void NearestNeighborMapping:: computeMapping() { preciceTrace1("computeMapping()", input()->vertices().size()); assertion(input().get() != NULL); assertion(output().get() != NULL); if (getConstraint() == CONSISTENT){ preciceDebug("Compute consistent mapping"); size_t verticesSize = output()->vertices().size(); _vertexIndices.resize(verticesSize); const mesh::Mesh::VertexContainer& outputVertices = output()->vertices(); for ( size_t i=0; i < verticesSize; i++ ){ const utils::DynVector& coords = outputVertices[i].getCoords(); query::FindClosestVertex find(coords); find(*input()); assertion(find.hasFound()); _vertexIndices[i] = find.getClosestVertex().getID(); } } else { assertion1(getConstraint() == CONSERVATIVE, getConstraint()); preciceDebug("Compute conservative mapping"); size_t verticesSize = input()->vertices().size(); _vertexIndices.resize(verticesSize); const mesh::Mesh::VertexContainer& inputVertices = input()->vertices(); for ( size_t i=0; i < verticesSize; i++ ){ const utils::DynVector& coords = inputVertices[i].getCoords(); query::FindClosestVertex find(coords); find(*output()); assertion(find.hasFound()); _vertexIndices[i] = find.getClosestVertex().getID(); } } _hasComputedMapping = true; }
MPIPortsCommunication:: ~MPIPortsCommunication() { preciceTrace1 ( "~MPIPortsCommunication()", _isConnection ); if (_isConnection){ closeConnection(); } }
void XMLTag:: parseSubtag ( XMLTag::XMLReader* xmlReader ) { preciceTrace1("parseSubtag()", _fullName); bool success = false; foreach (XMLTag* tag, _subtags){ if (std::string(xmlReader->getNodeName()) == tag->getFullName()){ if (tag->isConfigured() && (tag->getOccurrence() == OCCUR_ONCE || tag->getOccurrence() == OCCUR_NOT_OR_ONCE)) { std::string error = "Tag <" + tag->getFullName() + "> is not allowed to occur multiple times"; throw error; } tag->parse(xmlReader); if (not tag->_namespace.empty()){ assertion(utils::contained(tag->_namespace, _configuredNamespaces)); _configuredNamespaces[tag->_namespace] = true; } success = true; break; // since the xmlReader should not advance further } } if (not success){ std::ostringstream stream; stream << "Wrong tag <" << xmlReader->getNodeName() << ">"; throw stream.str(); } }
void ImportSTL:: doImport ( const std::string& name, mesh::Mesh& mesh ) { preciceTrace1("doImport()", name); assertion1(mesh.getDimensions() == 3, mesh.getDimensions()); // TODO }
void MPICommunication:: send ( double* itemsToSend, int size, int rankReceiver ) { preciceTrace1 ( "send(double*)", size ); assertion ( rankReceiver != ANY_SENDER ); MPI_Send ( itemsToSend, size, MPI_DOUBLE, rankReceiver, 0, _communicator ); }
void XMLTag:: addAttribute ( const XMLAttribute<double>& attribute ) { preciceTrace1 ( "addAttribute<double>()", attribute.getName() ); assertion(not utils::contained(attribute.getName(), _attributes)); _attributes.insert(attribute.getName()); _doubleAttributes.insert(std::pair<std::string,XMLAttribute<double> > (attribute.getName(), attribute)); }
int MPICommunication:: receive ( double & itemToReceive, int rankSender ) { preciceTrace1 ( "receive(double)", rankSender ); rankSender = rankSender == ANY_SENDER ? MPI_ANY_SOURCE : rankSender; MPI_Status status; MPI_Recv (&itemToReceive, 1, MPI_DOUBLE, rankSender, 0, _communicator, &status); preciceDebug ( "Received " << itemToReceive << " from rank " << status.MPI_SOURCE ); return status.MPI_SOURCE; }
int MPICommunication:: receive ( double * itemsToReceive, int size, int rankSender ) { preciceTrace1 ( "receive(double*)", size ); rankSender = rankSender == ANY_SENDER ? MPI_ANY_SOURCE : rankSender; MPI_Status status; MPI_Recv ( itemsToReceive, size, MPI_DOUBLE, rankSender, 0, _communicator, &status ); return status.MPI_SOURCE; }
void UncoupledScheme:: addComputedTime ( double timeToAdd ) { preciceTrace1("addComputedTime()", timeToAdd); preciceCheck ( isCouplingOngoing(), "addComputedTime()", "Invalid call of addComputedTime() after simulation end!" ); # ifdef Asserts bool greaterThanZero = tarch::la::greater(timeToAdd, 0.0, _eps); assertion1(greaterThanZero, timeToAdd); # endif // Asserts setComputedTimestepPart(getComputedTimestepPart() + timeToAdd); setTime(getTime() + timeToAdd); }
int MPICommunication:: receive ( bool & itemToReceive, int rankSender ) { preciceTrace1 ( "receive(bool)", rankSender ); rankSender = rankSender == ANY_SENDER ? MPI_ANY_SOURCE : rankSender; MPI_Status status; int buffer = -1; MPI_Recv ( &buffer, 1, MPI_INT, rankSender, 0, _communicator, &status ); assertion ( buffer != -1 ); itemToReceive = (buffer == 1) ? true : false; preciceDebug ( "Received " << itemToReceive << " from rank " << status.MPI_SOURCE ); return status.MPI_SOURCE; }
void BaseCouplingScheme:: sendState ( com::PtrCommunication communication, int rankReceiver) { preciceTrace1("sendState()", rankReceiver); communication->startSendPackage(rankReceiver ); assertion(communication.get() != NULL); assertion(communication->isConnected()); communication->send(_maxTime, rankReceiver); communication->send(_maxTimesteps, rankReceiver); communication->send(_timestepLength, rankReceiver); communication->send(_time, rankReceiver); communication->send(_timesteps, rankReceiver); communication->send(_checkpointTimestepInterval, rankReceiver); communication->send(_computedTimestepPart, rankReceiver); //communication->send(_maxLengthNextTimestep, rankReceiver); communication->send(_isInitialized, rankReceiver); communication->send(_isCouplingTimestepComplete, rankReceiver); communication->send(_hasDataBeenExchanged, rankReceiver); communication->send((int)_actions.size(), rankReceiver); foreach(const std::string& action, _actions) { communication->send(action, rankReceiver); }
bool NearestNeighborMapping:: hasComputedMapping() { preciceTrace1("hasComputedMapping()", _hasComputedMapping); return _hasComputedMapping; }
void XMLTag:: parse ( XMLTag::XMLReader* xmlReader ) { preciceTrace1("parse()", _fullName); try { resetAttributes(); if (xmlReader->getNodeType() == tarch::irr::io::EXN_ELEMENT){ assertion(xmlReader->getNodeName() != NULL); preciceDebug("reading attributes of tag " << xmlReader->getNodeName()); readAttributes(xmlReader); _listener.xmlTagCallback(*this); } if (_subtags.size() > 0){ while (xmlReader->read()){ if (xmlReader->getNodeType() == tarch::irr::io::EXN_ELEMENT){ assertion(xmlReader->getNodeName() != NULL); preciceDebug("reading subtag " << xmlReader->getNodeName() << " of tag " << _fullName); parseSubtag(xmlReader); } else if (xmlReader->getNodeType() == tarch::irr::io::EXN_ELEMENT_END){ assertion(xmlReader->getNodeName() != NULL); if (std::string(xmlReader->getNodeName()) == _fullName){ preciceDebug("end of tag " << xmlReader->getNodeName()); areAllSubtagsConfigured(); _configured = true; _listener.xmlEndTagCallback(*this); //resetAttributes(); return; } else { std::ostringstream stream; if (not _fullName.empty()){ stream << "Invalid closing tag </" << xmlReader->getNodeName() << ">"; throw stream.str(); } //else { // stream << "Invalid closing tag </" << xmlReader->getNodeName() // << ">, expected closing of tag <" << _fullName << "> instead"; //} } } } if (not _name.empty()){ std::ostringstream error; error << "Missing closing tag </" << _fullName << ">"; throw error.str(); } } else { _configured = true; } } catch (std::string errorMsg){ if (not _name.empty()){ errorMsg += "\n in tag <" + _fullName + ">"; } throw errorMsg; } }