50 :
TAG(
"coupling-scheme"),
98 XMLTag::Occurrence occ = XMLTag::OCCUR_ARBITRARY;
99 std::vector<XMLTag> tags;
102 tag.setDocumentation(
"Explicit coupling scheme according to conventional serial staggered procedure (CSS).");
108 tag.setDocumentation(
"Explicit coupling scheme according to conventional parallel staggered procedure (CPS).");
114 tag.setDocumentation(
"Implicit coupling scheme according to block Gauss-Seidel iterations (S-System). "
115 "Improved implicit iterations are achieved by using a acceleration (recommended!).");
121 tag.setDocumentation(
"Parallel Implicit coupling scheme according to block Jacobi iterations (V-System). "
122 "Improved implicit iterations are achieved by using a acceleration (recommended!).");
128 tag.setDocumentation(
"Multi coupling scheme according to block Jacobi iterations. "
129 "Improved implicit iterations are achieved by using a acceleration (recommended!).");
134 for (XMLTag &tag : tags) {
140 const std::string &participantName)
const
146 const std::string &participantName)
const
149 "No coupling scheme defined for participant \"{}\". "
150 "Please make sure to provide at least one <coupling-scheme:TYPE> in your "
151 "precice-config.xml that couples this participant using the <participants .../> tag.",
169 "First participant in coupling-scheme <participants first=\"{}\" second=\"{}\" /> is unknown. {}",
172 "Second participant in coupling-scheme <participants first=\"{}\" second=\"{}\" /> is unknown. {}",
175 "First and second participant in coupling scheme are the same. "
176 "Please choose different in the <participants first=\"{}\" second=\"{}\" /> tag in the <coupling-scheme:...> of your precice-config.xml",
178 _config.participants.push_back(first);
179 _config.participants.push_back(second);
185 "Provided participant in multi coupling-scheme <participant name=\"{}\" ... /> is unknown. {}",
188 "Participant \"{0}\" is provided multiple times to multi coupling scheme. "
189 "Please make sure that you do not provide the participant multiple times via the <participant name=\"{0}\" /> "
190 "tag in the <coupling-scheme:...> of your precice-config.xml",
194 "Only one controller per MultiCouplingScheme can be defined. "
195 "Please check the <participant name=\"{}\" control=\"{}\" /> tag in the <coupling-scheme:...> of your precice-config.xml",
196 participantName, control);
197 _config.controller = participantName;
200 _config.participants.push_back(participantName);
204 "Maximum time has to be larger than zero. "
205 "Please check the <max-time value=\"{}\" /> tag in the <coupling-scheme:...> of your precice-config.xml",
210 "Maximum number of time windows has to be larger than zero. "
211 "Please check the <max-time-windows value=\"{}\" /> tag in the <coupling-scheme:...> of your precice-config.xml",
220 "The minimal time window size supported by preCICE is {}. "
221 "Please check the <time-window-size value=\"{}\" /> tag "
222 "in the <coupling-scheme:...> of your precice-config.xml and pick an appropriate time window size.",
227 "You combined a custom time-window-size of {} with method=\"first-participant\". "
228 "The given time-window-size will be ignored as it is prescribed by the participant.",
274 "Mesh \"{}\" with data \"{}\" not defined. "
275 "Please check the <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" /> "
276 "tag in the <coupling-scheme:... /> of your precice-config.xml.",
277 nameMesh, nameData, nameData, nameMesh, nameParticipantFrom, nameParticipantTo);
284 Config::Exchange newExchange{exchangeData, exchangeMesh, nameParticipantFrom, nameParticipantTo, initialize, exchangeSubsteps};
286 R
"(Data "{}" of mesh "{}" cannot be exchanged multiple times between participants "{}" and "{}". Please remove one of the exchange tags.)",
287 nameData, nameMesh, nameParticipantFrom, nameParticipantTo);
289 _meshConfig->addNeededMesh(nameParticipantFrom, nameMesh);
290 _meshConfig->addNeededMesh(nameParticipantTo, nameMesh);
291 _config.exchanges.emplace_back(std::move(newExchange));
296 "Minimum iteration limit has to be larger than zero. Please check the <min-iterations value = \"{}\" /> subtag in the <coupling-scheme:... /> of your precice-config.xml.",
302 "Maximal iteration limit has to be larger than zero. "
303 "Please check the <max-iterations value=\"{0}\" /> subtag in the <coupling-scheme:... /> of your precice-config.xml. "
304 "To disable the iteration limit, remove the <max-iterations value=\"{0}\" /> subtag.",
311 "Maximum iteration limit {1} has to be larger or equal than the minimum iteration limit {0}. "
312 "Please check the <min-iterations value = \"{0}\" /> and <max-iterations value = \"{1}\" /> subtags in the <coupling-scheme:... /> of your precice-config.xml.",
326 "At least one termination condition is required "
327 "for the coupling scheme of type \"{}\". "
328 "Please add a <max-time value=\"...\"/> or <max-time-windows value=\"...\"/> tag "
329 "inside your <coupling-scheme:{}> configuration.",
332 PRECICE_CHECK(!
_allowRemeshing,
"Remeshing is currently incompatible with serial coupling schemes. Try using a parallel or a multi coupling scheme instead.");
333 std::string accessor(
_config.participants[0]);
337 accessor =
_config.participants[1];
343 std::string accessor(
_config.participants[0]);
347 accessor =
_config.participants[1];
353 PRECICE_CHECK(!
_allowRemeshing,
"Remeshing is currently incompatible with serial coupling schemes. Try using a parallel or a multi coupling scheme instead.");
355 std::string accessor(
_config.participants[0]);
359 accessor =
_config.participants[1];
365 PRECICE_INFO_IF(
_allowRemeshing,
"Remeshing for implicit coupling schemes is in development. Currently, the acceleration data is deleted on remeshing.");
367 std::string accessor(
_config.participants[0]);
370 accessor =
_config.participants[1];
376 PRECICE_CHECK(!
_allowRemeshing,
"Remeshing is currently incompatible with multi coupling schemes. Try using a parallel coupling scheme instead.");
377 PRECICE_INFO_IF(
_allowRemeshing,
"Remeshing for implicit coupling schemes is in development. Currently, the acceleration data is deleted on remeshing.");
380 "One controller per MultiCoupling needs to be defined. "
381 "Please check the <participant name=... /> tags in the <coupling-scheme:... /> of your precice-config.xml. "
382 "Make sure that at least one participant tag provides the attribute <participant name=... control=\"True\"/>.");
383 for (
const std::string &accessor :
_config.participants) {
396 const std::string &participantName)
400 PRECICE_DEBUG(
"No coupling scheme exists for the participant");
407 PRECICE_CHECK(!
_allowRemeshing,
"Remeshing is currently incompatible with compositional coupling schemes. If you need remeshing, try using a multi coupling scheme to compose your participants.");
411 PRECICE_DEBUG(
"Creating a compositional coupling scheme for the participant");
412 auto composition = std::make_shared<CompositionalCouplingScheme>();
422 PRECICE_CHECK(!cplScheme->isImplicitCouplingScheme() || !composition->isImplicitCouplingScheme(),
423 "You attempted to define a second implicit coupling-scheme for the participant \"{}\", which is not allowed. "
424 "Please use a multi coupling-scheme for true implicit coupling of multiple participants.",
430 const std::string &type,
481 const std::string &type,
485 XMLTag tagMaxTime(*
this,
TAG_MAX_TIME, XMLTag::OCCUR_NOT_OR_ONCE);
486 tagMaxTime.setDocumentation(
"Defined the end of the simulation as total time.");
488 XMLAttribute<double> attrValueMaxTime(
ATTR_VALUE);
489 attrValueMaxTime.setDocumentation(
"The value of the maximum simulation time.");
490 tagMaxTime.addAttribute(attrValueMaxTime);
494 tagMaxTimeWindows.setDocumentation(
"Defined the end of the simulation as a total count of time windows.");
495 XMLAttribute<int> attrValueMaxTimeWindows(
ATTR_VALUE);
496 attrValueMaxTimeWindows.setDocumentation(
"The maximum count of time windows.");
497 tagMaxTimeWindows.addAttribute(attrValueMaxTimeWindows);
501 tagTimeWindowSize.setDocumentation(
"Defines the size of the time window.");
503 .setDocumentation(
"The maximum time window size.");
504 tagTimeWindowSize.addAttribute(attrValueTimeWindowSize);
509 .setDocumentation(
"The method used to determine the time window size. Use `fixed` to fix the time window size for the participants.");
510 tagTimeWindowSize.addAttribute(attrMethod);
512 tagTimeWindowSize.addAttributeHint(
ATTR_METHOD,
"This feature is only available for serial coupling schemes.");
522 tagParticipants.setDocumentation(
"Defines the participants of the coupling scheme.");
523 XMLAttribute<std::string> attrFirst(
ATTR_FIRST);
524 attrFirst.setDocumentation(
"First participant to run the solver.");
525 tagParticipants.addAttribute(attrFirst);
527 attrSecond.setDocumentation(
"Second participant to run the solver.");
528 tagParticipants.addAttribute(attrSecond);
536 XMLTag tagParticipant(*
this,
TAG_PARTICIPANT, XMLTag::OCCUR_ONCE_OR_MORE);
537 XMLAttribute<std::string> attrName(
ATTR_NAME);
538 attrName.setDocumentation(
"Name of the participant.");
539 tagParticipant.addAttribute(attrName);
541 attrControl.setDocumentation(
"Does this participant control the coupling?");
542 tagParticipant.addAttribute(attrControl);
550 XMLTag tagExchange(*
this,
TAG_EXCHANGE, XMLTag::OCCUR_ONCE_OR_MORE);
551 tagExchange.setDocumentation(
"Defines the flow of data between meshes of participants.");
553 auto attrData = XMLAttribute<std::string>(
ATTR_DATA).setDocumentation(
"The data to exchange.");
554 tagExchange.addAttribute(attrData);
555 auto attrMesh = XMLAttribute<std::string>(
ATTR_MESH).setDocumentation(
"The mesh which uses the data.");
556 tagExchange.addAttribute(attrMesh);
557 auto participantFrom = XMLAttribute<std::string>(
ATTR_FROM).setDocumentation(
"The participant sending the data.");
558 tagExchange.addAttribute(participantFrom);
559 auto participantTo = XMLAttribute<std::string>(
ATTR_TO).setDocumentation(
"The participant receiving the data.");
560 tagExchange.addAttribute(participantTo);
561 auto attrInitialize = XMLAttribute<bool>(
ATTR_INITIALIZE,
false).setDocumentation(
"Should this data be initialized during initialize?");
562 tagExchange.addAttribute(attrInitialize);
563 auto attrExchangeSubsteps = XMLAttribute<bool>(
ATTR_EXCHANGE_SUBSTEPS, substepsDefault).setDocumentation(
"Should this data exchange substeps?");
564 tagExchange.addAttribute(attrExchangeSubsteps);
573 tagConvergenceMeasure.setDocumentation(
574 "Absolute convergence criterion based on the two-norm difference of data values between iterations.\n"
575 "\\$$\\left\\lVert H(x^k) - x^k \\right\\rVert_2 < \\text{limit}\\$$");
578 attrLimit.setDocumentation(
"Limit under which the measure is considered to have converged. Must be in \\((0, 1]\\).");
579 tagConvergenceMeasure.addAttribute(attrLimit);
588 tagConvergenceMeasure.setDocumentation(
589 "Absolute or relative convergence, which is the disjunction of an absolute criterion based on the two-norm difference of data values between iterations and a relative criterion based on the relative two-norm difference of data values between iterations,i.e. convergence is reached as soon as one of the both criteria is fulfilled. "
590 "\\$$\\left\\lVert H(x^k) - x^k \\right\\rVert_2 < \\text{abs-limit}\\quad\\text{or}\\quad\\frac{\\left\\lVert H(x^k) - x^k \\right\\rVert_2}{\\left\\lVert H(x^k) \\right\\rVert_2} < \\text{rel-limit} \\$$ ");
593 attrAbsLimit.setDocumentation(R
"(Absolute limit under which the measure is considered to have converged.)");
594 tagConvergenceMeasure.addAttribute(attrAbsLimit);
596 attrAbsLimit.setDocumentation(R"(Relative limit under which the measure is considered to have converged. Must be in \\((0, 1]\\).)");
597 tagConvergenceMeasure.addAttribute(attrRelLimit);
606 XMLTag::OCCUR_ARBITRARY);
607 tagConvergenceMeasure.setDocumentation(
608 "Relative convergence criterion comparing the currently measured residual to the residual of the first iteration in the time window.\n"
609 "\\$$\\frac{\\left\\lVert H(x^k) - x^k \\right\\rVert_2}{\\left\\lVert H(x^0) - x^0 \\right\\rVert_2} < \\text{limit}\\$$");
612 attrLimit.setDocumentation(
"Limit under which the measure is considered to have converged. Must be in \\((0, 1]\\).");
613 tagConvergenceMeasure.addAttribute(attrLimit);
622 tagConvergenceMeasure.setDocumentation(
623 "Relative convergence criterion based on the relative two-norm difference of data values between iterations.\n"
624 "\\$$\\frac{\\left\\lVert H(x^k) - x^k \\right\\rVert_2}{\\left\\lVert H(x^k) \\right\\rVert_2} < \\text{limit} \\$$");
627 attrLimit.setDocumentation(R
"(Limit under which the measure is considered to have converged. Must be in \\((0, 1]\\).)");
628 tagConvergenceMeasure.addAttribute(attrLimit);
636 auto attrData = XMLAttribute<std::string>(
ATTR_DATA)
637 .setDocumentation(
"Data to be measured.");
639 auto attrMesh = XMLAttribute<std::string>(
ATTR_MESH)
643 .setDocumentation(
"If true, convergence of this measure is sufficient for overall convergence.");
645 auto attrStrict = makeXMLAttribute(
ATTR_STRICT,
false)
646 .setDocumentation(
"If true, non-convergence of this measure ends the simulation. \"strict\" overrules \"suffices\".");
655 tagMinIterations.setDocumentation(
"Allows to specify a minimum amount of iterations that must be performed per time window.");
657 attrValue.setDocumentation(
"The minimum amount of iterations.");
658 tagMinIterations.addAttribute(attrValue);
667 tagMaxIterations.setDocumentation(
"Allows to specify a maximum amount of iterations per time window.");
669 attrValue.setDocumentation(
"The maximum value of iterations.");
670 tagMaxIterations.addAttribute(attrValue);
686 const std::string &dataName,
687 const std::string &meshName,
694 "Absolute convergence limit has to be greater than zero. "
695 "Please check the <absolute-convergence-measure limit=\"{}\" data=\"{}\" mesh=\"{}\" /> subtag "
696 "in your <coupling-scheme ... /> in the preCICE configuration file.",
697 limit, dataName, meshName);
701 convMeasureDef.
strict = strict;
703 convMeasureDef.
measure = std::make_shared<impl::AbsoluteConvergenceMeasure>(limit);
704 _config.convergenceMeasureDefinitions.push_back(convMeasureDef);
708 const std::string &dataName,
709 const std::string &meshName,
717 "Absolute convergence limit has to be greater than zero. "
718 "Please check the <absolute-or-relative-convergence-measure abs-limit=\"{}\" rel-limit=\"{}\" data=\"{}\" mesh=\"{}\" /> subtag "
719 "in your <coupling-scheme ... /> in the preCICE configuration file.",
720 absLimit, relLimit, dataName, meshName);
722 "Relative convergence limit has to be in ]0;1]. "
723 "Please check the <absolute-or-relative-convergence-measure abs-limit=\"{}\" rel-limit=\"{}\" data=\"{}\" mesh=\"{}\" /> subtag "
724 "in your <coupling-scheme ... /> in the preCICE configuration file.",
725 absLimit, relLimit, dataName, meshName);
729 convMeasureDef.
strict = strict;
731 convMeasureDef.
measure = std::make_shared<impl::AbsoluteOrRelativeConvergenceMeasure>(absLimit, relLimit);
732 _config.convergenceMeasureDefinitions.push_back(convMeasureDef);
736 const std::string &dataName,
737 const std::string &meshName,
744 "Relative convergence limit has to be in ]0;1]. "
745 "Please check the <relative-convergence-measure limit=\"{}\" data=\"{}\" mesh=\"{}\" /> subtag "
746 "in your <coupling-scheme ... /> in the preCICE configuration file.",
747 limit, dataName, meshName);
750 "The relative convergence limit=\"{}\" is close to the hard-coded numerical resolution=\"{}\" of preCICE. "
751 "This may lead to instabilities. The minimum relative convergence limit should be > \"{}\"",
757 convMeasureDef.
strict = strict;
759 convMeasureDef.
measure = std::make_shared<impl::RelativeConvergenceMeasure>(limit);
760 _config.convergenceMeasureDefinitions.push_back(convMeasureDef);
764 const std::string &dataName,
765 const std::string &meshName,
772 "Relative convergence limit has to be in ]0;1]. "
773 "Please check the <residual-relative-convergence-measure limit=\"{}\" data=\"{}\" mesh=\"{}\" /> subtag "
774 "in your <coupling-scheme ... /> in the preCICE configuration file.",
775 limit, dataName, meshName);
778 "The relative convergence limit=\"{}\" is close to the hard-coded numerical resolution=\"{}\" of preCICE. "
779 "This may lead to instabilities. The minimum relative convergence limit should be > \"{}\"",
785 convMeasureDef.
strict = strict;
787 convMeasureDef.
measure = std::make_shared<impl::ResidualRelativeConvergenceMeasure>(limit);
788 _config.convergenceMeasureDefinitions.push_back(convMeasureDef);
792 const std::string &dataName,
793 const std::string &meshName)
const
796 "Data \"{}\" used by mesh \"{}\" is not configured.", dataName, meshName);
798 return mesh->data(dataName);
805 if (
mesh->hasDataID(ID)) {
806 return mesh->data(ID);
813 const std::string &accessor)
const
820 for (
const auto &exchange :
_config.exchanges) {
821 if ((exchange.from ==
_config.participants[1]) && exchange.exchangeSubsteps) {
823 "Exchange of substeps is activated in the serial-explicit coupling between the second participant \"{}\" and first participant \"{}\". This is inefficient as these substeps will never be used. You can turn this off in your preCICE configuration setting substeps=\"false\" in <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" substeps=\"false\" />", exchange.from, exchange.to, exchange.data->getName(), exchange.mesh->getName(), exchange.from, exchange.to);
833 const std::string &accessor)
const
841 for (
const auto &exchange :
_config.exchanges) {
842 if (exchange.exchangeSubsteps) {
844 "Exchange of substeps is activated in the parallel-explicit coupling between \"{}\" and \"{}\". This is inefficient as these substeps will never be used. You can turn this off in your preCICE configuration setting substeps=\"false\" in <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" substeps=\"false\" />", exchange.from, exchange.to, exchange.data->getName(), exchange.mesh->getName(), exchange.from, exchange.to);
854 const std::string &accessor)
const
858 const auto first =
_config.participants[0];
859 const auto second =
_config.participants[1];
863 SerialCouplingScheme *scheme =
new SerialCouplingScheme(
_config.maxTime,
_config.maxTimeWindows,
_config.timeWindowSize, first, second, accessor,
m2n,
_config.dtMethod,
BaseCouplingScheme::Implicit,
_config.minIterations,
_config.maxIterations);
867 "No send data configured. "
868 "Use explicit scheme for one-way coupling. "
869 "Please check your <coupling-scheme ... /> and make sure that you provide at least one <exchange .../> subtag, "
870 "where from=\"{}\".",
883 "In case of serial coupling, acceleration can be defined for data of second participant only!");
890 const std::string &accessor)
const
900 "No send data configured. Use explicit scheme for one-way coupling. "
901 "Please check your <coupling-scheme ... /> and make sure that you provide at least one <exchange .../> subtag, "
902 "where from=\"{}\".",
916 const std::string &accessor)
const
923 std::map<std::string, m2n::PtrM2N> m2ns;
924 for (
const std::string &participant :
_config.participants) {
925 if (
_m2nConfig->isM2NConfigured(accessor, participant)) {
926 m2ns[participant] =
_m2nConfig->getM2N(accessor, participant);
934 PRECICE_ASSERT(castedScheme,
"The dynamic cast of CouplingScheme failed.");
938 "No send data configured. Use explicit scheme for one-way coupling. "
939 "Please check your <coupling-scheme ... /> and make sure that you provide at least one "
940 "<exchange .../> subtag, where from=\"{}\".",
945 if (accessor ==
_config.controller) {
954 "Due to numerical reasons, for multi coupling, the number of coupling data vectors should be at least 3, not: {}. "
955 "Please check the <data .../> subtags in your <acceleration:.../> and make sure that you have at least 3.",
962 const std::string &method)
const
984 if (
_config.convergenceMeasureDefinitions.empty()) {
986 "Not defining convergence measures without providing a maximum iteration limit is forbidden. "
987 "Please define a convergence measure or set a maximum iteration limit using <max-iterations value=\"...\" />.");
989 PRECICE_INFO(
"No convergence measures were defined for an implicit coupling scheme. "
990 "It will always iterate the maximum amount iterations, which is {}. "
991 "You may want to add a convergence measure in your <coupling-scheme:.../> in your configuration.",
1000 const auto &meshPtr = participant->findMesh(exchange.
data->getName());
1002 if (meshPtr ==
nullptr) {
1004 PRECICE_WARN(
"You defined <exchange data=\"{}\" ... to=\"{}\" /> in the <coupling-scheme:... />, but <participant name=\"{}\"> has no corresponding <read-data name=\"{}\" ... />. Usually this means that there is an error in your configuration.",
1005 exchange.
data->getName(), exchange.
to, exchange.
to, exchange.
data->getName());
1009 const auto &readDataContext = participant->readDataContext(meshPtr->getName(), exchange.
data->getName());
1010 if (readDataContext.getWaveformDegree() == 0) {
1012 "You configured <data:scalar/vector name=\"{}\" waveform-degree=\"{}\" />. Please deactivate exchange of substeps by setting substeps=\"false\" in the following exchange tag of your coupling scheme: <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" />. Reason: For constant interpolation no exchange of data for substeps is needed. Please consider using waveform-degree=\"1\" or higher, if you want to use subcycling.",
1013 readDataContext.getDataName(), readDataContext.getWaveformDegree(), exchange.
data->getName(), exchange.
mesh->
getName(), exchange.
from, exchange.
to);
1014 }
else if (readDataContext.getWaveformDegree() >= 2) {
1016 "You configured <data:scalar/vector name=\"{}\" waveform-degree=\"{}\" />. Please activate exchange of substeps by setting substeps=\"true\" in the following exchange tag of your coupling scheme: <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" />. Reason: For higher-order interpolation exchange of data for substeps is required. If you don't want to activate exchange of additional data, please consider using waveform-degree=\"1\". Note that deactivating exchange of substep data might lead to worse results, if you use subcycling.",
1017 readDataContext.getDataName(), readDataContext.getWaveformDegree(), exchange.
data->getName(), exchange.
mesh->
getName(), exchange.
from, exchange.
to);
1025 const std::string &accessor)
const
1029 const std::string &from = exchange.
from;
1030 const std::string &to = exchange.
to;
1031 const std::string &dataName = exchange.
data->getName();
1032 const std::string &meshName = exchange.
mesh->
getName();
1035 "You cannot define an exchange from and to the same participant. "
1036 "Please check the <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" /> tag in the <coupling-scheme:... /> of your precice-config.xml.",
1037 dataName, meshName, from, to);
1040 "Participant \"{}\" is not configured for coupling scheme. "
1041 "Please check the <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" /> tag in the <coupling-scheme:... /> of your precice-config.xml.",
1042 from, dataName, meshName, from, to);
1045 "Participant \"{}\" is not configured for coupling scheme. "
1046 "Please check the <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" /> tag in the <coupling-scheme:... /> of your precice-config.xml.",
1047 to, dataName, meshName, from, to);
1053 "Participant \"{}\" cannot initialize data of the directly-accessed mesh \"{}\" from the participant\"{}\". "
1054 "Either disable the initialization in the <exchange /> tag or use a locally provided mesh instead.",
1055 from, meshName, to);
1059 if (from == accessor) {
1061 }
else if (to == accessor) {
1073 const std::string &accessor)
const
1077 const std::string &from = exchange.
from;
1078 const std::string &to = exchange.
to;
1079 const std::string &dataName = exchange.
data->getName();
1080 const std::string &meshName = exchange.
mesh->
getName();
1083 "You cannot define an exchange from and to the same participant. "
1084 "Please check the <exchange data=\"{}\" mesh=\"{}\" from=\"{}\" to=\"{}\" /> tag in the <coupling-scheme:... /> of your precice-config.xml.",
1085 dataName, meshName, from, to);
1088 "Participant \"{}\" is not configured for coupling scheme",
1092 "Participant \"{}\" is not configured for coupling scheme", to);
1097 if (from == accessor) {
1099 }
else if (to == accessor) {
1107 DataID dataID, std::string_view participant)
const
1109 const auto match = std::find_if(
_config.exchanges.begin(),
1113 if (exchange.from != participant && exchange.to != participant) {
1116 return exchange.data->getID() == dataID;
1119 if (match != _config.exchanges.end()) {
1124 std::string dataName =
"";
1125 auto dataptr = findDataByID(dataID);
1127 dataName = dataptr->getName();
1130 PRECICE_ERROR(
"You need to exchange every data that you use for convergence measures and/or the iteration acceleration. "
1131 "Data \"{}\" is currently not exchanged over the respective mesh of participant \"{}\" on which it is used for convergence measures and/or iteration acceleration. "
1132 "Please check the <exchange ... /> and <...-convergence-measure ... /> tags in the <coupling-scheme:... /> of your precice-config.xml.",
1133 dataName, participant);
1138 const std::string &first,
1139 const std::string &second)
const
1142 const auto match = std::find_if(
_config.exchanges.begin(),
1144 [dataID](
const Config::Exchange &exchange) { return exchange.data->getID() == dataID; });
1146 const auto &exchange = *match;
1149 if (second == exchange.
from) {
1153 std::string dataName =
"";
1156 dataName = dataptr->getName();
1160 "You configured acceleration data \"{}\" in the serial implicit coupling scheme between participants \"{}\" and \"{}\". "
1161 "For serial implicit coupling schemes, only data exchanged from the second to the first participant can be used for acceleration. "
1162 "Here, from \"{}\" to \"{}\". "
1163 "However, you configured data \"{}\" for acceleration, which is exchanged from \"{}\" to \"{}\". "
1164 "Please remove this acceleration data tag or switch to a parallel implicit coupling scheme.",
1165 dataName, first, second, second, first, dataName, first, second);
1170 const std::string &participant,
1171 const std::vector<ConvergenceMeasureDefintion> &convergenceMeasureDefinitions)
const
1173 for (
auto &elem : convergenceMeasureDefinitions) {
1174 _meshConfig->addNeededMesh(participant, elem.meshName);
1182 const std::string &first,
1183 const std::string &second)
const
1198 const std::string &participant)
const
1202 _meshConfig->addNeededMesh(participant, neededMesh);
1211 "You configured participant \"{}\" in a parallel-implicit coupling scheme with \"Aitken\" "
1212 "acceleration, which is known to perform bad in parallel coupling schemes. "
1213 "See https://precice.org/configuration-acceleration.html#dynamic-aitken-under-relaxation for details. "
1214 "Consider switching to a serial-implicit coupling scheme or changing the acceleration method.",
#define PRECICE_ERROR(...)
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO_IF(condition,...)
#define PRECICE_INFO(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
const std::string & getName() const
Returns the name of the mesh, as set in the config file.
const DataContainer & data() const
Allows access to all data.
Abstract base class for standard coupling schemes.
virtual bool hasAnySendData()=0
void setAcceleration(const acceleration::PtrAcceleration &acceleration)
Set an acceleration technique.
void addConvergenceMeasure(int dataID, bool suffices, bool strict, impl::PtrConvergenceMeasure measure)
Adds a measure to determine the convergence of coupling iterations.
bool doesFirstStep() const
Getter for _doesFirstStep.
Abstract base class for coupling schemes with two participants.
bool hasSendData(DataID dataID)
bool hasAnySendData() final override
void addDataToReceive(const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps)
Adds data to be received on data exchange.
void addDataToSend(const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps)
Adds data to be sent on data exchange and possibly be modified during coupling iterations.
void determineInitialDataExchange() override
Determines which data is initialized and therefore has to be exchanged during initialize.
const std::string TAG_ABS_CONV_MEASURE
const std::string ATTR_NAME
PtrCouplingScheme createSerialExplicitCouplingScheme(const std::string &accessor) const
void checkIterationLimits() const
Helper function to check iteration limits in conjunction with convergence measures.
const std::string VALUE_PARALLEL_IMPLICIT
const PtrCouplingScheme & getCouplingScheme(const std::string &participantName) const
Returns the configured coupling scheme.
precice::config::PtrParticipantConfiguration _participantConfig
const std::string TAG_MAX_TIME_WINDOWS
void addMultiDataToBeExchanged(MultiCouplingScheme &scheme, const std::string &accessor) const
Adds configured exchange data to be sent or received to scheme. Only used specifically for MultiCoupl...
PtrCouplingScheme createSerialImplicitCouplingScheme(const std::string &accessor) const
void addBaseAttributesTagConvergenceMeasure(xml::XMLTag &tag)
const std::string TAG_TIME_WINDOW_SIZE
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback method required when using xml::XMLTag.
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback method required when using xml::XMLTag.
void setSerialAcceleration(BaseCouplingScheme *scheme, const std::string &first, const std::string &second) const
void addResidualRelativeConvergenceMeasure(const std::string &dataName, const std::string &meshName, double limit, bool suffices, bool strict)
void addTagMinIterations(xml::XMLTag &tag)
const std::string ATTR_SECOND
const std::string ATTR_REL_LIMIT
mesh::PtrData getData(const std::string &dataName, const std::string &meshName) const
void addAbsoluteConvergenceMeasure(const std::string &dataName, const std::string &meshName, double limit, bool suffices, bool strict)
const std::string ATTR_INITIALIZE
const std::string TAG_RES_REL_CONV_MEASURE
void addDataToBeExchanged(BiCouplingScheme &scheme, const std::string &accessor) const
Adds configured exchange data to be sent or received to scheme.
void addTagRelativeConvergenceMeasure(xml::XMLTag &tag)
void addTagAcceleration(xml::XMLTag &tag)
const std::string ATTR_METHOD
void addTagParticipant(xml::XMLTag &tag)
struct precice::cplscheme::CouplingSchemeConfiguration::Config _config
void checkSubstepExchangeWaveformDegree(const Config::Exchange &exchange) const
Helper function to check that waveform-degree and substep exchange are compatible.
const std::string VALUE_SERIAL_EXPLICIT
const std::string TAG_REL_CONV_MEASURE
const std::string ATTR_TYPE
const std::string ATTR_VALUE
const std::string VALUE_PARALLEL_EXPLICIT
constants::TimesteppingMethod getTimesteppingMethod(const std::string &method) const
void checkSerialImplicitAccelerationData(DataID dataID, const std::string &first, const std::string &second) const
void addTagAbsoluteConvergenceMeasure(xml::XMLTag &tag)
acceleration::PtrAccelerationConfiguration _accelerationConfig
std::map< std::string, PtrCouplingScheme > _couplingSchemes
Map from participant name to coupling scheme (composition).
void checkIfDataIsExchanged(DataID dataID, std::string_view participant) const
const std::string ATTR_LIMIT
const std::string TAG_MIN_ITERATIONS
const std::string TAG_EXCHANGE
CouplingSchemeConfiguration(xml::XMLTag &parent, mesh::PtrMeshConfiguration meshConfig, m2n::M2NConfiguration::SharedPointer m2nConfig, config::PtrParticipantConfiguration participantConfig)
Constructor.
void addTagExchange(xml::XMLTag &tag, bool substepsDefault)
mesh::PtrData findDataByID(int ID) const
const std::string TAG_PARTICIPANT
void addTypespecifcSubtags(const std::string &type, xml::XMLTag &tag)
PtrCouplingScheme createMultiCouplingScheme(const std::string &accessor) const
const std::string ATTR_STRICT
mesh::PtrMeshConfiguration _meshConfig
const std::string ATTR_CONTROL
void addCouplingScheme(const PtrCouplingScheme &cplScheme, const std::string &participantName)
Adds a manually configured coupling scheme for a participant.
const std::string ATTR_MESH
const std::string ATTR_SUFFICES
const std::string TAG_PARTICIPANTS
void setRemeshing(bool allowed)
bool hasCouplingScheme(const std::string &participantName) const
Check, if a coupling scheme is configured for a participant.
static const int DEFAULT_MAX_ITERATIONS
void updateConfigForImplicitCoupling()
Helper to update some configs which may have a different meaning in implicit coupling.
const std::string VALUE_FIXED
m2n::M2NConfiguration::SharedPointer _m2nConfig
void addAbsoluteOrRelativeConvergenceMeasure(const std::string &dataName, const std::string &meshName, double absLimit, double relLimit, bool suffices, bool strict)
static const int DEFAULT_MIN_ITERATIONS
void addTagParticipants(xml::XMLTag &tag)
PtrCouplingScheme createParallelImplicitCouplingScheme(const std::string &accessor) const
const std::string VALUE_SERIAL_IMPLICIT
const std::string ATTR_ABS_LIMIT
const std::string ATTR_PARTICIPANT
const std::string ATTR_TO
const std::string VALUE_MULTI
void addTagResidualRelativeConvergenceMeasure(xml::XMLTag &tag)
const std::string TAG_MAX_TIME
PtrCouplingScheme createParallelExplicitCouplingScheme(const std::string &accessor) const
void addTransientLimitTags(const std::string &type, xml::XMLTag &tag)
void addTagAbsoluteOrRelativeConvergenceMeasure(xml::XMLTag &tag)
const std::string TAG_MAX_ITERATIONS
const std::string ATTR_FROM
void addTagMaxIterations(xml::XMLTag &tag)
const std::string ATTR_EXCHANGE_SUBSTEPS
void addRelativeConvergenceMeasure(const std::string &dataName, const std::string &meshName, double limit, bool suffices, bool strict)
const std::string ATTR_FIRST
std::map< std::string, CompositionalCouplingScheme * > _couplingSchemeCompositions
If a participant has more than one coupling scheme, a composition is created.
void addConvergenceMeasures(BaseCouplingScheme *scheme, const std::string &participant, const std::vector< ConvergenceMeasureDefintion > &convergenceMeasureDefinitions) const
void setParallelAcceleration(BaseCouplingScheme *scheme, const std::string &participant) const
const std::string VALUE_FIRST_PARTICIPANT
const std::string ATTR_DATA
const std::string TAG_ABS_OR_REL_CONV_MEASURE
static const int INFINITE_MAX_ITERATIONS
To be used, when the number of max iterations is infinite (for implicit coupling).
static const double UNDEFINED_MAX_TIME
Does not define a time limit for the coupled simulation.
static const int UNDEFINED_MAX_ITERATIONS
To be used, when the number of max iterations is not defined (for explicit coupling).
static const double UNDEFINED_TIME_WINDOW_SIZE
To be used, when the time window size is determined dynamically during the coupling.
static const int UNDEFINED_TIME_WINDOWS
Does not define limit on time windows for the coupled simulation.
A coupling scheme with multiple participants.
void addDataToSend(const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps, const std::string &to)
Adds data to be sent on data exchange and possibly be modified during coupling iterations.
void determineInitialDataExchange() override
Determines which data is initialized and therefore has to be exchanged during initialize.
void addDataToReceive(const mesh::PtrData &data, mesh::PtrMesh mesh, bool requiresInitialization, bool exchangeSubsteps, const std::string &from)
Adds data to be received on data exchange.
Coupling scheme for parallel coupling, i.e. simultaneous execution of two coupled participants.
Coupling scheme for serial coupling, i.e. staggered execution of two coupled participants.
std::shared_ptr< M2NConfiguration > SharedPointer
Represents an XML tag to be configured automatically.
const std::string & getNamespace() const
Returns xml namespace.
std::string getStringAttributeValue(const std::string &name, std::optional< std::string > default_value=std::nullopt) const
bool getBooleanAttributeValue(const std::string &name, std::optional< bool > default_value=std::nullopt) const
XMLTag & setDocumentation(std::string_view documentation)
Adds a description of the purpose of this XML tag.
const std::string & getName() const
Returns name (without namespace).
const std::string & getFullName() const
Returns full name consisting of xml namespace + ":" + name.
int getIntAttributeValue(const std::string &name, std::optional< int > default_value=std::nullopt) const
double getDoubleAttributeValue(const std::string &name, std::optional< double > default_value=std::nullopt) const
XMLTag & addAttribute(const XMLAttribute< double > &attribute)
Adds a XML attribute by making a copy of the given attribute.
XMLTag & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
vector< double > getData()
std::shared_ptr< ParticipantConfiguration > PtrParticipantConfiguration
@ FIRST_PARTICIPANT_SETS_TIME_WINDOW_SIZE
contains implementations of coupling schemes for coupled simulations.
std::shared_ptr< CouplingScheme > PtrCouplingScheme
contains the logic of the parallel communication between participants.
std::shared_ptr< M2N > PtrM2N
constexpr double NUMERICAL_ZERO_DIFFERENCE
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type greaterEquals(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type greater(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
std::shared_ptr< Mesh > PtrMesh
std::shared_ptr< MeshConfiguration > PtrMeshConfiguration
bool contained(const ELEMENT_T &element, const std::vector< ELEMENT_T > &vec)
Returns true, if given element is in vector, otherwise false.
contains the XML configuration parser.
bool requiresInitialization
impl::PtrConvergenceMeasure measure
Tightly coupled to the parameters of Participant()