preCICE
Loading...
Searching...
No Matches
ExportConfiguration.cpp
Go to the documentation of this file.
2#include <utility>
5#include "xml/XMLTag.hpp"
6
7namespace precice::io {
8
10{
11 using namespace xml;
12 std::string doc;
13 std::list<XMLTag> tags;
14 XMLTag::Occurrence occ = XMLTag::OCCUR_ARBITRARY;
15 {
16 XMLTag tag(*this, VALUE_VTK, occ, TAG);
17 tag.setDocumentation("Exports meshes to VTK legacy format files. Parallel participants will use the VTU exporter instead.");
18 tags.push_back(tag);
19 }
20 {
21 XMLTag tag(*this, VALUE_VTU, occ, TAG);
22 tag.setDocumentation("Exports meshes to VTU files in serial or PVTU files with VTU piece files in parallel.");
23 tags.push_back(tag);
24 }
25 {
26 XMLTag tag(*this, VALUE_VTP, occ, TAG);
27 tag.setDocumentation("Exports meshes to VTP files in serial or PVTP files with VTP piece files in parallel.");
28 tags.push_back(tag);
29 }
30 {
31 XMLTag tag(*this, VALUE_CSV, occ, TAG);
32 tag.setDocumentation("Exports vertex coordinates and data to CSV files.");
33 tags.push_back(tag);
34 }
35
36 auto attrMesh = XMLAttribute<std::string>(ATTR_MESH, "")
37 .setDocumentation("Name of the mesh to export, or empty to export all meshes of the participant.");
38
39 auto attrLocation = XMLAttribute<std::string>(ATTR_LOCATION, ".")
40 .setDocumentation("Directory to export the files to.");
41
42 auto attrEveryNTimeWindows = makeXMLAttribute(ATTR_EVERY_N_TIME_WINDOWS, 1)
43 .setDocumentation("preCICE does an export every X time windows. Choose -1 for no exports.");
44
45 auto attrEveryIteration = makeXMLAttribute(ATTR_EVERY_ITERATION, false)
46 .setDocumentation("Exports in every coupling (sub)iteration. For debug purposes.");
47
48 auto attrUpdateSeries = makeXMLAttribute(ATTR_UPDATE_SERIES, false)
49 .setDocumentation("Update the series file after every export instead of at the end of the simulation.");
50
51 for (XMLTag &tag : tags) {
52 tag.addAttribute(attrMesh);
53 tag.addAttribute(attrLocation);
54 tag.addAttribute(attrEveryNTimeWindows);
55 tag.addAttribute(attrEveryIteration);
56 tag.addAttribute(attrUpdateSeries);
57 parent.addSubtag(tag);
58 }
59}
60
62 const xml::ConfigurationContext &context,
63 xml::XMLTag &tag)
64{
65 if (tag.getNamespace() == TAG) {
67 config.configuredMeshName = tag.getStringAttributeValue(ATTR_MESH);
71 config.type = tag.getName();
73 _contexts.push_back(std::move(config));
74 }
75}
76
77} // namespace precice::io
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback at begin of XML tag.
std::list< ConfiguredExport > _contexts
Represents an XML tag to be configured automatically.
Definition XMLTag.hpp:28
const std::string & getNamespace() const
Returns xml namespace.
Definition XMLTag.hpp:159
std::string getStringAttributeValue(const std::string &name, std::optional< std::string > default_value=std::nullopt) const
Definition XMLTag.cpp:145
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
int getIntAttributeValue(const std::string &name, std::optional< int > default_value=std::nullopt) const
Definition XMLTag.cpp:131
XMLTag & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
Definition XMLTag.cpp:41
provides Import and Export of the coupling mesh and data.
contains the XML configuration parser.
Tightly coupled to the parameters of Participant().
Definition XMLTag.hpp:21