14 plot_predicate="true",
19 Plot grid and assume all data are associated with vertices
21 This is a copy of the one in toolbox, but for the time being
22 we hardcode the number of unknowns per vertex that we plot
23 to 1, and we make some important customisations. Particularly
24 regarding the place we plot.
26 \param plot_predicate: string
27 This determines whether we want to plot in this cell. This prevents
28 spurious creation of patch files that we don't want to print.
30 \param cell_predicate: string
31 This determines whether we want to plot in this cell. For instance,
32 we use this flag to prevent plotting on levels that are not the
36 super( PlotVertexDataInPeanoBlockFormat, self ).
__init__()
39 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
40 self.
d[
"SOLVER_NAME"] = solver.typename()
41 self.
d[
"VARIABLE" ] = variable_name
42 self.
d[
"GETTER" ] = getter
43 self.
d[
"PLOT_PREDICATE"] = plot_predicate
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 =
"""
61 if ( {{PLOT_PREDICATE}} ) {
62 assertion(_dataWriter!=nullptr);
63 assertion1(_dataWriter!=nullptr,_treeNumber);
66 _writer->writeToFile();
71 _dataWriter = nullptr;
82 return " return std::vector< peano4::grid::GridControlEvent >();\n"
86 return __name__.replace(
".py",
"").replace(
".",
"_")
93 __Template_TouchCellFirstTime =
"""
95 fineGridCell{{SOLVER_NAME}}.getType() == celldata::{{SOLVER_NAME}}::Type::Interior
99 int vertexIndices[TwoPowerD];
101 int patchIndex = _writer->plotPatch(
102 marker.x()-0.5 * marker.h(),
106 int vertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
107 for (int i=0; i<TwoPowerD; i++) {
108 double* value = fineGridVertices{{SOLVER_NAME}}(i).{{GETTER}}().data();
109 _dataWriter->plotVertex( vertexIndex+i, value );
115 __Template_BeginTraversal =
"""
116 if ({{PLOT_PREDICATE}}) {
117 tarch::mpi::Lock lock( _semaphore );
119 static int counter = -1;
122 std::ostringstream snapshotFileName;
123 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
125 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
126 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
129 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
130 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
131 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
135 _dataWriter = _writer->createVertexDataWriter(
137 2, // number of dofs per axis per cell
138 repositories::{{SOLVER_INSTANCE}}.VertexUnknowns,
140 "Solution as delivered through MF Solver"
142 _dataWriter->setPrecision(16);
149 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
151 if operation_name==ActionSet.OPERATION_BEGIN_TRAVERSAL:
153 if operation_name==ActionSet.OPERATION_END_TRAVERSAL:
160 static tarch::mpi::BooleanSemaphore _semaphore;
164 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
165 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
171#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
172#include "tarch/mpi/Lock.h"
173#include "tarch/mpi/BooleanSemaphore.h"
174#include "tarch/multicore/Lock.h"
175#include "tarch/multicore/BooleanSemaphore.h"
176#include "peano4/utils/Loop.h"
177#include "peano4/parallel/SpacetreeSet.h"
178#include "../repositories/SolverRepository.h"
184tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)