9 NoMetaFile =
"no-meta-file"
10 CountTimeSteps =
"count-time-steps"
16 time_stamp_evaluation,
17 number_of_unknows_per_vertex=1,
18 guard_predicate="true",
19 additional_includes=""
23 Plot grid and assume all data are associated with vertices
26 Name of the output file
28 vertex_unknown: (DaStGen) object tied to a vertex
29 The object you have associated with a vertex and that you want to print.
30 The code will access its name via
32 fineGridVertices{VERTEX_UNKNOWN_NAME}
34 in the generated source code
36 getter: String (C++ code)
37 Getter acting on the vertex. Could be something alike getU() for example.
38 If there's no getter but you want to directly access the data, remove
39 any brackets from the passed string. Please note that Peano's plotter
40 routines usually require plain value (double) pointers. So if a string
45 returns a tarch vector, you have to pass in
49 to make the getter compatible with plotters' interface.
51 time_stamp_evaluation: String
52 C++ expression returning a double. This is used to write the time series
53 file for a series of snapshots. Pass in "0" if you solve a stationary
54 problem, e.g. You can also hand in the constants NoMetaFile or
57 number_of_unknows_per_vertex: Integer
58 Has to match to the getter.
61 super( PlotVertexDataInPeanoBlockFormat, self ).
__init__()
64 self.
d[
"FILENAME" ] = filename
65 self.
d[
"VERTEX_UNKNOWN_NAME" ] = vertex_unknown.name
66 self.
d[
"GETTER" ] = getter
67 self.
d[
"NUMBER_OF_UNKNOWNS_PER_VERTEX" ] = number_of_unknows_per_vertex
68 self.
d[
"DESCRIPTION" ] = description
69 self.
d[
"TIMESTAMP" ] = time_stamp_evaluation
70 self.
d[
"GUARD_PREDICATE" ] = guard_predicate
74 __Template_Constructor =
"""
76 _dataWriter = nullptr;
77 _treeNumber = treeNumber;
79 // An MPI lock (critical section) would be important!
81 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
89 __Template_EndTraversal =
"""
90 assertion(_dataWriter!=nullptr);
91 assertion1(_dataWriter!=nullptr,_treeNumber);
94 _writer->writeToFile();
99 _dataWriter = nullptr;
109 return " return std::vector< peano4::grid::GridControlEvent >();\n"
113 return __name__.replace(
".py",
"").replace(
".",
"_")
120 __Template_TouchCellFirstTime =
"""
121if ( {{GUARD_PREDICATE}} ) {
122 int vertexIndices[TwoPowerD];
124 int patchIndex = _writer->plotPatch(
125 marker.x()-0.5 * marker.h(),
129 assertion( _dataWriter!=nullptr );
130 int vertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
132 auto data = fineGridVertices{{VERTEX_UNKNOWN_NAME}}(kScalar).{{GETTER}};
133 _dataWriter->plotVertex( vertexIndex, data );
140 __Template_BeginTraversal =
"""
141 tarch::mpi::Lock lock( _semaphore );
143 static int counter = -1;
146 std::ostringstream snapshotFileName;
147 snapshotFileName << "{{FILENAME}}-" << counter;
149 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
150 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
153 {% if TIMESTAMP==\"""" + NoMetaFile +
"""\" %}
154 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
155 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
156 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::NoIndexFile,
159 {% elif TIMESTAMP==\"""" + CountTimeSteps +
"""\" %}
160 static int timeStep = -1;
162 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
163 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
164 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
168 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
169 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
170 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
175 _dataWriter = _writer->createVertexDataWriter(
176 "{{VERTEX_UNKNOWN_NAME}}",
177 2, // number of dofs per axis per cell
178 {{NUMBER_OF_UNKNOWNS_PER_VERTEX}},
186 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
188 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
190 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
197 static tarch::mpi::BooleanSemaphore _semaphore;
201 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
202 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
208#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
209#include "tarch/mpi/Lock.h"
210#include "tarch/mpi/BooleanSemaphore.h"
211#include "tarch/multicore/Lock.h"
212#include "tarch/multicore/BooleanSemaphore.h"
213#include "peano4/utils/Loop.h"
214#include "peano4/parallel/SpacetreeSet.h"
220tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)