preCICE v3.2.0
Loading...
Searching...
No Matches
Configuration.cpp
Go to the documentation of this file.
1#include "Configuration.hpp"
2#include <map>
3#include <memory>
4#include <ostream>
5#include <vector>
10#include "math/differences.hpp"
11#include "mesh/Mesh.hpp"
18#include "utils/assertion.hpp"
19#include "xml/ConfigParser.hpp"
20#include "xml/XMLAttribute.hpp"
21
22namespace precice::config {
23
25 : _tag(*this, "precice-configuration", xml::XMLTag::OCCUR_ONCE),
26 _logConfig(_tag), // This must be the first configuration to be constructed
28{
29 _tag.setDocumentation("Main tag containing preCICE configuration.");
30 _tag.addNamespace("data");
31 _tag.addNamespace("communication");
32 _tag.addNamespace("mapping");
33 _tag.addNamespace("export");
34 _tag.addNamespace("action");
35 _tag.addNamespace("coupling-scheme");
36 _tag.addNamespace("acceleration");
37
38 auto attrExperimental = xml::makeXMLAttribute("experimental", false)
39 .setDocumentation("Enable experimental features.");
40 _tag.addAttribute(attrExperimental);
41
42 auto attrRemeshing = xml::makeXMLAttribute("allow-remeshing", false)
43 .setDocumentation("Enable experimental remeshing feature, requires experimental to be true.");
44 _tag.addAttribute(attrRemeshing);
45
46 auto attrWaitInFinalize = xml::makeXMLAttribute("wait-in-finalize", false)
47 .setDocumentation("Connected participants wait for each other in finalize, which can be helpful in SLURM sessions.");
48 _tag.addAttribute(attrWaitInFinalize);
50 _tag);
54 _tag);
59}
60
65
67{
69 if (tag.getName() == "precice-configuration") {
70 _experimental = tag.getBooleanAttributeValue("experimental");
71 _remeshing = tag.getBooleanAttributeValue("allow-remeshing");
72
73 PRECICE_CHECK(!_remeshing || _experimental, "Remeshing is considered an experimental feature. Please enable <precice-configuration experimental=\"1\" >.");
77 _waitInFinalize = tag.getBooleanAttributeValue("wait-in-finalize");
78 } else {
79 PRECICE_UNREACHABLE("Received callback from unknown tag '{}'.", tag.getName());
80 }
81}
82
84 const xml::ConfigurationContext &context,
85 xml::XMLTag &tag)
86{
88 PRECICE_ASSERT(tag.getName() == "precice-configuration");
89
90 // test if both participants do have the exchange meshes
91 typedef std::map<std::string, std::vector<std::string>>::value_type neededMeshPair;
92 for (const neededMeshPair &neededMeshes : _meshConfiguration->getNeededMeshes()) {
93 bool participantFound = false;
94 for (const impl::PtrParticipant &participant : _participantConfiguration->getParticipants()) {
95 if (participant->getName() == neededMeshes.first) {
96 for (const std::string &neededMesh : neededMeshes.second) {
97 PRECICE_CHECK(participant->isMeshUsed(neededMesh),
98 "Participant \"{}\" needs to use the mesh \"{}\" to be able to use it in the coupling scheme. "
99 "Please either add a provide-mesh or a receive-mesh tag in this participant's configuration, or use a different mesh in the coupling scheme.",
100 neededMeshes.first, neededMesh);
101 }
102 participantFound = true;
103 break;
104 }
105 }
106 PRECICE_ASSERT(participantFound);
107 }
108
109 // test if all M2Ns use participants that exist
110 for (const auto &m2n : _m2nConfiguration->m2ns()) {
111 PRECICE_CHECK(_participantConfiguration->hasParticipant(m2n.acceptor),
112 "The acceptor in <m2n:... acceptor=\"{}\" connector=\"{}\" /> is an unknown. {}",
113 m2n.acceptor, m2n.connector, _participantConfiguration->hintFor(m2n.acceptor));
114
115 PRECICE_CHECK(_participantConfiguration->hasParticipant(m2n.connector),
116 "The connector in <m2n:... acceptor=\"{}\" connector=\"{}\" /> is an unknown. {}",
117 m2n.acceptor, m2n.connector, _participantConfiguration->hintFor(m2n.connector));
118 }
119}
120
126
127} // namespace precice::config
#define PRECICE_TRACE(...)
Definition LogMacros.hpp:92
#define PRECICE_CHECK(check,...)
Definition LogMacros.hpp:32
#define PRECICE_ASSERT(...)
Definition assertion.hpp:85
#define PRECICE_UNREACHABLE(...)
Definition assertion.hpp:93
const PtrParticipantConfiguration & getParticipantConfiguration() const
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &tag) override
Callback function required for use of automatic configuration.
mesh::PtrMeshConfiguration _meshConfiguration
logging::LogConfiguration _logConfig
bool _remeshing
Allow the use of experimental remeshing features.
precice::profiling::ProfilingConfiguration _profilingConfig
bool _experimental
Allow the use of experimental features.
m2n::M2NConfiguration::SharedPointer _m2nConfiguration
PtrParticipantConfiguration _participantConfiguration
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &tag) override
Callback function required for use of automatic configuration.
xml::XMLTag & getXMLTag()
Returns root xml tag to start the automatic configuration process.
bool _waitInFinalize
Synchronize participants in finalize.
cplscheme::PtrCouplingSchemeConfiguration _couplingSchemeConfiguration
mesh::PtrDataConfiguration _dataConfiguration
Represents an XML tag to be configured automatically.
Definition XMLTag.hpp:28
bool getBooleanAttributeValue(const std::string &name, std::optional< bool > default_value=std::nullopt) const
Definition XMLTag.cpp:159
const std::string & getName() const
Returns name (without namespace).
Definition XMLTag.hpp:153
T make_shared(T... args)
std::shared_ptr< ParticipantConfiguration > PtrParticipantConfiguration
std::shared_ptr< ParticipantState > PtrParticipant
contains the logic of the parallel communication between participants.
Definition BoundM2N.cpp:12
contains the XML configuration parser.
XMLAttribute< std::string > makeXMLAttribute(std::string name, const char *defaultValue)
Tightly coupled to the parameters of Participant()
Definition XMLTag.hpp:21