17 NoMetaFile =
"no-meta-file"
18 CountTimeSteps =
"count-time-steps"
20 def __init__(self, filename, cell_unknown=None, time_stamp_evaluation=NoMetaFile, guard_predicate="true", additional_includes=""):
22 Plot only the grid structure
27 Name of the output file.
29 cell_unknown: None or cell data
30 If you use cell unknowns, pass any unknown in. As we do not dump
31 any semantic information about unknowns, it does not matter which
32 one you choose. If you don't have cell unknowns at all, pass in
35 time_stamp_evaluation: String
36 C++ expression returning a double. You can also hand in NoMetaFile
40 super( PlotGridInPeanoBlockFormat, self ).
__init__()
43 self.
d[
"FILENAME" ] = filename
44 self.
d[
"CELL_WRAPPER" ] =
"Cell"
45 if cell_unknown!=
None:
46 self.
d[
"CELL_WRAPPER" ] += cell_unknown.name
47 self.
d[
"GUARD_PREDICATE" ] = guard_predicate
49 self.
d[
"TIMESTAMP" ] = time_stamp_evaluation
52 __Template_Constructor =
"""
54 _dataWriter = nullptr;
55 _treeNumber = treeNumber;
57 // An MPI lock (critical section) would be important!
59 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
67 __Template_EndTraversal = jinja2.Template(
"""
68 assertion1(_dataWriter!=nullptr,_treeNumber);
71 _writer->writeToFile();
76 _dataWriter = nullptr;
86 return " return std::vector< peano4::grid::GridControlEvent >();\n"
90 return __name__.replace(
".py",
"").replace(
".",
"_")
97 __Template_TouchCellFirstTime = jinja2.Template(
"""
98 int vertexIndices[TwoPowerD];
100 int indices = _writer->plotPatch(
101 marker.x() - marker.h() * 0.5,
105 assertion( _dataWriter!=nullptr );
107 double markerData[] = {
108 marker.hasBeenRefined() ? 1.0 : 0.0,
109 marker.willBeRefined() ? 1.0 : 0.0,
110 marker.isLocal() ? 1.0 : 0.0,
111 marker.hasBeenEnclaveCell() ? 1.0 : 0.0,
112 marker.willBeEnclaveCell() ? 1.0 : 0.0
114 _dataWriter->plotCell(indices,markerData);
118 __Template_BeginTraversal = jinja2.Template(
"""
119 tarch::mpi::Lock lock( _semaphore );
121 static int counter = -1;
124 std::ostringstream snapshotFileName;
125 snapshotFileName << "{{FILENAME}}-" << counter;
127 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
128 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
131 {% if TIMESTAMP==\"""" + NoMetaFile +
"""\" %}
132 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
133 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
134 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::NoIndexFile,
137 {% elif TIMESTAMP==\"""" + CountTimeSteps +
"""\" %}
138 static int timeStep = -1;
140 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
141 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
142 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
146 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
147 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
148 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
153 _dataWriter = _writer->createCellDataWriter( "cell-marker", 1, 5, "is-refined,has-been-refined,local,enclave" );
159 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
161 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
163 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
169 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
170 return self.
d[
"GUARD_PREDICATE" ]
176 static tarch::mpi::BooleanSemaphore _semaphore;
180 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
181 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter* _dataWriter;
187#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
188#include "tarch/multicore/Lock.h"
189#include "tarch/multicore/BooleanSemaphore.h"
190#include "tarch/mpi/Lock.h"
191#include "tarch/mpi/BooleanSemaphore.h"
192#include "peano4/parallel/SpacetreeSet.h"
198tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)