9 Specialisation of array using Peano's tarch with a smart pointer
11 This routine maps a logical array of fixed size onto a smart pointer class.
12 If you use it, the resulting element tied to a cell, face or vertex might
13 induce significantly lower memory movement overhead. However, this is not
14 guaranteed, and requires some careful testing. As you work with smart
15 pointers, the routine gives you direct access to the underlying vector,
16 i.e. provides specialised routines that expose the underlying data
17 structure: There are the standard getters and setters, but there are also
18 variants which give you the start pointer data object, while get and set
19 are compatible with Peano4DoubleArray's signature.
21 Using this class is straightforward and doesn't seem to be any different to
22 Peano4DoubleArray. However, under the hood you'll alter the behaviour of
23 peano4.datamodel.DaStGen2.
34 See superclass' constructor.
36 @param cardinality: String
37 This is important: It is not (necessarily) an integer, but can be
38 a string which is defined via a pragma or constexpr later.
41 super(Peano4SmartPointerDoubleArray, self).
__init__(
42 name, cardinality, valid_mantissa_bits=
None, ifdefs=ifdefs
46 def get_methods(self, _full_qualified_class_name, for_declaration=True):
49 This routine defines which operations the generated data type offers
51 It is very much the same as Peano4DoubleArray, i.e. it hides the
52 underlying smart pointers. If the user calls get, the data is converted
53 into a normal tarch vector. If the user calls set, we take the argument
54 and copy it into the underlying smart pointer.
56 However, we add one more routine: getXXXXSmartPointer(). This way,
57 users can get access to the smart pointer data under the hood.
63 "get" + accessor_name +
"() const",
69 +
"(const tarch::la::Vector<"
74 (
"get" + accessor_name +
"(int index) const",
"double"),
75 (
"set" + accessor_name +
"(int index, double value)",
"void"),
77 "get" + accessor_name +
"SmartPointer()",
94 return [(
"_" + self.
_name_name +
".data()[0]",
"void")]
108 signature.startswith(
"get")
109 and "SmartPointer" in signature
111 return " return " + name +
";\n"
113 signature.startswith(
"get")
114 and "index" in signature
116 return " return " + name +
"(index);\n"
118 signature.startswith(
"set")
119 and "index" in signature
121 return name +
"(index) = value;\n"
122 elif signature.startswith(
"get"):
123 return " return " + name +
".toVector();\n"
124 elif signature.startswith(
"set"):
125 return name +
" = value;\n"
136 Return string representation of attribute.
140 return "_dataStore._" + self.
_name_name +
".toVector()"
An array of doubles, i.e.
Specialisation of array using Peano's tarch with a smart pointer.
get_native_MPI_type(self)
Return native (built-in) MPI datatype.
get_first_plain_C_attribute(self)
For MPI for example, I need to know the first attribute.
get_methods(self, _full_qualified_class_name, for_declaration=True)
This routine defines which operations the generated data type offers.
use_default_copy_constructor(self)
Cannot use the default copy constructor, as it is an array, i.e.
get_constructor_arguments(self)
Return list of tuple of arguments for the constructor.
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.
__init__(self, name, cardinality, ifdefs=[])
See superclass' constructor.
get_to_string(self)
Return string representation of attribute.