10 NoMetaFile =
"no-meta-file"
11 CountTimeSteps =
"count-time-steps"
13 def __init__(self, filename, cell_unknown=None, time_stamp_evaluation=NoMetaFile, guard_predicate="true", additional_includes=""):
15 Plot only the grid structure
20 Name of the output file.
22 cell_unknown: None or cell data
23 If you use cell unknowns, pass any unknown in. As we do not dump
24 any semantic information about unknowns, it does not matter which
25 one you choose. If you don't have cell unknowns at all, pass in
28 time_stamp_evaluation: String
29 C++ expression returning a double. You can also hand in NoMetaFile
33 super( PlotGridInPeanoBlockFormat, self ).
__init__()
36 self.
d[
"FILENAME" ] = filename
37 self.
d[
"CELL_WRAPPER" ] =
"Cell"
38 if cell_unknown!=
None:
39 self.
d[
"CELL_WRAPPER" ] += cell_unknown.name
40 self.
d[
"GUARD_PREDICATE" ] = guard_predicate
42 self.
d[
"TIMESTAMP" ] = time_stamp_evaluation
45 __Template_Constructor =
"""
47 _dataWriter = nullptr;
48 _treeNumber = treeNumber;
50 // An MPI lock (critical section) would be important!
52 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
60 __Template_EndTraversal = jinja2.Template(
"""
61 assertion1(_dataWriter!=nullptr,_treeNumber);
64 _writer->writeToFile();
69 _dataWriter = nullptr;
79 return " return std::vector< peano4::grid::GridControlEvent >();\n"
83 return __name__.replace(
".py",
"").replace(
".",
"_")
90 __Template_TouchCellFirstTime = jinja2.Template(
"""
91 if ( {{GUARD_PREDICATE}} ) {
92 int vertexIndices[TwoPowerD];
94 int indices = _writer->plotPatch(
95 marker.x() - marker.h() * 0.5,
99 assertion( _dataWriter!=nullptr );
101 double markerData[] = {
102 marker.hasBeenRefined() ? 1.0 : 0.0,
103 marker.willBeRefined() ? 1.0 : 0.0,
104 marker.isLocal() ? 1.0 : 0.0,
105 marker.hasBeenEnclaveCell() ? 1.0 : 0.0,
106 marker.willBeEnclaveCell() ? 1.0 : 0.0
108 _dataWriter->plotCell(indices,markerData);
113 __Template_BeginTraversal = jinja2.Template(
"""
114 tarch::mpi::Lock lock( _semaphore );
116 static int counter = -1;
119 std::ostringstream snapshotFileName;
120 snapshotFileName << "{{FILENAME}}-" << counter;
122 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
123 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
126 {% if TIMESTAMP==\"""" + NoMetaFile +
"""\" %}
127 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
128 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
129 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::NoIndexFile,
132 {% elif TIMESTAMP==\"""" + CountTimeSteps +
"""\" %}
133 static int timeStep = -1;
135 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
136 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
137 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
141 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
142 Dimensions, snapshotFileName.str(), "{{FILENAME}}",
143 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
148 _dataWriter = _writer->createCellDataWriter( "cell-marker", 1, 5, "is-refined,has-been-refined,local,enclave" );
154 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
156 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
158 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
165 static tarch::mpi::BooleanSemaphore _semaphore;
169 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
170 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::CellDataWriter* _dataWriter;
176#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
177#include "tarch/multicore/Lock.h"
178#include "tarch/multicore/BooleanSemaphore.h"
179#include "tarch/mpi/Lock.h"
180#include "tarch/mpi/BooleanSemaphore.h"
181#include "peano4/parallel/SpacetreeSet.h"
187tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)