3from enum
import IntEnum
9 Superclass has to be IntEnum, as I use this one within Jinja2 templates
10 where I struggled to compare against enum variants. I however can always
11 compare against integers.
29 if association==DoFAssociation.Vertex:
30 result +=
"VertexData"
31 elif association==DoFAssociation.Cell:
33 elif association==DoFAssociation.Face:
35 elif association==DoFAssociation.Global:
36 result +=
"GlobalData"
44 if association==DoFAssociation.Vertex:
46 elif association==DoFAssociation.Cell:
48 elif association==DoFAssociation.Face:
50 elif association==DoFAssociation.Global:
59 Base class for any degree of freedom object
61 Any degree of freedom object in Peano is derived from DoF. There are
62 different subclasses of this type which are actually used in most
63 implementations. The most popular one is peano4.api.datamodel.DaStGen2 which
64 encodes a DoF implementation which is based upon plain C++ objects created
65 through DaStGen2. However, there are also other data models such as bespoke
66 patch data represented through peano4.api.datamodel.Patch.
68 @image html dof-class-diagram.png
70 Every DoF in Peano has a name and a unique association with a mesh entity
71 which is held in association. There are some further properties tied to
72 each DoF such as a position x and a mesh width h, but we leave it to
73 subclasses to provide those guys.
75 Please consult the tutorials on @ref tutorials_peano4_assign_data_to_mesh "assigning data to a mesh" and
76 @ref tutorials_peano4_mask_out_data_usage "masking out data storage"
77 on some instructions where this class is actually used in code.
85 Create a degree of freedom object
87 Both the association and the namespace are not to be set directly,
88 but through the operation configure().
90 ## Additional store/load/send/receive arguments
92 - The first entry of this triple is the expression that you want the
94 - The second one is the C++ type of this expression.
95 - The third one is the name that you wanna use in the dof signatures
98 It is the responsibility of the DoF subclass to ensure that the second
99 entry is properly used to initialise the store and load routines.
100 Most define an additional setter for property.
105 association: DoFAssociation
108 Has to be a fit to the C++ naming conventions
111 Sequence of namespaces.
113 additional_load_and_store_arguments: [(String,String,String)]
114 This flag is, by default, an empty list. If you add an entry to this
115 list, each store and load routine will get an additional parameter.
116 Consult documentation above for the semantics of the list entries.
118 grid_selector: peano4.api.toolbox.GridSelector or None
119 None by default. If set, the task graph compiler restricts the
120 storage of this DoF to the mesh entities selected: The selector's
121 guard is AND-combined with each of the use/load/store predicates the
122 compiler derives (@see peano4.api.taskgraph.compiler.DeriveLoadStoreComputeFlag).
123 That is, data are only used, loaded or stored if the selector holds
124 and the compiler has concluded that the data are needed.
135 def configure(self,namespace,association, subdirectory=""):
137 Typically called by model as soon as you add an object to it
156 What should the data type be called within the data repository,
157 or within action sets. We add a prefix name here.
164 What should the data type be called within the data repository.
168 result +=
"peano4::datamanagement::VertexEnumerator<"
170 result +=
"peano4::datamanagement::FaceEnumerator<"
172 assert False,
"association was {}".format( self.
association )
186 use_dof_association = None
190 You can make Peano's store and load arguments of any DoF depend on other
191 DoFs that you have loaded before. So you can load X and then make Y later
192 on depend on the state of X. For this, you have to add a tuple to
193 Y's additional_load_and_store_arguments. It is a very technical tuple.
194 This routine helps you to construct it for X.
196 use_dof_association: DoFAssociation
197 Set this one to None and the routine will pick up self._association.
198 However, there are cases where we want to construct the string and
199 the association is not yet set properly. In this case, you have to
200 supplement the information manually.
203 if use_dof_association==
None:
206 stack_access_string =
"repositories::DataRepository::_{}Stack.getForPush( repositories::DataRepository::DataKey(_spacetreeId,peano4::grid::PeanoCurve::CallStack))->top()".format(
210 data_type =
"{}::{}".format(
215 return (stack_access_string,data_type,argument_name)
Superclass has to be IntEnum, as I use this one within Jinja2 templates where I struggled to compare ...
Base class for any degree of freedom object.
get_full_qualified_type(self)
configure(self, namespace, association, subdirectory="")
Typically called by model as soon as you add an object to it.
_additional_load_and_store_arguments
get_logical_type_name(self)
What should the data type be called within the data repository, or within action sets.
additional_load_and_store_arguments_for_other_dof(self, argument_name, use_dof_association=None)
You can make Peano's store and load arguments of any DoF depend on other DoFs that you have loaded be...
get_enumeration_type(self)
What should the data type be called within the data repository.
__init__(self, name)
Create a degree of freedom object.
additional_load_and_store_arguments(self)
get_logical_type_name_for_association(association, name)
get_subnamespace_for_association(association)