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
83 tarch::mpi::Lock lock( _semaphore );
85 logTraceInWith1Argument("touchCellFirstTime(...)", fineGridCell{{SOLVER_NAME}}.{{GETTER}}());
87 int patchIndex = _writer->plotPatch(
88 marker.x()-0.5 * marker.h(),
92 int valuePatchVertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
97 dfor(k,repositories::{{SOLVER_INSTANCE}}.PolyDegree+1) {
98 double* value = fineGridCell{{SOLVER_NAME}}.{{GETTER}}().data();
99 _dataWriter->plotVertex( valuePatchVertexIndex, value+currentDoF );
100 valuePatchVertexIndex++;
104 logTraceOut("touchCellFirstTime(...)");
109 __Template_BeginTraversal =
"""
110 if ({{PLOT_PREDICATE}}) {
111 tarch::mpi::Lock lock( _semaphore );
113 static int counter = -1;
116 std::ostringstream snapshotFileName;
117 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
119 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
120 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
123 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
124 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
125 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
129 double spatialArrangementOfIntegrationPoints[repositories::{{SOLVER_INSTANCE}}.NodesPerCell*Dimensions];
131 dfor(i,repositories::{{SOLVER_INSTANCE}}.PolyDegree+1) {
132 for (int d=0; d<Dimensions; d++) {
133 spatialArrangementOfIntegrationPoints[k] = repositories::{{SOLVER_INSTANCE}}.getIntegrationPoint(i)(d);
135 assertion(k<=repositories::{{SOLVER_INSTANCE}}.NodesPerCell*repositories::{{SOLVER_INSTANCE}}.NodesPerCell*Dimensions);
139 _dataWriter = _writer->createVertexDataWriter(
141 repositories::{{SOLVER_INSTANCE}}.PolyDegree+1, // nodes per axis
142 repositories::{{SOLVER_INSTANCE}}.UnknownsPerCellNode,
143 "Solution of {{SOLVER_NAME}}",
145 spatialArrangementOfIntegrationPoints
148 _dataWriter->setPrecision(16);
155 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
157 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
159 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
166 static tarch::mpi::BooleanSemaphore _semaphore;
170 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
171 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
172 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _rhsWriter;
178#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
179#include "tarch/mpi/Lock.h"
180#include "tarch/mpi/BooleanSemaphore.h"
181#include "tarch/multicore/Lock.h"
182#include "tarch/multicore/BooleanSemaphore.h"
183#include "peano4/utils/Loop.h"
184#include "peano4/parallel/SpacetreeSet.h"
185#include "../repositories/SolverRepository.h"
191tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)