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
44 self.
d[
"CELL_PREDICATE"] = cell_predicate
46 __Template_Constructor =
"""
48 _dataWriter = nullptr;
49 _treeNumber = treeNumber;
51 // An MPI lock (critical section) would be important!
53 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
61 __Template_EndTraversal =
"""
62 if ( {{PLOT_PREDICATE}} ) {
63 assertion(_dataWriter!=nullptr);
64 assertion1(_dataWriter!=nullptr,_treeNumber);
67 _writer->writeToFile();
72 _dataWriter = nullptr;
83 return " return std::vector< peano4::grid::GridControlEvent >();\n"
87 return __name__.replace(
".py",
"").replace(
".",
"_")
94 __Template_TouchCellFirstTime =
"""
96 fineGridCell{{SOLVER_NAME}}.getType() == celldata::{{SOLVER_NAME}}::Type::Interior
102 int vertexIndices[TwoPowerD];
104 int patchIndex = _writer->plotPatch(
105 marker.x()-0.5 * marker.h(),
109 int vertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
110 for (int i=0; i<TwoPowerD; i++) {
111 double* value = fineGridVertices{{SOLVER_NAME}}(i).{{GETTER}}().data();
112 _dataWriter->plotVertex( vertexIndex+i, value );
118 __Template_BeginTraversal =
"""
119 if ({{PLOT_PREDICATE}}) {
120 tarch::mpi::Lock lock( _semaphore );
122 static int counter = -1;
125 std::ostringstream snapshotFileName;
126 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
128 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
129 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
132 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
133 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
134 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
138 _dataWriter = _writer->createVertexDataWriter(
140 2, // number of dofs per axis per cell
141 repositories::{{SOLVER_INSTANCE}}.VertexUnknowns,
142 "Solution of {{SOLVER_NAME}}"
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:
163 static tarch::mpi::BooleanSemaphore _semaphore;
167 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
168 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
174#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
175#include "tarch/mpi/Lock.h"
176#include "tarch/mpi/BooleanSemaphore.h"
177#include "tarch/multicore/Lock.h"
178#include "tarch/multicore/BooleanSemaphore.h"
179#include "peano4/utils/Loop.h"
180#include "peano4/parallel/SpacetreeSet.h"
181#include "../repositories/SolverRepository.h"
187tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)