Peano
Loading...
Searching...
No Matches
Solver.py
Go to the documentation of this file.
1"""
2 This file is part of the MGHyPE project within Peano 4. For conditions of distribution and
3 use, please see the copyright notice at www.peano-framework.org
4"""
5import peano4
6import dastgen2
7from abc import abstractmethod
8
9class Solver:
10 """!
11
12 Abstract base class for matrix free solvers.
13
14 ## Data associated with mesh entities
15
16 We always assign data to vertices, cells and faces, even though your
17 particular solver subclass might not require those guys.
18
19 """
20
21 def __init__(self,
22 name,
23 min_h,
24 max_h):
25 self._name = name
26 self.min_h = min_h
27 self.max_h = max_h
28
32
33 self._vertex_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Boundary", "Interior", "Coarse", "Outside", "Undefined"] ) )
34 self._face_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Boundary", "Interior", "Coarse", "Outside", "Undefined"] ) )
35 self._cell_data.data.add_attribute( dastgen2.attributes.Enumeration( name="type", variants=["Interior", "Coarse", "Outside", "Undefined"] ) )
36
37 # for use with verification suite
40
41
42 #! [mghype_matrixfree_solvers_api_Solver_add_to_mesh]
43 def add_to_Peano4_datamodel( self, datamodel, verbose ):
44 datamodel.add_vertex(self._vertex_data)
45 datamodel.add_face(self._face_data)
46 datamodel.add_cell(self._cell_data)
47
48 def add_use_statements(self, observer):
49 """!
50
51 This routine should still be called even if overwritten
52 in child class.
53
54 """
55 observer.use_vertex(self._vertex_data)
56 observer.use_face( self._face_data)
57 observer.use_cell( self._cell_data)
58 #! [mghype_matrixfree_solvers_api_Solver_add_to_mesh]
59
60 def typename(self):
61 return self._name
62
63 def instance_name(self):
64 """!
65
66Return the name of the object that will be created for this solver.
67
68 """
69 return "instanceOf" + self.typename()
70
71 @abstractmethod
73 return "not written yet"
74
75 def add_to_abstract_solver(self, header, implementation):
77 self._abstract_solver_implementation_extras = implementation
78
79 def add_to_vertex_data(self, name, size):
80 """!
81 Add in extra attributes on the fly
82 """
83 self._vertex_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
84
85 def add_to_cell_data(self, name, size):
86 """!
87 Add in extra attributes on the fly
88 """
89 self._cell_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
90
91 def add_to_face_data(self, name, size):
92 """!
93 Add in extra attributes on the fly
94 """
95 self._face_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
96
97 @property
98 def name(self):
99 return self._name
100
101 def __str__(self):
102 return """
103Name: {}
104h_min: {}
105h_max: {}
106""".format(
107 self._name,
108 self.min_h,
109 self.max_h,
110 )
111
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Definition Enumeration.py:6
Specialisation of array using Peano's tarch.
Default superclass for any data model in Peano which is stored within the grid.
Definition DaStGen2.py:157
Abstract base class for matrix free solvers.
Definition Solver.py:9
add_to_Peano4_datamodel(self, datamodel, verbose)
Definition Solver.py:43
add_to_vertex_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:79
add_to_abstract_solver(self, header, implementation)
Definition Solver.py:75
add_to_cell_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:85
instance_name(self)
Return the name of the object that will be created for this solver.
Definition Solver.py:63
add_use_statements(self, observer)
This routine should still be called even if overwritten in child class.
Definition Solver.py:48
__init__(self, name, min_h, max_h)
Definition Solver.py:24
add_to_face_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:91