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 def add_to_Peano4_datamodel( self, datamodel, verbose ):
43 datamodel.add_vertex(self._vertex_data)
44 datamodel.add_face(self._face_data)
45 datamodel.add_cell(self._cell_data)
46
47 def add_use_statements(self, observer):
48 """!
49
50 This routine should still be called even if overwritten
51 in child class.
52
53 """
54 observer.use_vertex(self._vertex_data)
55 observer.use_face( self._face_data)
56 observer.use_cell( self._cell_data)
57
58 def typename(self):
59 return self._name
60
61 def instance_name(self):
62 """!
63
64Return the name of the object that will be created for this solver.
65
66 """
67 return "instanceOf" + self.typename()
68
69 @abstractmethod
71 return "not written yet"
72
73 def add_to_abstract_solver(self, header, implementation):
75 self._abstract_solver_implementation_extras = implementation
76
77 def add_to_vertex_data(self, name, size):
78 """!
79 Add in extra attributes on the fly
80 """
81 self._vertex_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
82
83 def add_to_cell_data(self, name, size):
84 """!
85 Add in extra attributes on the fly
86 """
87 self._cell_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
88
89 def add_to_face_data(self, name, size):
90 """!
91 Add in extra attributes on the fly
92 """
93 self._face_data.data.add_attribute( peano4.dastgen2.Peano4DoubleArray( name, size ) )
94
95 @property
96 def name(self):
97 return self._name
98
99 def __str__(self):
100 return """
101Name: {}
102h_min: {}
103h_max: {}
104""".format(
105 self._name,
106 self.min_h,
107 self.max_h,
108 )
109
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:197
Abstract base class for matrix free solvers.
Definition Solver.py:9
add_to_Peano4_datamodel(self, datamodel, verbose)
Definition Solver.py:42
add_to_vertex_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:77
add_to_abstract_solver(self, header, implementation)
Definition Solver.py:73
add_to_cell_data(self, name, size)
Add in extra attributes on the fly.
Definition Solver.py:83
instance_name(self)
Return the name of the object that will be created for this solver.
Definition Solver.py:61
add_use_statements(self, observer)
This routine should still be called even if overwritten in child class.
Definition Solver.py:47
__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:89