Peano
Loading...
Searching...
No Matches
AssignNumbersToCells.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.api.solversteps.ActionSet import ActionSet
4
5
6import jinja2
7import dastgen2
8import peano4.api
9
10
11from .EnumerateCellsAndVertices import ClearNumbersOnMesh
12from .EnumerateCellsAndVertices import create_cell_marker
13from .EnumerateCellsAndVertices import construct_marker_name
14
15
17 """!
18
19 Gives each mesh cell a unique number
20
21 The numbers are unique per rank, but not globally unique. If you want to
22 use this action set, you before have to add a marker to the mesh data
23 model:
24
25 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 my_fancy_name = ...
27
28 cell_marker_for_tasks = peano4.api.toolbox.api.EnumerateCellsAndVertices.create_cell_marker(my_fancy_name)
29 self._project.datamodel.add_cell(cell_marker_for_tasks)
30 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31
32 @see create_vertex_marker()
33
34 """
35
37 self,
38 task_name,
39 ):
40 """!
41
42 Initialise assignment
43
44 @param task_name: String
45 The name of the task (attribute tied to the mesh entity) to be
46 manipulated.
47
48 """
49 super( AssignNumbersToCells, self ).__init__()
50 self._task_name = task_name
51 pass
52
53 def get_body_of_operation(self, operation_name):
54 """!
55
56 Very simple operation which basically resets all data
57
58 """
59 if operation_name == ActionSet.OPERATION_CREATE_CELL:
60 return """
61 fineGridCell{}.setNumber(tarch::Enumerator::NoNumber);
62 """.format(
63 construct_marker_name(self._task_name)
64 )
65 if operation_name == ActionSet.OPERATION_DESTROY_CELL:
66 return """
67 fineGridCell{}.getEnumerator().releaseNumber( fineGridCell{}.getNumber() );
68 """.format(
69 construct_marker_name(self._task_name),
70 construct_marker_name(self._task_name),
71 )
72 if operation_name == ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
73 return """
74 if ( fineGridCell{}.getNumber()==tarch::Enumerator::NoNumber ) {{
75 fineGridCell{}.setNumber( fineGridCell{}.getEnumerator().getNumber() );
76 logDebug( "touchCellFirstTime(...)", "set number " << fineGridCell{}.toString() );
77 }}
78 """.format(
79 construct_marker_name(self._task_name),
80 construct_marker_name(self._task_name),
81 construct_marker_name(self._task_name),
82 construct_marker_name(self._task_name),
83 construct_marker_name(self._task_name),
84 construct_marker_name(self._task_name),
85 )
86 return ""
87
89 return " return std::vector< peano4::grid::GridControlEvent >();\n"
90
92 return __name__.replace(".py", "").replace(".", "_") + "_AssignNumbersToCells"
93
95 return False
96
97 def get_includes(self):
98 return """
99#include "tarch/multicore/TaskEnumerator.h"
100 """
101
Action set (reactions to events)
Definition ActionSet.py:6
user_should_modify_template(self)
Is the user allowed to modify the output.
get_body_of_operation(self, operation_name)
Very simple operation which basically resets all data.
get_includes(self)
Return include statements that you need.
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.