42 tagSourceData.setDocumentation(
"Single data to read from. ");
43 XMLTag tagMultipleSourceData(*
this,
TAG_SOURCE_DATA, XMLTag::OCCUR_ONCE_OR_MORE);
44 tagMultipleSourceData.setDocumentation(
"Multiple data to read from.");
46 tagTargetData.setDocumentation(
"Data to read from and write to.");
48 auto attrName = XMLAttribute<std::string>(
ATTR_NAME).setDocumentation(
"Name of the data.");
49 tagSourceData.addAttribute(attrName);
50 tagMultipleSourceData.addAttribute(attrName);
51 tagTargetData.addAttribute(attrName);
54 XMLTag::Occurrence occ = XMLTag::OCCUR_ARBITRARY;
57 tag.setDocumentation(
"Multiplies data values with mesh area associated to vertex holding the value.");
58 tag.addSubtag(tagTargetData);
63 tag.setDocumentation(
"Divides data values by mesh area associated to vertex holding the value.");
64 tag.addSubtag(tagTargetData);
69 tag.setDocumentation(
"Sums up multiple source data values and writes the result into target data.");
70 tag.addSubtag(tagMultipleSourceData);
71 tag.addSubtag(tagTargetData);
76 tag.setDocumentation(
"Records action invocations for testing purposes.");
81 tag.setDocumentation(
"Calls Python script to execute action."
82 " See preCICE file \"src/action/PythonAction.py\" for an example.");
84 XMLTag tagModulePath(*
this,
TAG_MODULE_PATH, XMLTag::OCCUR_NOT_OR_ONCE);
85 tagModulePath.setDocumentation(
"Directory path to Python module, i.e. script file."
86 " If it doesn't occur, the current path is used");
87 tagModulePath.addAttribute(makeXMLAttribute(
ATTR_NAME,
"").setDocumentation(
"The path to the directory of the module."));
88 tag.addSubtag(tagModulePath);
91 tagModule.setDocumentation(
"Name of Python module, i.e. Python script file without file ending. "
92 "The module name has to differ from existing (library) modules, "
93 "otherwise, the existing module will be loaded instead of the user script.");
94 tagModule.addAttribute(attrName);
95 tag.addSubtag(tagModule);
97 XMLTag tagOptionalSourceData(*
this,
TAG_SOURCE_DATA, XMLTag::OCCUR_NOT_OR_ONCE);
98 tagOptionalSourceData.setDocumentation(
"Source data to be read is handed to the Python module."
99 " Can be omitted, if only a target data is needed.");
100 tagOptionalSourceData.addAttribute(attrName);
101 tag.addSubtag(tagOptionalSourceData);
103 XMLTag tagOptionalTargetData(*
this,
TAG_TARGET_DATA, XMLTag::OCCUR_NOT_OR_ONCE);
104 tagOptionalTargetData.setDocumentation(
"Target data to be read and written to is handed to the Python module."
105 " Can be omitted, if only source data is needed.");
106 tagOptionalTargetData.addAttribute(attrName);
107 tag.addSubtag(tagOptionalTargetData);
112 auto attrTiming = XMLAttribute<std::string>(
ATTR_TIMING)
113 .setDocumentation(
"Determines when (relative to advancing the coupling scheme and the data mappings) the action is executed.")
116 auto attrMesh = XMLAttribute<std::string>(
ATTR_MESH)
117 .setDocumentation(
"Determines mesh used in action.");
118 for (XMLTag &tag : tags) {
119 tag.addAttribute(attrTiming);
120 tag.addAttribute(attrMesh);
176 int targetDataID = -1;
178 "Data action uses mesh \"{}\" which is not configured. Please ensure that the correct mesh name is given in <action:python mesh=\"...\">",
_configuredAction.mesh);
183 "Data action uses target data \"{}\" which is not configured. Please ensure that the target data name is used by the mesh with name \"{}\".",
_configuredAction.targetData,
_configuredAction.mesh);
189 PRECICE_CHECK(
mesh->hasDataName(dataName),
"Data action uses source data \"{}\" which is not configured. Please ensure that the target data name is used by the mesh with name \"{}\".", dataName,
_configuredAction.mesh);
194 "Data action uses source data \"{}\" which is not configured. Please ensure that the source data name is used by the mesh with name \"{}\".",
_configuredAction.sourceDataVector.back(),
_configuredAction.mesh);
212#ifndef PRECICE_NO_PYTHON
216 mesh, targetDataID, sourceDataIDs.
back()));
233 "Valid action timings are read-mapping-post and write-mapping-post.",
#define PRECICE_ERROR(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
mesh::PtrMeshConfiguration _meshConfig
const std::string ATTR_NAME
Action::Timing getTiming() const
const std::string NAME_MULTIPLY_BY_AREA
const std::string TAG_MODULE_NAME
const std::string WRITE_MAPPING_POST
const std::string ATTR_VALUE
const std::string ATTR_TIMING
const std::string ATTR_MESH
ConfiguredAction _configuredAction
const std::string READ_MAPPING_POST
void createAction()
Adds all required subtags to the main action tag.
const std::string NAME_DIVIDE_BY_AREA
const std::string NAME_SUMMATION
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback function required for use of automatic configuration.
const std::string TAG_TARGET_DATA
std::list< PtrAction > _actions
const std::string TAG_MAX_ITERATIONS
const std::string TAG_MODULE_PATH
const std::string NAME_PYTHON
const std::string TAG_SOURCE_DATA
const std::string TAG_CONVERGENCE_TOLERANCE
ActionConfiguration(xml::XMLTag &parent, mesh::PtrMeshConfiguration meshConfig)
const std::string NAME_RECORDER
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback function required for use of automatic configuration.
int getUsedMeshID() const
Returns the id of the mesh used in the data action.
Timing
Defines the time and place of application of the action.
Action whose implementation is given in a Python file.
Action that records invocations for testing purposes.
@ SCALING_MULTIPLY_BY_AREA
Multiplies the data by the area of neighboring edges/triangles.
@ SCALING_DIVIDE_BY_AREA
Divides the data by the area of neighboring edges/triangles.
Action that adds multiple source data into target data.
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.
contains actions to modify exchanged data.
std::unique_ptr< Action > PtrAction
provides Mesh, Data and primitives.
std::shared_ptr< Mesh > PtrMesh
std::shared_ptr< MeshConfiguration > PtrMeshConfiguration
contains the XML configuration parser.
Tightly coupled to the parameters of Participant()