Peano
Loading...
Searching...
No Matches
FixedResolutionGridSelector.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from .GridSelector import GridSelector
4
5
7 """!
8
9 Select the mesh entities of one level of the spacetree
10
11 The root of the spacetree, i.e. the bounding box of the whole domain,
12 is level 0. Each further level splits the cells of its parent into
13 three along each axis, i.e. a cell on level l has the size
14 domain_size/3^l. The guards select exactly the vertices, faces and
15 cells of this size, no matter whether they are refined further or not.
16 If the mesh is coarser than the level somewhere, the guards do not
17 hold there.
18
19 The markers do not know their level, so the guards compare the mesh
20 size h() of the vertex, face or cell with the size of a cell on the
21 selected level. Different to FineGridSelector, the selection does not
22 depend on the refinement state, i.e. it is the same in each and every
23 mesh sweep.
24
25 """
26
27 def __init__(self, level: int, domain_size):
28 """!
29
30 level: int
31 Level of the spacetree, with 0 being the root.
32
33 domain_size: list of float
34 Size of the computational domain along each axis, i.e. the same
35 value as handed over to the project's global simulation
36 parameters.
37
38 """
39 assert level >= 0, "level has to be non-negative"
40 self._level = level
41 self._mesh_size = [size / 3**level for size in domain_size]
42
43 def _guard(self) -> str:
44 """!
45
46 Compare each entry of marker.h() with the size of a cell on the
47 selected level. The tolerance is relative to this size, as the
48 sizes become tiny on fine levels.
49
50 """
51 return " and ".join(
52 f"tarch::la::equals(marker.h()({axis}), {size!r}, {size * 1e-6!r})"
53 for axis, size in enumerate(self._mesh_size)
54 )
55
56 def createVertexGuard(self) -> str:
57 return self._guard()
58
59 def createFaceGuard(self) -> str:
60 return self._guard()
61
62 def createCellGuard(self) -> str:
63 return self._guard()
__init__(self, int level, domain_size)
level: int Level of the spacetree, with 0 being the root.
str createFaceGuard(self)
C++ boolean expression over a peano4::datamanagement::FaceMarker called marker.
str _guard(self)
Compare each entry of marker.h() with the size of a cell on the selected level.
str createCellGuard(self)
C++ boolean expression over a peano4::datamanagement::CellMarker called marker.
str createVertexGuard(self)
C++ boolean expression over a peano4::datamanagement::VertexMarker called marker.
Select a subset of the mesh entities.