Peano
Loading...
Searching...
No Matches
Solver.py
Go to the documentation of this file.
1import peano4
2import dastgen2
3from abc import abstractmethod
4
5class Solver:
6 """!
7
8 Abstract base class for matrix free solvers.
9
10 """
11
12 def __init__(self,
13 name,
14 min_h,
15 max_h):
16 self._name = name
17 self.min_h = min_h
18 self.max_h = max_h
19
23
24 self._vertex_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Boundary", "Interior", "Coarse", "Outside", "Undefined"] ) )
25 self._face_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Boundary", "Interior", "Coarse", "Outside", "Undefined"] ) )
26 self._cell_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Interior", "Coarse", "Outside", "Undefined"] ) )
27
28 # for use with verification suite
31
32
33 def add_to_Peano4_datamodel( self, datamodel, verbose ):
34 datamodel.add_vertex(self._vertex_data)
35 datamodel.add_face(self._face_data)
36 datamodel.add_cell(self._cell_data)
37
38 def add_use_statements(self, observer):
39 """!
40
41 This routine should still be called even if overwritten
42 in child class.
43
44 """
45 observer.use_vertex(self._vertex_data)
46 observer.use_face( self._face_data)
47 observer.use_cell( self._cell_data)
48
49 def typename(self):
50 return self._name
51
52 def instance_name(self):
53 """!
54
55Return the name of the object that will be created for this solver.
56
57 """
58 return "instanceOf" + self.typename()
59
60 @abstractmethod
62 return "not written yet"
63
64 def add_to_abstract_solver(self, header, implementation):
66 self._abstract_solver_implementation_extras = implementation
67
68 def add_to_vertex_data(self, name, size):
69 """!
70 Add in extra attributes on the fly
71 """
72 self._vertex_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
73
74 def add_to_cell_data(self, name, size):
75 """!
76 Add in extra attributes on the fly
77 """
78 self._cell_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
79
80 def add_to_face_data(self, name, size):
81 """!
82 Add in extra attributes on the fly
83 """
84 self._face_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
85
86 @property
87 def name(self):
88 return self._name
89
90 def __str__(self):
91 return """
92Name: {}
93h_min: {}
94h_max: {}
95""".format(
96 self._name,
97 self.min_h,
98 self.max_h,
99 )
100
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Definition Enumeration.py:6
Specialisation of dastgen2.attributes.DoubleArray which relies on Peano's tarch.
Default superclass for any data model in Peano which is stored within the grid.
Definition DaStGen2.py:47
Abstract base class for matrix free solvers.
Definition Solver.py:5
add_to_Peano4_datamodel(self, datamodel, verbose)
Definition Solver.py:33
add_to_vertex_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:68
add_to_abstract_solver(self, header, implementation)
Definition Solver.py:64
add_to_cell_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:74
instance_name(self)
Return the name of the object that will be created for this solver.
Definition Solver.py:52
add_use_statements(self, observer)
This routine should still be called even if overwritten in child class.
Definition Solver.py:38
__init__(self, name, min_h, max_h)
Definition Solver.py:15
add_to_face_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:80