Peano
Loading...
Searching...
No Matches
CellLabel.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from peano4.solversteps.ActionSet import ActionSet
4
5import dastgen2
7
8
10 """! Update the cell label within a sweep
11
12 Update the cell label initialises cell labels correctly when a cell is
13 created, and it also resets the update flag.
14
15 It is important that this label update happens before the actual cell
16 update. This is ensured via a correct invocation order in
17 FV.add_actions_to_perform_time_step().
18
19 Cell labels exist everywhere and are not masked out via the LoadStoreCompute
20 flag. That is, we store them persistently in each and every cell on all
21 resolution levels all the time - even if the underlying solver des not
22 exist in such a cell. In this case, the cell label should be false all the
23 time.
24
25 """
26 def get_attribute_name(solver_name):
27 return solver_name + "CellLabel"
28
29 """
30
31 SetLabels is an action set which is automatically merged into all ExaHyPE2
32 steps by the project. There's nothing for the user solvers to be done here.
33
34 """
35 def __init__(self, solver_name):
36 super(UpdateCellLabel,self).__init__(descend_invocation_order=1,parallel=False)
37 self._solver_name = solver_name
38 pass
39
40
42 return ""
43
44
46 return ""
47
48
49 #def get_body_of_getGridControlEvents(self):
50 # return self.__Template_GridControlEvents.format(**self.d)
51
52
54 return __name__.replace(".py", "").replace(".", "_")
55
56
58 return False
59
60
61 def get_body_of_operation(self,operation_name):
62 result = "\n"
63 if operation_name==ActionSet.OPERATION_CREATE_CELL:
64 result += """
65 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setSemaphoreNumber( ::exahype2::EnclaveBookkeeping::NoEnclaveTaskNumber );
66 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setAMDCriterionEvaluatedThroughoutGridConstruction( false );
67 if ( tarch::la::equals(repositories::getMinTimeStamp(),0.0) ) {
68 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setTimeStamp( 0.0 );
69 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setTimeStepSize( 0.0 );
70 }
71 else {
72 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setTimeStamp( coarseGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.getTimeStamp() );
73 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setTimeStepSize( coarseGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.getTimeStepSize() );
74 }
75 fineGridCell""" + UpdateCellLabel.get_attribute_name(self._solver_name) + """.setHasUpdated( false );
76"""
77 return result
78
79
80 def get_attributes(self):
81 return ""
82
83
84 def get_includes(self):
85 return """
86#include "Constants.h"
87#include "exahype2/EnclaveBookkeeping.h"
88#include "repositories/SolverRepository.h"
89"""
90
91
92
93
94def create_cell_label(solver_name):
95 """!
96
97 Build up the DaStGen2 data structure that we need per cell to maintain
98 per-cell data per solver.
99
100 :: Attributes per cell
101
102 - SemaphoreNumber is a number that links to a task that has been spawn in the
103 background. Consult the enclave tasking and its bookkeeping for details.
104 - TimeStamp holds the local time stamp of the current cell. Even for global
105 time stepping, it is important that this time stamp is stored per cell, as
106 some postprocessing (particles, e.g.) rely on the field.
107 - TimeStepSize (similar to arguments around TimeStamp).
108 - AMDCriterionEvaluatedThroughoutGridConstruction
109 - DeviceNumber is the number of the GPU that the device memory of this cell is allocated on.
110 - DeviceMemoryAddress is the pointer to the device memory of this cell. The device
111 memory is used to store the reconstructed patch of the cell when enclave tasking is used.
112 - DeviceMemoryStatus is the status of the device memory of this cell
113
114 solver_name: string
115 Name of the solver
116
117 """
118 result = peano4.datamodel.DaStGen2( UpdateCellLabel.get_attribute_name( solver_name ) )
119
120 result.data.add_attribute( dastgen2.attributes.Integer("SemaphoreNumber") )
121 result.data.add_attribute( dastgen2.attributes.Double("TimeStamp") )
122 result.data.add_attribute( dastgen2.attributes.Double("TimeStepSize") )
123 result.data.add_attribute( dastgen2.attributes.Boolean("HasUpdated") )
124 result.data.add_attribute( dastgen2.attributes.Boolean("AMDCriterionEvaluatedThroughoutGridConstruction") )
125 result.data.add_attribute( dastgen2.attributes.Integer("DeviceNumber") )
126 result.data.add_attribute( dastgen2.attributes.DoublePointer("DeviceMemoryAddress") )
127 result.data.add_attribute( dastgen2.attributes.Enumeration("DeviceMemoryStatus", ["Unallocated", "OutOfDate", "UpToDate"]) )
128 result.peano4_mpi_and_storage_aspect.merge_implementation = """
129 switch (context) {
130 case ::peano4::grid::TraversalObserver::SendReceiveContext::BoundaryExchange:
131 assertionMsg( false, "cells should never be subject of a boundary exchange" );
132 break;
133 case ::peano4::grid::TraversalObserver::SendReceiveContext::ForkDomain:
134 *this = neighbour;
135 break;
136 default:
137 assertionMsg( false, "not implemented yet" );
138 }
139"""
140
141 return result
cardinality is a string (you can thus use symbols as well as long as they will be defined at compile ...
Definition Double.py:6
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Definition Enumeration.py:6
Update the cell label within a sweep.
Definition CellLabel.py:9
get_includes(self)
Return include statements that you need.
Definition CellLabel.py:84
user_should_modify_template(self)
Is the user allowed to modify the output.
Definition CellLabel.py:57
get_action_set_name(self)
Return unique action set name.
Definition CellLabel.py:53
get_constructor_body(self)
Define a tailored constructor body.
Definition CellLabel.py:41
get_attributes(self)
Return attributes as copied and pasted into the generated class.
Definition CellLabel.py:80
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
Definition CellLabel.py:61
Default superclass for any data model in Peano which is stored within the grid.
Definition DaStGen2.py:157
Action set (reactions to events)
Definition ActionSet.py:6
create_cell_label(solver_name)
Build up the DaStGen2 data structure that we need per cell to maintain per-cell data per solver.
Definition CellLabel.py:94