18 super( PlotDGDataInPeanoBlockFormat, self ).
__init__()
21 self.
d[
"SOLVER_INSTANCE"] = solver.instance_name()
22 self.
d[
"SOLVER_NAME"] = solver.typename()
34 __Template_Constructor =
"""
36 _valueWriter = nullptr;
38 _treeNumber = treeNumber;
40 // An MPI lock (critical section) would be important!
42 logDebug( "PlotGrid2PlotGridInPeanoBlockFormat1()", "created tree instance for " << treeNumber );
50 __Template_EndTraversal =
"""
51 assertion(_valueWriter!=nullptr);
52 assertion1(_valueWriter!=nullptr,_treeNumber);
54 assertion(_rhsWriter!=nullptr);
55 assertion1(_rhsWriter!=nullptr,_treeNumber);
57 _valueWriter->close();
59 _writer->writeToFile();
65 _valueWriter = nullptr;
75 return " return std::vector< peano4::grid::GridControlEvent >();\n"
79 return __name__.replace(
".py",
"").replace(
".",
"_")
86 Template_TouchCellFirstTime =
"""
87if (fineGridCell{{SOLVER_NAME}}PETScData.getType() == celldata::{{SOLVER_NAME}}PETScData::Type::Interior) {
88 int patchIndex = _writer->plotPatch(
89 marker.x()-0.5 * marker.h(),
93 int valuePatchVertexIndex = _valueWriter->getFirstVertexWithinPatch(patchIndex);
94 int rhsPatchVertexIndex = _rhsWriter->getFirstVertexWithinPatch(patchIndex);
96 assertionEquals(valuePatchVertexIndex, rhsPatchVertexIndex);
100 dfor(k,repositories::{{SOLVER_INSTANCE}}.Order+1) {
101 double* value = fineGridCell{{SOLVER_NAME}}.getValue().data();
102 double* rhs = fineGridCell{{SOLVER_NAME}}.getRhs().data();
103 _valueWriter->plotVertex( valuePatchVertexIndex, value+currentDoF );
104 _rhsWriter->plotVertex( rhsPatchVertexIndex, rhs+currentDoF );
105 valuePatchVertexIndex++;
106 rhsPatchVertexIndex++;
107 currentDoF += repositories::{{SOLVER_INSTANCE}}.CellUnknowns;
114 __Template_BeginTraversal =
"""
115 tarch::mpi::Lock lock( _semaphore );
117 std::ostringstream snapshotFileName;
118 snapshotFileName << "{{SOLVER_NAME}}";
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(), "{{FILENAME}}",
126 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::IndexFileMode::NoIndexFile,
130 _valueWriter = _writer->createVertexDataWriter(
132 repositories::{{SOLVER_INSTANCE}}.Order+1, // nodes per axis
133 repositories::{{SOLVER_INSTANCE}}.CellUnknowns,
135 "Solution as delivered through PETSc"
137 _rhsWriter = _writer->createVertexDataWriter(
139 repositories::{{SOLVER_INSTANCE}}.Order+1, // nodes per axis
140 repositories::{{SOLVER_INSTANCE}}.CellUnknowns,
142 "Nodal right-hand side value"
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* _valueWriter;
166 tarch::plotter::griddata::blockstructured::PeanoTextPatchFileWriter::VertexDataWriter* _rhsWriter;
172#include "tarch/plotter/griddata/blockstructured/PeanoTextPatchFileWriter.h"
173#include "tarch/mpi/Lock.h"
174#include "tarch/mpi/BooleanSemaphore.h"
175#include "tarch/multicore/Lock.h"
176#include "tarch/multicore/BooleanSemaphore.h"
177#include "peano4/utils/Loop.h"
178#include "peano4/parallel/SpacetreeSet.h"
179#include "../repositories/SolverRepository.h"
185tarch::mpi::BooleanSemaphore """ + full_qualified_classname +
"""::_semaphore;
Action set (reactions to events)