14 plot_predicate="true",
15 cell_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 );
59 __Template_EndTraversal =
"""
60 if ( {{PLOT_PREDICATE}} ) {
61 assertion(_dataWriter!=nullptr);
62 assertion1(_dataWriter!=nullptr,_treeNumber);
65 _writer->writeToFile();
70 _dataWriter = nullptr;
79 return " return std::vector< peano4::grid::GridControlEvent >();\n"
82 return __name__.replace(
".py",
"").replace(
".",
"_")
87 __Template_TouchCellFirstTime =
"""
89 fineGridCell{{SOLVER_NAME}}.getType() == celldata::{{SOLVER_NAME}}::Type::Interior
95 int vertexIndices[TwoPowerD];
97 int patchIndex = _writer->plotPatch(
98 marker.x()-0.5 * marker.h(),
102 int vertexIndex = _dataWriter->getFirstVertexWithinPatch(patchIndex);
103 for (int i=0; i<TwoPowerD; i++) {
104 double* value = fineGridVertices{{SOLVER_NAME}}(i).{{GETTER}}().data();
105 _dataWriter->plotVertex( vertexIndex+i, value );
110 __Template_BeginTraversal =
"""
111 if ({{PLOT_PREDICATE}}) {
112 tarch::mpi::Lock lock( _semaphore );
114 static int counter = -1;
117 std::ostringstream snapshotFileName;
118 snapshotFileName << "{{SOLVER_NAME}}.{{VARIABLE}}-" << counter ;
120 if (tarch::mpi::Rank::getInstance().getNumberOfRanks()>1 ) {
121 snapshotFileName << "-rank-" << tarch::mpi::Rank::getInstance().getRank();
124 _writer = new tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter(
125 Dimensions, snapshotFileName.str(), "{{SOLVER_NAME}}.{{VARIABLE}}",
126 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::AppendNewData,
130 _dataWriter = _writer->createVertexDataWriter(
132 2, // number of dofs per axis per cell
133 repositories::{{SOLVER_INSTANCE}}.VertexUnknowns,
134 "Solution of {{SOLVER_NAME}}"
137 _dataWriter->setPrecision(16);
143 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
147 if operation_name == ActionSet.OPERATION_BEGIN_TRAVERSAL:
149 if operation_name == ActionSet.OPERATION_END_TRAVERSAL:
155 static tarch::mpi::BooleanSemaphore _semaphore;
159 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter* _writer;
160 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _dataWriter;
165#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
166#include "tarch/mpi/Lock.h"
167#include "tarch/mpi/BooleanSemaphore.h"
168#include "tarch/multicore/Lock.h"
169#include "tarch/multicore/BooleanSemaphore.h"
170#include "peano4/utils/Loop.h"
171#include "peano4/parallel/SpacetreeSet.h"
172#include "../repositories/SolverRepository.h"
178tarch::mpi::BooleanSemaphore """
179 + full_qualified_classname
Action set (reactions to events)