14 plot_predicate = "true"
21 super( PlotDGDataInPeanoBlockFormat, self ).
__init__()
24 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
25 self.
d[
"SOLVER_NAME"] = solver.typename()
26 self.
d[
"VARIABLE" ] = variable_name
27 self.
d[
"GETTER" ] = getter
28 self.
d[
"PLOT_PREDICATE"] = plot_predicate
30 __Template_Constructor =
"""
32 _dataWriter = nullptr;
33 _treeNumber = treeNumber;
35 // An MPI lock (critical section) would be important!
37 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
45 __Template_EndTraversal =
"""
46 if ( {{PLOT_PREDICATE}} ) {
47 assertion(_dataWriter!=nullptr);
48 assertion1(_dataWriter!=nullptr,_treeNumber);
51 _writer->writeToFile();
56 _dataWriter = nullptr;
66 return " return std::vector< peano4::grid::GridControlEvent >();\n"
70 return __name__.replace(
".py",
"").replace(
".",
"_")
77 Template_TouchCellFirstTime =
"""
79 fineGridCell{{SOLVER_NAME}}.getType() == celldata::{{SOLVER_NAME}}::Type::Interior
84 logTraceInWith1Argument("Plot::touchCellFirstTime", fineGridCell{{SOLVER_NAME}}.{{GETTER}}());
86 int patchIndex = _writer->plotPatch(
87 marker.x()-0.5 * marker.h(),
91 int valuePatchVertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
96 dfor(k,repositories::{{SOLVER_INSTANCE}}.PolyDegree+1) {
97 double* value = fineGridCell{{SOLVER_NAME}}.{{GETTER}}().data();
98 _dataWriter->plotVertex( valuePatchVertexIndex, value+currentDoF );
99 valuePatchVertexIndex++;
105 logTraceOut("Plot::touchCellFirstTime");
109 templateTouchFaceFirstTime=
"""
110 if (fineGridFace{{SOLVER_NAME}}.getType()!=facedata::{{SOLVER_NAME}}::Type::Coarse)
112 logTraceInWith3Arguments("touchFaceFirstTimeOutput", marker.x(), fineGridFace{{SOLVER_NAME}}.getSolution(),fineGridFace{{SOLVER_NAME}}.getProjection());
113 logTraceOut("touchFaceFirstTimeOutput");
117 __Template_BeginTraversal =
"""
118 if ({{PLOT_PREDICATE}}) {
119 tarch::mpi::Lock lock( _semaphore );
121 static int counter = -1;
124 std::ostringstream snapshotFileName;
125 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
127 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
128 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
131 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
132 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
133 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
137 _dataWriter = _writer->createVertexDataWriter(
139 repositories::{{SOLVER_INSTANCE}}.PolyDegree+1, // nodes per axis
140 repositories::{{SOLVER_INSTANCE}}.UnknownsPerCellNode,
142 "Solution as delivered through MF Solver"
145 _dataWriter->setPrecision(16);
152 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
154 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
156 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
158 if operation_name==ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
165 static tarch::mpi::BooleanSemaphore _semaphore;
169 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
170 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
171 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _rhsWriter;
177#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
178#include "tarch/mpi/Lock.h"
179#include "tarch/mpi/BooleanSemaphore.h"
180#include "tarch/multicore/Lock.h"
181#include "tarch/multicore/BooleanSemaphore.h"
182#include "peano4/utils/Loop.h"
183#include "peano4/parallel/SpacetreeSet.h"
184#include "../repositories/SolverRepository.h"
190tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)