Skip to content

Commit

Permalink
Add data name to message (precice#826)
Browse files Browse the repository at this point in the history
* Add dataName to exchange cplscheme error message

* Fix comment

* Apply refactoring.

Co-authored-by: BenjaminRueth <[email protected]>
  • Loading branch information
uekerman and BenjaminRodenberg authored Jul 20, 2020
1 parent 743232d commit 5b566bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/cplscheme/config/CouplingSchemeConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,20 @@ mesh::PtrData CouplingSchemeConfiguration::getData(
<< meshName << "\" is not configured.");
}

mesh::PtrData CouplingSchemeConfiguration::findDataByID(
int ID) const
{
for (mesh::PtrMesh mesh : _meshConfig->meshes()) {
for (mesh::PtrData data : mesh->data()) {
if (data->getID() == ID) {
return data;
}
}
}
return nullptr;
}


PtrCouplingScheme CouplingSchemeConfiguration::createSerialExplicitCouplingScheme(
const std::string &accessor) const
{
Expand Down Expand Up @@ -1067,8 +1081,15 @@ void CouplingSchemeConfiguration::checkIfDataIsExchanged(
hasFound = true;
}
}

std::string dataName = "";
auto dataptr = findDataByID(dataID);
if (dataptr) {
dataName = dataptr->getName();
}

PRECICE_CHECK(hasFound, "You need to exchange every data that you use for convergence measures "
<< "and/or the iteration acceleration. Data \"" << dataID << "\" is " /// @todo better provide the dataName! Is there an easy way to access it?
<< "and/or the iteration acceleration. Data \"" << dataName << "\" is "
<< "currently not exchanged, but used for convergence measures and/or iteration "
<< "acceleration. Please check the <exchange ... /> and "
<< "<...-convergence-measure ... /> tags in the "
Expand Down
3 changes: 3 additions & 0 deletions src/cplscheme/config/CouplingSchemeConfiguration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class CouplingSchemeConfiguration : public xml::XMLTag::Listener {
const std::string &dataName,
const std::string &meshName) const;

mesh::PtrData findDataByID(
int ID) const;

PtrCouplingScheme createSerialExplicitCouplingScheme(
const std::string &accessor) const;

Expand Down

0 comments on commit 5b566bd

Please sign in to comment.