14 plot_predicate = "true"
21 super( PlotDGPatchesInPeanoBlockFormat, self ).
__init__()
24 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
25 self.
d[
"SOLVER_NAME"] = solver.typename()
26 self.
d[
"GETTER" ] = getter
27 self.
d[
"VARIABLE" ] = variable
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
83 tarch::mpi::Lock lock( _semaphore );
85 int patchIndex = _writer->plotPatch(
86 marker.x()-0.5 * marker.h(),
90 int valuePatchVertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
95 dfor(k,repositories::{{SOLVER_INSTANCE}}.PolyDegree+1) {
96 double* value = fineGridCell{{GETTER}}().data();
97 _dataWriter->plotVertex( valuePatchVertexIndex, value+currentDoF );
98 valuePatchVertexIndex++;
105 __Template_BeginTraversal =
"""
106 if ({{PLOT_PREDICATE}}) {
107 tarch::mpi::Lock lock( _semaphore );
109 static int counter = -1;
112 std::ostringstream snapshotFileName;
113 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
115 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
116 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
119 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
120 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
121 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
125 _dataWriter = _writer->createVertexDataWriter(
127 repositories::{{SOLVER_INSTANCE}}.PolyDegree+1, // nodes per axis
128 repositories::{{SOLVER_INSTANCE}}.UnknownsPerCellNode,
130 "Solution as delivered through MF Solver"
133 _dataWriter->setPrecision(16);
140 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
142 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
144 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
151 static tarch::mpi::BooleanSemaphore _semaphore;
155 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
156 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
157 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _rhsWriter;
163#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
164#include "tarch/mpi/Lock.h"
165#include "tarch/mpi/BooleanSemaphore.h"
166#include "tarch/multicore/Lock.h"
167#include "tarch/multicore/BooleanSemaphore.h"
168#include "peano4/utils/Loop.h"
169#include "peano4/parallel/SpacetreeSet.h"
170#include "../repositories/SolverRepository.h"
176tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)