14 auto attrName = XMLAttribute<std::string>(
ATTR_NAME)
15 .setDocumentation(
"Unique name for the data set.");
18 attrDegree.setDocumentation(
"Polynomial degree of waveform that is used for time interpolation.");
21 tagScalar.setDocumentation(
"Defines a scalar data set to be assigned to meshes. Lower and upper bound of the data can be specified to prevent acceleration methods of IQN family violating the physical value range.");
22 tagScalar.addAttribute(attrName);
23 tagScalar.addAttribute(attrDegree);
25 .setDefaultValue(-std::numeric_limits<double>::infinity())
26 .setDocumentation(
"Lower bound for the scalar data. Example is 0 for temperature in Kelvin.");
27 tagScalar.addAttribute(attrLowerBound);
30 .setDefaultValue(std::numeric_limits<double>::infinity())
31 .setDocumentation(
"Upper bound for the scalar data. Example is 1 for volumetric phase fraction");
32 tagScalar.addAttribute(attrUpperBound);
36 tagVector.setDocumentation(
"Defines a vector data set to be assigned to meshes. The number of "
37 "components of each data entry depends on the spatial dimensions of the mesh."
38 "Lower and upper bound for each component can be specified to prevent acceleration methods of IQN family violating the physical value range.");
39 tagVector.addAttribute(attrName);
40 tagVector.addAttribute(attrDegree);
42 .setDefaultValue(-std::numeric_limits<double>::infinity())
43 .setDocumentation(
"Lower bound for the x-component of the vector data.");
44 tagVector.addAttribute(attrLowerBoundX);
47 .setDefaultValue(-std::numeric_limits<double>::infinity())
48 .setDocumentation(
"Lower bound for the y-component of the vector data.");
49 tagVector.addAttribute(attrLowerBoundY);
52 .setDefaultValue(-std::numeric_limits<double>::infinity())
53 .setDocumentation(
"Lower bound for the z-component of the vector data.");
54 tagVector.addAttribute(attrLowerBoundZ);
57 .setDefaultValue(std::numeric_limits<double>::infinity())
58 .setDocumentation(
"Upper bound for the x-component of the vector data.");
59 tagVector.addAttribute(attrUpperBoundX);
62 .setDefaultValue(std::numeric_limits<double>::infinity())
63 .setDocumentation(
"Upper bound for the y-component of the vector data.");
64 tagVector.addAttribute(attrUpperBoundY);
67 .setDefaultValue(std::numeric_limits<double>::infinity())
68 .setDocumentation(
"Upper bound for the z-component of the vector data.");
69 tagVector.addAttribute(attrUpperBoundZ);
73const std::vector<DataConfiguration::ConfiguredData> &
95 if (tag.
getName() ==
"scalar") {
97 }
else if (tag.
getName() ==
"vector") {
100 PRECICE_ERROR(
"You configured data with name=\"{}\" to be of type \"{}\", but this type is unknown. Known types are \"scalar\" and \"vector\".", name, tag.
getName());
105 "You tried to configure the data with name \"{}\" to use the waveform-degree=\"{}\", but the degree must be at least \"{}\".", name, waveformDegree,
time::Time::MIN_WAVEFORM_DEGREE);
106 if (tag.
getName() ==
"scalar") {
110 std::vector<std::optional<double>> lowerBoundVec(1);
111 std::vector<std::optional<double>> upperBoundVec(1);
113 std::isfinite(lowerBound) ? lowerBoundVec[0] = lowerBound : lowerBoundVec[0] = std::nullopt;
114 std::isfinite(upperBound) ? upperBoundVec[0] = upperBound : upperBoundVec[0] = std::nullopt;
117 "You tried to configure the data with name \"{}\" to have a lower-bound=\"{}\" that is larger than the upper-bound=\"{}\".",
118 name, lowerBound, upperBound);
119 addData(name, typeName, waveformDegree, lowerBoundVec, upperBoundVec);
120 }
else if (tag.
getName() ==
"vector") {
128 std::vector<std::optional<double>> lowerBoundVec(3);
129 std::vector<std::optional<double>> upperBoundVec(3);
131 std::isfinite(lowerBoundX) ? lowerBoundVec[0] = lowerBoundX : lowerBoundVec[0] = std::nullopt;
132 std::isfinite(lowerBoundY) ? lowerBoundVec[1] = lowerBoundY : lowerBoundVec[1] = std::nullopt;
133 std::isfinite(lowerBoundZ) ? lowerBoundVec[2] = lowerBoundZ : lowerBoundVec[2] = std::nullopt;
134 std::isfinite(upperBoundX) ? upperBoundVec[0] = upperBoundX : upperBoundVec[0] = std::nullopt;
135 std::isfinite(upperBoundY) ? upperBoundVec[1] = upperBoundY : upperBoundVec[1] = std::nullopt;
136 std::isfinite(upperBoundZ) ? upperBoundVec[2] = upperBoundZ : upperBoundVec[2] = std::nullopt;
138 if (lowerBoundVec[0].has_value() && upperBoundVec[0].has_value()) {
139 PRECICE_CHECK(lowerBoundVec[0].value() <= upperBoundVec[0].value(),
140 "You tried to configure the data with name \"{}\" to have a lower-bound-x=\"{}\" that is larger than the upper-bound-x=\"{}\".",
141 name, lowerBoundVec[0].value(), upperBoundVec[0].value());
143 if (lowerBoundVec[1].has_value() && upperBoundVec[1].has_value()) {
144 PRECICE_CHECK(lowerBoundVec[1].value() <= upperBoundVec[1].value(),
145 "You tried to configure the data with name \"{}\" to have a lower-bound-y=\"{}\" that is larger than the upper-bound-y=\"{}\".",
146 name, lowerBoundVec[1].value(), upperBoundVec[1].value());
148 if (lowerBoundVec[2].has_value() && upperBoundVec[2].has_value()) {
149 PRECICE_CHECK(lowerBoundVec[2].value() <= upperBoundVec[2].value(),
150 "You tried to configure the data with name \"{}\" to have a lower-bound-z=\"{}\" that is larger than the upper-bound-z=\"{}\".",
151 name, lowerBoundVec[2].value(), upperBoundVec[2].value());
154 addData(name, typeName, waveformDegree, lowerBoundVec, upperBoundVec);
168 const std::string &name,
171 std::vector<std::optional<double>> lowerBound,
172 std::vector<std::optional<double>> upperBound)
175 for (
auto &elem :
_data) {
177 "Data \"{0}\" has already been defined. Please rename or remove one of the data tags with name=\"{0}\".",
180 _data.emplace_back(name, typeName, waveformDegree, lowerBound, upperBound);
#define PRECICE_ERROR(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
const std::string ATTR_LOWER_BOUND
const std::string ATTR_UPPER_BOUND
const std::string ATTR_DEGREE
const std::string ATTR_UPPER_BOUND_X
const std::string VALUE_SCALAR
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback at begin of XML tag.
DataConfiguration(xml::XMLTag &parent)
const std::string ATTR_LOWER_BOUND_Y
void addData(const std::string &name, const Data::typeName typeName, int waveformDegree=time::Time::DEFAULT_WAVEFORM_DEGREE, std::vector< std::optional< double > > lowerBound=std::vector< std::optional< double > >(3), std::vector< std::optional< double > > upperBound=std::vector< std::optional< double > >(3))
Adds data manually.
const std::string ATTR_LOWER_BOUND_Z
ConfiguredData getRecentlyConfiguredData() const
const std::vector< ConfiguredData > & data() const
const std::string ATTR_NAME
const std::string ATTR_UPPER_BOUND_Y
const std::string ATTR_UPPER_BOUND_Z
std::vector< ConfiguredData > _data
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback at end of XML tag and at end of subtag.
const std::string ATTR_LOWER_BOUND_X
const std::string VALUE_VECTOR
static const int DEFAULT_WAVEFORM_DEGREE
To be used, when the interpolation degree is not defined.
static const int MIN_WAVEFORM_DEGREE
The minimum required interpolation degree.
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
const std::string & getName() const
Returns name (without namespace).
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 & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
provides Mesh, Data and primitives.
contains the XML configuration parser.
Tightly coupled to the parameters of Participant()