16 NoMetaFile =
"no-meta-file"
17 CountTimeSteps =
"count-time-steps"
23 time_stamp_evaluation,
24 number_of_unknows_per_vertex=1,
25 guard_predicate="true",
26 additional_includes=""
30 Plot grid and assume all data are associated with vertices
33 Name of the output file
35 vertex_unknown: (DaStGen) object tied to a vertex
36 The object you have associated with a vertex and that you want to print.
37 The code will access its name via
39 fineGridVertices{VERTEX_UNKNOWN_NAME}
41 in the generated source code
43 getter: String (C++ code)
44 Getter acting on the vertex. Could be something alike getU() for example.
45 If there's no getter but you want to directly access the data, remove
46 any brackets from the passed string. Please note that Peano's plotter
47 routines usually require plain value (double) pointers. So if a string
52 returns a tarch vector, you have to pass in
56 to make the getter compatible with plotters' interface.
58 time_stamp_evaluation: String
59 C++ expression returning a double. This is used to write the time series
60 file for a series of snapshots. Pass in "0" if you solve a stationary
61 problem, e.g. You can also hand in the constants NoMetaFile or
64 number_of_unknows_per_vertex: Integer
65 Has to match to the getter.
68 super( PlotVertexDataInPeanoBlockFormat, self ).
__init__()
71 self.
d[
"FILENAME" ] = filename
72 self.
d[
"VERTEX_UNKNOWN_NAME" ] = vertex_unknown.name
73 self.
d[
"GETTER" ] = getter
74 self.
d[
"NUMBER_OF_UNKNOWNS_PER_VERTEX" ] = number_of_unknows_per_vertex
75 self.
d[
"DESCRIPTION" ] = description
76 self.
d[
"TIMESTAMP" ] = time_stamp_evaluation
77 self.
d[
"GUARD_PREDICATE" ] = guard_predicate
81 __Template_Constructor =
"""
83 _dataWriter = nullptr;
84 _treeNumber = treeNumber;
86 // An MPI lock (critical section) would be important!
88 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
96 __Template_EndTraversal =
"""
97 assertion(_dataWriter!=nullptr);
98 assertion1(_dataWriter!=nullptr,_treeNumber);
100 _dataWriter->close();
101 _writer->writeToFile();
106 _dataWriter = nullptr;
116 return " return std::vector< peano4::grid::GridControlEvent >();\n"
120 return __name__.replace(
".py",
"").replace(
".",
"_")
127 __Template_TouchCellFirstTime =
"""
128 int vertexIndices[TwoPowerD];
130 int patchIndex = _writer->plotPatch(
131 marker.x()-0.5 * marker.h(),
135 assertion( _dataWriter!=nullptr );
136 int vertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
138 auto data = fineGridVertices{{VERTEX_UNKNOWN_NAME}}(kScalar).{{GETTER}};
139 _dataWriter->plotVertex( vertexIndex, data );
145 __Template_BeginTraversal =
"""
146 tarch::mpi::Lock lock( _semaphore );
148 static int counter = -1;
151 std::ostringstream snapshotFileName;
152 snapshotFileName << "{{FILENAME}}-" << counter;
154 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
155 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
158 {% if TIMESTAMP==\"""" + NoMetaFile +
"""\" %}
159 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
160 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
161 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::NoIndexFile,
164 {% elif TIMESTAMP==\"""" + CountTimeSteps +
"""\" %}
165 static int timeStep = -1;
167 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
168 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
169 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
173 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
174 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
175 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
180 _dataWriter = _writer->createVertexDataWriter(
181 "{{VERTEX_UNKNOWN_NAME}}",
182 2, // number of dofs per axis per cell
183 {{NUMBER_OF_UNKNOWNS_PER_VERTEX}},
191 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
193 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
195 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
201 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
202 return self.
d[
"GUARD_PREDICATE" ]
208 static tarch::mpi::BooleanSemaphore _semaphore;
212 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
213 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
219#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
220#include "tarch/mpi/Lock.h"
221#include "tarch/mpi/BooleanSemaphore.h"
222#include "tarch/multicore/Lock.h"
223#include "tarch/multicore/BooleanSemaphore.h"
224#include "peano4/utils/Loop.h"
225#include "peano4/parallel/SpacetreeSet.h"
231tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)