simudo.mesh package¶
Submodules¶
simudo.mesh.construction_helper module¶
-
class
simudo.mesh.construction_helper.
BaseConstructionHelper
[source]¶ Bases:
object
boilerplate
-
dim
¶
-
classmethod
from_existing_mesh_cf
(mesh, cf, cell_regions, run=True, params=None, mesh_unit=None)[source]¶
-
gdim
¶
-
mesh_data
¶
-
p
¶
-
robjs
¶
-
used_cell_values
¶
-
user_mark_external_boundary_facets
(mesh, boundary_facet_function)[source]¶ override me (maybe)
this function is allowed to add new definitions and cell values to self.cell_regions
by default this uses facet.facet2d_angle and defines new regions right/top/left/bottom
this function MUST add an ‘exterior’ key for all external boundary facets
-
-
class
simudo.mesh.construction_helper.
ConstructionHelperIntervalProduct2DMesh
[source]¶ Bases:
simudo.mesh.construction_helper.BaseConstructionHelper
-
class
Interval1DTag
(intervals)¶ Bases:
simudo.mesh.interval1dtag.Product2DMeshMixin
,simudo.mesh.interval1dtag.MinimumCoordinateDistanceMixin
,simudo.mesh.interval1dtag.BaseInterval1DTag
-
interval_1d_tag
¶
-
product2d_Ys
= (0.0, 1.0)¶
-
class
-
class
simudo.mesh.construction_helper.
ConstructionHelperLayeredStructure
[source]¶ Bases:
simudo.mesh.construction_helper.ConstructionHelperIntervalProduct2DMesh
-
material_to_region
¶ Mapping from material to abstract CellRegion.
- Type
dict
-
extra_regions
¶
-
layers
¶
-
material_to_region
¶
-
-
class
simudo.mesh.construction_helper.
ConstructionHelperManualCellTagging
[source]¶ Bases:
simudo.mesh.construction_helper.BaseConstructionHelper
-
class
simudo.mesh.construction_helper.
ConstructionHelperMshr
[source]¶ Bases:
simudo.mesh.construction_helper.BaseConstructionHelper
-
class
simudo.mesh.construction_helper.
ConstructionHelperPygmsh
[source]¶ Bases:
simudo.mesh.construction_helper.BaseConstructionHelper
-
mesh_filename
= None¶
-
-
class
simudo.mesh.construction_helper.
InvertibleTransform
[source]¶ Bases:
object
FIXME: make PlazaRefinementND use alternate definition of longest_edge
This hack is instead used to temporarily modify the mesh coordinates temporarily to alter PlazaRefinementND’s length metric
v[i, j] is vertex i’s jth coordinate
simudo.mesh.construction_helper_example module¶
-
class
simudo.mesh.construction_helper_example.
Bob
[source]¶ Bases:
simudo.mesh.construction_helper.ConstructionHelperMshr
simudo.mesh.domaintag_mshr module¶
-
class
simudo.mesh.domaintag_mshr.
DomainTag
[source]¶ Bases:
object
-
first_cell_value
= 1¶
-
generate_intersection_regions
(tagitems)[source]¶ returns frozenset of tagset
region described by tagset is intersection(tagset) - union(all_tags - tagset)
-
-
class
simudo.mesh.domaintag_mshr.
DomainTagTest
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
simudo.mesh.facet module¶
-
class
simudo.mesh.facet.
FacetsManager
(mesh, cell_function, boundary_facet_function)[source]¶ Bases:
object
Keep track of boundaries between subdomains (cell function values).
-
boundary
(X, Y, intersection=None)[source]¶ Get signed boundary between X and Y.
If the intersection between X and Y is nonempty, you must pass the intersection argument. This function will pretend that the intersection is actually part of X or Y (depending on the value of intersection). In other words,
boundary(X, Y, 0) == boundary(X, Y-X)
, andboundary(X, Y, 1) == boundary(X-Y, Y)
.
- Parameters
X (set) – X and Y must be sets of cell marker values (representing subdomains). X and Y must be disjoint unless the intersection argument is used.
Y (set) – See X.
intersection (int, optional) – Must be 0 or 1, if specified.
- Returns
fvs – Set of tuples
(facet_value, sign)
representing facets between X and Y.- Return type
set
-
cell_value_internal
(X)[source]¶ Get internal facets excluding boundaries across cell values (subdomains).
- Parameters
X (set) – Set of cell values (representing subdomains).
- Returns
fvs – Set of (facet_value, sign) representing facets contained within X and not on the boundary between two cell values.
- Return type
set
-
fix_undefined_facets_after_subdivision
(mesh, cell_function, facet_function)[source]¶ Assign markers to facets created by mesh subdivision.
Upon subdivision, cells get split and new facets are created to separate them. The subdivision algorithm cannot know what facet value to assign to these new facets, so it leaves them with a large undefined value.
These facets must be fully internal to a subdomain, so the cells on either side must have the same cell value. That cell value corresponds to a facet value for internal facets, which is precisely the information stored in the internal_facets_dict attribute.
- Parameters
mesh (dolfin.Mesh) – Mesh on which to operate.
cell_function (dolfin.CellFunction) – Cell function on mesh representing subdomains.
facet_function (dolfin.FacetFunction) – Facet function to fix up after subdivision. This will be modified in place.
-
-
simudo.mesh.facet.
facet2d_angle
(facet)[source]¶ right_value=0, up_value=1, left_value=2, down_value=3
simudo.mesh.interval1dtag module¶
-
class
simudo.mesh.interval1dtag.
BaseInterval1DTag
(intervals)[source]¶ Bases:
object
Class that turns a bunch of arbitrary overlapping intervals into a mesh.
-
coordinates
¶
-
first_cell_value
= 1¶
-
make_interval_coordinates
(x0, x1, local_edge_length_function)[source]¶ Note: this excludes second endpoint
-
subdomains
¶
-
tag_to_cell_values
¶ Mapping from a tag to a set of cell values (e.g. values inside self.product2d_mesh.cell_function).
-
-
class
simudo.mesh.interval1dtag.
CInterval
(x0, x1, tags=(), edge_length=inf)[source]¶ Bases:
simudo.mesh.interval1dtag.Interval
Represents an interval with constant edge length (in the x direction).
Note: you do not need to derive from this class to implement a custom edge length. Instead, you can subclass from
Interval
and implement a customlocal_edge_length
method.
-
class
simudo.mesh.interval1dtag.
GeometricallyExpandingMeshInterval
(*, edge_length_start, edge_length_expansion_factor, **kw)[source]¶ Bases:
simudo.mesh.interval1dtag.Interval
Interval of 1D mesh where the edge lengths start at
start
and increase geometrically away from the region bounds.See
doc/mesh.lyx
for more information.(Local edge length: minimum distance between two mesh vertices.)
- Parameters
bounds (tuple) – Tuple defining the region.
edge_length_start (float or tuple) – The initial edge length at the bounds. To have different initial edge lengths at the two ends of the region, pass in a tuple.
edge_length_expansion_factor (float or tuple) – Geometric expansion factor. Pass in a tuple to use different factors on the two ends of the region.
-
class
simudo.mesh.interval1dtag.
Interval
(x0, x1, tags=())[source]¶ Bases:
object
Represents a single interval, possibly with tags.
-
class
simudo.mesh.interval1dtag.
Interval1DTag
(intervals)[source]¶ Bases:
simudo.mesh.interval1dtag.Product2DMeshMixin
,simudo.mesh.interval1dtag.MinimumCoordinateDistanceMixin
,simudo.mesh.interval1dtag.BaseInterval1DTag
-
class
simudo.mesh.interval1dtag.
MinimumCoordinateDistanceMixin
[source]¶ Bases:
object
-
minimum_coordinate_distance
= 1e-10¶
-
-
class
simudo.mesh.interval1dtag.
Product2DMeshMixin
[source]¶ Bases:
object
-
class
Product2DMesh
(Xs, Ys=None)¶ Bases:
object
-
cells_at_ix
(ix)¶
-
copy
()¶ note: does not deepcopy Xs and Ys
-
create_function_from_x_values
(values)¶
-
element
¶
-
ix_from_vertex
(v)¶
-
iy_from_vertex
(v)¶
-
mesh
¶
-
nX
¶
-
nY
¶
-
space
¶
-
vertices_at_ix
(ix)¶
-
vertices_at_iy
(iy)¶
-
-
make_product2d_mesh
(coordinates, subdomain_to_coordinate_range, subdomain_to_cell_value, Ys)[source]¶
-
product2d_Ys
= (0.0, 1.0)¶
-
product2d_mesh
¶ Use this to get a readily-constructed Product2D object. Note that an attribute cell_function has been added to it.
-
class
simudo.mesh.mesh_entity_predicate module¶
-
class
simudo.mesh.mesh_entity_predicate.
AlwaysTruePredicate
(dim)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
AndMeshEntityPredicate
(*predicates)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.CombiningMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
CombiningMeshEntityPredicate
(*predicates)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
DimensionAdapterPredicate
(predicate, dim)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
DirectionalEdgeLengthPredicate
(direction, threshold=None)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
dim
= 1¶
-
-
class
simudo.mesh.mesh_entity_predicate.
InRadiusCellPredicate
(threshold, dim)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
MaxEdgeLengthCellPredicate
(threshold, dim)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
NandMeshEntityPredicate
(*predicates)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.CombiningMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
OrMeshEntityPredicate
(*predicates)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.CombiningMeshEntityPredicate
-
class
simudo.mesh.mesh_entity_predicate.
SubdomainCellPredicate
(cell_function, subdomains)[source]¶ Bases:
simudo.mesh.mesh_entity_predicate.BaseMeshEntityPredicate
simudo.mesh.product2d module¶
simudo.mesh.pygmsh module¶
-
class
simudo.mesh.pygmsh.
PygmshMakeRegions
[source]¶ Bases:
object
We want overlapping regions. gmsh and pygmsh make that difficult. gmsh supports overlapping physical surfaces/volumes, but it returns duplicate mesh cells (see meshio issue 175). We can fix this by postprocessing pygmsh’s output, which thankfully contains all the necessarily info. At least for now.
simudo.mesh.refine module¶
simudo.mesh.topology module¶
-
class
simudo.mesh.topology.
CellRegion
(*args, **kwargs)[source]¶ Abstract cell region.
Can be evaluated down to a set of subdomain markers using
MeshData.evaluate_topology()
.To access a cell region predefined (named) in the mesh generator, instantiate this class directly with a
name
argument.
-
class
simudo.mesh.topology.
FacetRegion
(*args, **kwargs)[source]¶ Abstract facet region.
Can be evaluated down to a set of
(facet_marker_value, facet_sign)
usingMeshData.evaluate_topology()
.To access a facet region predefined (named) in the mesh generator, instantiate this class directly with a
name
argument.
-
class
simudo.mesh.topology.
CellRegions
(mapping=None)[source]¶ Convenient container for cell region objects.
-
\_mapping\_
Dictionary of cell regions.
- Type
dict
-
\_\_getitem\_\_(name)
I.e.
obj[name]
. Ifname
is already in_mapping_
, it is retrieved from there; otherwise aCellRegion
is created with that name, stored inside_mapping_
, and returned.If
name
is aset
, then a subset of the_mapping_
dictionary is returned with those keys.
-
\_\_getattr\_\_(name)
I.e.
obj.$name
. Redirected toobj[name]
.
-
-
class
simudo.mesh.topology.
FacetRegions
(mapping=None)[source]¶ Convenient container for facet region objects.
See
CellRegions
.