salvus.mesh.unstructured_mesh
A class to handle unstructured meshes. Some functions are restricted to special mesh types (Quadrilateral in 2D or Hexahedral in 3D).
Classes
UnstructuredMesh
UnstructuredMeshclass UnstructuredMesh(builtins.object):
def __init__(
self,
points: numpy.ndarray,
connectivity: numpy.ndarray,
scale: float = 1.0,
check_connectivity_shape: bool = True,
):
...Create an UnstructuredMesh from points and connectivity arrays.
pointsnumpy.ndarray — Nodes of the mesh, array with shape (number of points, number of dimensions)connectivitynumpy.ndarray — Connectivity of the mesh defining the elements in the mesh listing all nodes in tensorized order. Can include higher order tensorized elements and should have shape (number of elements, (shape order + 1) ** (number of dimensions)).scalefloat — A scaling of the mesh that is only applied to the points array ob writing to file.check_connectivity_shapebool — Check the connectivity shape, only needed internally.expert
edges_per_element int
edges_per_element intNumber or edges on each element.
element_nodal_fields Dict[str, numpy.ndarray]
element_nodal_fields Dict[str, numpy.ndarray]Element nodal fields.
element_nodes_shape Tuple[int, ...]
element_nodes_shape Tuple[int, ...]Return the shape of the element nodes array.
Useful for initializing element nodal fields.
Returns: The shape of the element nodes.
elemental_scalar_fields Dict[str, numpy.ndarray]
elemental_scalar_fields Dict[str, numpy.ndarray]Element scalar fields.
first_order_connectivity numpy.ndarray
first_order_connectivity numpy.ndarrayFirst order connectivity constructed from the corner points in case the shape mapping order is larger than 1.
max_dist_abc float
max_dist_abc floatMaximum distance of the absorbing damping layer from the edge of the domain.
ndim int
ndim intNumber of space dimensions. For now either 2 or 3.
nelem int
nelem intNumber of elements in the mesh.
nelemental_fields int
nelemental_fields intNumber of elemental fields.
nglobal_arrays int
nglobal_arrays intNumber of global arrays.
nglobal_strings int
nglobal_strings intNumber of global strings.
nglobal_variables int
nglobal_variables intNumber of global variables.
nnodal_fields int
nnodal_fields intNumber of nodal fields.
nodes_per_element int
nodes_per_element intNumber of nodes per element, e. g. 4 for first order Quads and 8 for first order Hex.
npoint int
npoint intNumber of points / nodes in the mesh
nside_sets int
nside_sets intNumber of side sets.
shape_order int
shape_order intShape mapping order, i.e. the number of points in each direction in the tensorized elements - 1.
topological_facets numpy.ndarray
topological_facets numpy.ndarrayGet an array of node ids corresponding to each facet in the mesh.
The facets returned here are “topological” in that they only consider the mesh’s first-order connectivity. Returns an array of shape (n_elem, n_facet_per_elem, n_nodes_per_facet). Facet ordering is as followings:
2D Quad: bottom, top, right, left. 3D Hex: Left, right, bottom, top, back, front.
from_exodus()
from_exodus()def from_exodus(filename: Union[str, pathlib.Path]) -> UnstructuredMesh:
...Read unstructured mesh from exodus file. Only supports first order quads or hexes.
filenameUnion[str, pathlib.Path] — File to open.
from_h5()
from_h5()def from_h5(
filename: Union[str, pathlib.Path], read_data: bool = True
) -> UnstructuredMesh:
...Read unstructured mesh from an h5 file, as written by salvus.mesh.UnstructuredMesh.write_h5.
Note that nodal fields are not yet supported in this filetype.
filenameUnion[str, pathlib.Path] — File to open.read_databool — read the elemental and element nodal data
add_dem_2D()
add_dem_2D()def add_dem_2D(
self,
x: numpy.ndarray,
dem: numpy.ndarray,
y0: float = 0.0,
y1: float = inf,
yref: Optional[float] = None,
kx: int = 3,
ky: int = 1,
name: Optional[str] = None,
mode: str = "cartesian",
) -> None:
...Add topography by vertically stretching the domain in the region [y0, y1] - points below y0 are kept fixed, points above y1 are moved as the DEM, points in between are interpolated and the full DEM is applied to points at yref.
Usage: first call add_dem_2D for each boundary that is to be perturbed and finally call apply_dem to add the perturbation to the mesh coordinates.
xnumpy.ndarray — horizontal coordinates of the DEM. Angle in radians for spherical models.demnumpy.ndarray — the DEM sampled at the coordinates xy0float — vertical coordinate, at which the stretching begins, can be -np.infty for cartesian meshes.y1float — vertical coordinate, at which the stretching ends, can be np.inftyyrefOptional[float] — vertical coordinate, at which the topography should be applied, e.g. z-coordinate of the surface for surface topography. Defaults to the max y coordinate / radius in case at least one of y0, y1 are finite.kxint — horizontal degree of the spline interpolationkyint — vertical degree of the spline interpolationnameOptional[str] — name of this topography to refer to it in UnstructuredMesh.apply_dem()modestr — interpolation mode, either ‘cartesian’ or ‘spherical’
add_dem_3D()
add_dem_3D()def add_dem_3D(
self,
x: numpy.ndarray,
y: numpy.ndarray,
dem: numpy.ndarray,
z0: float = 0.0,
z1: float = inf,
zref: Optional[float] = None,
khorizontal: int = 3,
mode: str = "cartesian",
name: Optional[str] = None,
) -> None:
...Add topography by vertically stretching the domain in the region [z0, z1] - points below z0 and above z1 are kept fixed, points in between are linearly interpolated and the full DEM is applied to points at zref.
Usage: first call add_dem_3D for each boundary that is to be perturbed and finally call apply_dem to add the perturbation to the mesh coordinates.
The DEM can be either structured or unstructured, this is determined from the shapes of x and y.
See scipy.interpolate.RectBivariateSpline for structured Spline interpolation and scipy.interpolate.LinearNDInterpolator (khorizontal=1) or scipy.interpolate.CloughTocher2DInterpolator (khorizontal=3) for more information on the unstructured interpolation. For full sphere interpolation refer to scipy.interpolate.RectSphereBivariateSpline
xnumpy.ndarray — x coordinates of the DEM (colatitude in spherical models in radians). Either 1D for structured data or 2D for unstructured dataynumpy.ndarray — y coordinates of the DEM (longitude in spherical modes in radians). Either 1D for structured data or 2D for unstructured datademnumpy.ndarray — the DEM sampled at the coordinates x and yz0float — Vertical coordinate at which the stretching begins. Can be-np.inftyto just move all points belowzrefwith the DEM.z1float — Vertical coordinate at which the stretching ends. Can benp.inftyto just move all points abovezrefwith the DEMzrefOptional[float] — Vertical coordinates at which the DEM will be applied. It will linear interpolate between full stretching and no stretching betweenzrefandz0as well aszrefandz1respectively.khorizontalint — horizontal degree of the spline interpolation. For unstructured data either 1 or 3.modestr — interpolation mode, either ‘cartesian’, ‘spherical’ or ‘spherical_full’nameOptional[str] — name of this topography to refer to it in UnstructuredMesh.apply_dem()
add_dem_cylindrical()
add_dem_cylindrical()def add_dem_cylindrical(
self,
phi: numpy.ndarray,
z: numpy.ndarray,
dem: numpy.ndarray,
r0: float = 0.0,
r1: float = inf,
rref: Optional[float] = None,
kx: int = 3,
ky: int = 3,
name: Optional[str] = None,
) -> None:
...Add topography for cylindrical meshes where the axis of the cylinder is aligned with the z component. The DEM radially stretches the domain in the region of (x,y)-radii in [r0, r1] - points below r0 are kept fixed, points above r1 are moved as the DEM, points in between are interpolated and the full DEM is applied to points at rref.
Usage: first call add_dem_cylindrical for each boundary that is to be perturbed and finally call apply_dem to add the perturbation to the mesh coordinates.
phinumpy.ndarray — Angle in the x-y-plane of the DEM in radians.znumpy.ndarray — z-coordinates of the DEM.demnumpy.ndarray — the DEM sampled at the coordinates (phi,z)r0float — radius in x-y-plane at which the stretching beginsr1float — radius in x-y-plane at which the stretching ends, can be infinityrrefOptional[float] — radius in x-y-plane at which the topography should be appliedkxint — horizontal degree of the spline interpolationkyint — vertical degree of the spline interpolationnameOptional[str] — name of this topography to refer to it in UnstructuredMesh.apply_dem()
add_ellipticity()
add_ellipticity()def add_ellipticity(
self,
ellipticity: Union[str, float, numpy.ndarray, Callable] = "WGS84",
points: Optional[numpy.ndarray] = None,
scale: float = 1.0,
) -> None:
...Add ellipticity by radial stretching the domain.
Usage: first call add_ellipticity and add_dem_2D/3D and finally call apply_dem to add the perturbation to the mesh coordinates.
ellipticityUnion[str, float, numpy.ndarray, Callable] — ellipticity at the surface or as a function of radius. If its a callback function it wil be called with the radiuspointsOptional[numpy.ndarray] — An optional array to use for the mesh points, rather than using the stored points. Useful, for instance, when one wants to ensure that the points used for the ellpticity computation are normalized.scalefloat — Scale the radius by this value.
apply_dem()
apply_dem()def apply_dem(self, names: Optional[List[str]] = None) -> None:
...Apply the previously added DEMs.
namesOptional[List[str]] — Names of the DEMs to apply. Defaults to all added ones.
apply_element_mask()
apply_element_mask()def apply_element_mask(
self,
mask: numpy.ndarray,
return_node_map: bool = False,
side_sets: Optional[str, List[str]] = None,
) -> Union[UnstructuredMesh, Tuple[UnstructuredMesh, numpy.ndarray]]:
...Apply an element mask to the mesh, retaining elements only that are set true in the mask.
masknumpy.ndarray — The mask as boolean array.return_node_mapbool — Return a node map together with the new mesh object, to be used to map nodal fields to the set of nodes that are retained in the mesh.side_setsOptional[str, List[str]] — list of side set names to which the mask should be directly connected. All elements not connected to the side sets are retained. Can be used to avoid cavities in the mask.
attach_field()
attach_field()def attach_field(self, name: str, data: numpy.ndarray) -> None:
...store data on either the elements or the nodes (determined by the shape of data).
namestr — name of the fielddatanumpy.ndarray — data to store. 1D numpy array, with size of either nelem or npoint.
attach_global_variable()
attach_global_variable()def attach_global_variable(
self, name: str, data: Union[float, str, numpy.ndarray]
) -> None:
...store global mesh variable.
namestr — name of the variabledataUnion[float, str, numpy.ndarray] — data to store
change_tensor_order()
change_tensor_order()def change_tensor_order(
self,
tensor_order: Optional[int, numpy.int32, numpy.int64] = None,
interpolation_mode: str = "linear",
interpolation_kwargs: Optional[Dict] = None,
make_unique_points: bool = True,
tensor_node_locations: Optional[numpy.ndarray] = None,
) -> None:
...Change the tensor order of the mesh’s elements by going from linear to higher order elements.
Please be aware that this will delete any potentially set element nodal fields and nodal fields. Elemental fields and side sets will be retained.
New grid points are created by interpolating the existing corner
points. This function supports a variety of interpolation modes (some
of which require extra kwargs to set as part of the
interpolation_kwargs dictionary):
"linear": The default. Perform a bi/trilinear interpolation. No extra keyword arguments are supported or required for this mode."spherical": Linearly interpolate in radial direction, and apply spherical linear interpolation (slerp) laterally. The center of the sphere is always considered to be at the origin of the coordinate system. Supported additional keywords:
"r1_spherical": Apply slerp only for radii >=r1_spherical, default:0.0."r0_spherical": Apply bi/trilinear interpolation for radii <r0_spherical, default:0.0.
If r1_spherical > r0_spherical intermediate radii will linearly
interpolate between both modes.
"cylindrical": Linearly interpolate radially and along the last dimension. Slerp in the middle dimension. Only defined in 3D, for 2D point symmetry use"spherical". Supported additional keywords:
"r1_cylindrical": Apply slerp only for radii >=r1_cylindrical, default:0.0."r0_cylindrical": Apply bi/trilinear interpolation for radii <r0_cylindrical, default:0.0.
If r1_cylindrical > r0_cylindrical intermediate radii will linearly
interpolate between both modes.
"SmoothieSEM": Special interpolation mode for spherical SmoothieSEM mesh that preserves the cylindrical “inner core”. Supported additional keywords:"r0_spherical","r1_spherical","r0_cylindrical", and"r1_cylindrical"with the same meaning as for the other interpolation modes.
tensor_orderOptional[int, numpy.int32, numpy.int64] — Desired new tensor order of the elements.interpolation_modestr — How to interpolate the location of the new grid points. See above description.interpolation_kwargsOptional[Dict] — Extra keyword arguments for the chosen interpolation mode. See above description.make_unique_pointsbool — Remove duplicate points. Make sure to have a reason if you set this toFalse.tensor_node_locationsOptional[numpy.ndarray] — Locations of the tensor nodes. Defaults to the GLL locations of the chosen tensor order. In almost all cases you will not have to change this.
compute_dt()
compute_dt()def compute_dt(
self,
vp: Union[numpy.ndarray, float],
courant_number: float = 1.0,
min_gll_point_distance: float = 1.0,
fast: bool = True,
return_hmin_elemnodes: bool = False,
) -> Union[
Tuple[float, numpy.ndarray], Tuple[float, numpy.ndarray, numpy.ndarray]
]:
...estimate the time step based on the Courant criterion and the edgelengths of the elements.
vpUnion[numpy.ndarray, float] — scaled p-wave velocity for each elementcourant_numberfloat — Courant numbermin_gll_point_distancefloat — min_gll_point_distancefastbool — fastreturn_hmin_elemnodesbool — return_hmin_elemnodes
compute_mesh_quality()
compute_mesh_quality()def compute_mesh_quality(
self, quality_measure: str = "edge_aspect_ratio"
) -> numpy.ndarray:
...compute mesh quality
quality_measurestr — one of'edge_aspect_ratio'or'equiangular_skewness'
compute_resolved_frequency()
compute_resolved_frequency()def compute_resolved_frequency(
self, vmin: numpy.ndarray, elements_per_wavelength: float
) -> Tuple[float, numpy.ndarray]:
...estimate the highest resolved frequency: vmin / hmax / elements_per_wavelength
vminnumpy.ndarray — scaled minimum velocity for each elementelements_per_wavelengthfloat — number of elements needed to resolve one wavelength
copy()
copy()def copy(self) -> UnstructuredMesh:
...Return a deep copy of the object.
define_side_set()
define_side_set()def define_side_set(
self,
name: str,
element_ids: Optional[numpy.ndarray] = None,
side_ids: Optional[numpy.ndarray] = None,
side_set: Optional[
Tuple[numpy.ndarray, numpy.ndarray], Set[Tuple[int, int]]
] = None,
) -> None:
...define a set of edges (2D) or faces (3D) with a name.
Either provide element_ids AND side_ids, or the side set as a python set as created by UnstructuredMesh.get_side_set()
namestr — name of the side setelement_idsOptional[numpy.ndarray] — element ids of the sidesside_idsOptional[numpy.ndarray] — side ids of the sidesside_setOptional[Tuple[numpy.ndarray, numpy.ndarray], Set[Tuple[int, int]]] — set of tuples with element id and side id
extrude()
extrude()def extrude(
self,
offsets: numpy.ndarray,
scale: Optional[numpy.ndarray] = None,
rotation: Optional[numpy.ndarray] = None,
center: Optional[numpy.ndarray] = None,
) -> UnstructuredMesh:
...Extrude a 2D mesh to create a 3D mesh. Each extruded 2D mesh can be offset, scaled and rotated copies of the original.
offsetsnumpy.ndarray — offsets, either in the new dimension or all 3 dimension, shape is (nextrude, ) or (nextrude, 3)scaleOptional[numpy.ndarray] — scaling factor for each extruded copy, relative to the center, shape is (nextrude,)rotationOptional[numpy.ndarray] — rotation of each extruded copy in terms of euler angles relative to the center, shape is (nextrude, 3)centerOptional[numpy.ndarray] — center coordinates for rotation, defaults to the center of mass of the original 2D mesh, shape is (3,)
extrude_side_set()
extrude_side_set()def extrude_side_set(
self,
side_set: str,
offsets: numpy.ndarray,
scale: Optional[numpy.ndarray] = None,
rotation: Optional[numpy.ndarray] = None,
center: Optional[numpy.ndarray] = None,
) -> UnstructuredMesh:
...Extrude a side set to add new elements to the mesh.
side_setstr — name of the side setoffsetsnumpy.ndarray — offsets, either in the new dimension or all 3 dimension, shape is (nextrude, ) or (nextrude, 3)scaleOptional[numpy.ndarray] — scaling factor for each extruded copy, relative to the center, shape is (nextrude,)rotationOptional[numpy.ndarray] — rotation of each extruded copy in terms of euler angles relative to the center, shape is (nextrude, 3)centerOptional[numpy.ndarray] — center coordinates for rotation, defaults to the center of mass of the original 2D mesh, shape is (3,)
extrude_side_set_2D()
extrude_side_set_2D()def extrude_side_set_2D(
self,
side_set: str,
offsets: numpy.ndarray,
direction: Optional[str] = None,
) -> UnstructuredMesh:
...Extrude a side set of a 2D mesh and append new elements. Currently, the functionality is limited to cartesian meshes with side sets that are aligned with the coordinate axis.
side_setstr — name of the side setoffsetsnumpy.ndarray — offsets, either in the new dimension or all 3 dimension, shape is (nextrude, ) or (nextrude, 3)directionOptional[str] — Optional axis of extrusion ifoffsetsis a one-dimensional array. Must bexory.
find_side_sets()
find_side_sets()def find_side_sets(
self, mode: str = "cartesian", tolerance: float = 1e-08
) -> None:
...Find surfaces of simple box or spherical meshes in 2 or 3 dimension based on the node locations. Needs to be called before appling the DEM or space mapping. Assuming 3D hexahedral meshes, where the surface elements are all quads or 2D quadrilateral meshes, where the surface elements are lines.
Use UnstructuredMesh.find_surface() for more complex shapes.
modestr — the side sets to be found depend on the shape of the mesh, should be one of “cartesian”, “cylindrical”, “spherical_full”, “spherical_chunk”, “spherical_chunk_z”, “spherical_full_axisem” or “spherical_SmoothieSEM”.tolerancefloat — Floating point tolerance to assume a node is on a given side.
find_side_sets_generic()
find_side_sets_generic()def find_side_sets_generic(
self,
name: str,
distance: Union[Callable[[numpy.ndarray], numpy.ndarray], numpy.ndarray],
tolerance: float = 1e-08,
attach_side_set: bool = True,
) -> Optional[Tuple[numpy.ndarray, numpy.ndarray]]:
...Define side sets based on a callback function for the distance to that surface.
namestr — Name of the new side set.distanceUnion[Callable[[numpy.ndarray], numpy.ndarray], numpy.ndarray] — Callback function taking in points and returning a distance.tolerancefloat — Point with a distance beneath this are part of the side set.attach_side_setbool — If true, add the side set to the mesh, othewise return the side set elements and sides.
find_surface()
find_surface()def find_surface(self, side_set_name: str = "surface") -> None:
...find the surface of the mesh, i.e. all element sides that don’t touch another element side.
side_set_namestr — Name to give to the found surface.
get_element_centroid()
get_element_centroid()def get_element_centroid(self, spherical: bool = False) -> numpy.ndarray:
...Compute the centroids of all elements on the fly from the nodes of the mesh. Useful to determine which domain in a layered medium an element belongs to or to compute elemental properties from the model. For spherical meshes, correct spherical mapping may be used.
sphericalbool — Assume spherical mesh.
get_element_centroid_radius()
get_element_centroid_radius()def get_element_centroid_radius(self) -> numpy.ndarray:
...Compute the centroids of all elements on the fly from the nodes of the mesh. Usefull to determine which domain in a layered medium an element belongs to or to compute elemental properties from the model. This function computes the spherical radius directly and is hence more memory efficient than UnstructuredMesh.get_element_centroid()
get_element_directions()
get_element_directions()def get_element_directions(self) -> Tuple[numpy.ndarray, ...]:
...compute vectors that point into the reference coordinate direction in the center of the element. These need not be orthogonal.
get_element_nodes()
get_element_nodes()def get_element_nodes(self) -> numpy.ndarray:
...Get duplicated nodes, i.e. an array with shape (nelem, nodes_per_element, ndim) containing the node locations for all elements for all nodes. This can be significant in terms of memory requirements.
get_side_set()
get_side_set()def get_side_set(self, name: str) -> Set[Tuple[int, int]]:
...returns a side set as a python set, which is useful for logical operations on side sets.
namestr — Name of the side set.
get_side_set_facet_nodes()
get_side_set_facet_nodes()def get_side_set_facet_nodes(
self, name: str
) -> Tuple[numpy.ndarray, numpy.ndarray]:
...Get the tensorized nodes along a side set.
Note that this function respects the tensor order of the mesh, and will therefore return nodes equivalent to a tensorized quad in 3-D and all the nodes along an edge in 2-D.
namestr — The name of the side set.
get_side_set_nodes()
get_side_set_nodes()def get_side_set_nodes(self, name: str) -> numpy.ndarray:
...return side set node ids as array
namestr — Name of the side set.
map_nodal_fields_to_element_nodal()
map_nodal_fields_to_element_nodal()def map_nodal_fields_to_element_nodal(self) -> None:
...Map all nodal fields to element nodal and reset the nodal fields dictionary. To be used to store such data using UnstructuredMesh.write_h5
plot()
plot()def plot(
self,
show: bool = True,
linewidths: float = 0.5,
scatter: bool = False,
elemental_data: Optional[numpy.ndarray] = None,
element_node_data: Optional[numpy.ndarray] = None,
figure: Optional[matplotlib.figure.Figure] = None,
clim: Optional[Dict] = None,
) -> Optional[matplotlib.figure.Figure]:
...Plot the unstructured mesh.
showbool — Show the plot.linewidthsfloat — line widthscatterbool — scatter, otherwise plot lineselemental_dataOptional[numpy.ndarray] — elemental dataelement_node_dataOptional[numpy.ndarray] — element nodal datafigureOptional[matplotlib.figure.Figure] — The figure to plot into if givenclimOptional[Dict] — Norm limits for the colormap scaling.
plot_quality()
plot_quality()def plot_quality(
self,
quality_measure: str = "edge_aspect_ratio",
show: bool = True,
hist_kwargs: Dict = {},
compute_quality_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
...Plot the mesh quality.
quality_measurestr — Quality measure to plot.showbool — Show plot or not.hist_kwargsDict — hist_kwargscompute_quality_kwargsDict — compute_quality_kwargs
refine_locally()
refine_locally()def refine_locally(
self,
mask: numpy.ndarray,
refinement_level: int = 1,
hierarchical_map: Optional[numpy.ndarray] = None,
refinement_style: str = "unstable",
interpolation_mode: str = "linear",
interpolation_kwargs: Optional[Dict] = None,
reinterpolate_nodal_fields: bool = False,
unique_points_tolerance: int = 12,
) -> Optional[numpy.ndarray]:
...Refine the mesh locally using various refinement templates.
New grid points are created by interpolating the existing corner
points. This function supports a variety of interpolation modes (some
of which require extra kwargs to set as part of the
interpolation_kwargs dictionary):
"linear": The default. Perform a bi/trilinear interpolation. No extra keyword arguments are supported or required for this mode."spherical": Linearly interpolate radially, slerp laterally. The center of the sphere is always considered to be at the origin of the coordinate system. Supported additional keywords:"r0_spherical"and"r1_spherical". Don’t slerp <r0, slerp =>r0, and linearly interpolate between both modes in between."cylindrical": Linearly interpolate radially and along the last dimension. Slerp in the middle dimension. Only makes sense in 3D, for 2D point symmetry use"spherical"Supported additional keywords:"r0_cylindrical"and"r1_cylindrical". Don’t slerp <r0, slerp =>r0, and linearly interpolate between both modes in between."SmoothieSEM": Special for SmoothieSEM, only for expert usage.
masknumpy.ndarray — Mark either elements, nodes or edges to refine, boolean array with shape (nelem,), (npoint,) or (nelem, edges_per_element)refinement_levelint — Refinement level, can only be larger than 1 for stable schemes and an elemental mask.hierarchical_mapOptional[numpy.ndarray] — Pass a hierarchical map to keep track of which element in a coarser mesh the newly created elements belong torefinement_stylestr — Choose the refinement style, currently available in 2D are ‘stable’, ‘unstable’, ‘stable_convex’ and ‘unstable_convex’, in 3D ‘unstable_unidir’, ‘unstable’, ‘stable_convex’, ‘unstable_convex’, ‘unstable_convex_dir’, ‘unstable_dir’. Here stable refers to maintaining the angles in multilevel refinements, convexity refers to the region in the mesh in terms of its connectivity (which may be different to its geometric shape for non-rectilinar meshes) and directionality refers to isotropic or anisotropic refinements (where the latter need an edge based refinement mask).interpolation_modestr — How to interpolate the location of the new grid points. See above description.interpolation_kwargsOptional[Dict] — Extra keyword arguments for the chosen interpolation mode. See above description.reinterpolate_nodal_fieldsbool — map nodal fields to the newly created nodes using linear interpolationunique_points_toleranceint — The number of decimal digits used to determine unique points in the refined mesh.
rotate_coordinates()
rotate_coordinates()def rotate_coordinates(self, euler_angles: numpy.ndarray) -> None:
...Rotate the nodes coordinates around the origin.
euler_anglesnumpy.ndarray — Euler-angles to rotate around.
write_binary_vtk()
write_binary_vtk()def write_binary_vtk(self, filename: Union[str, pathlib.Path]) -> None:
...Write a binary VTK file.
Please note that this method currently writes the mesh without any attached material parameters. The advantage of using this output format is that ParaView can visualize high-order shapes (e.g. curved elements) in that format.
filenameUnion[str, pathlib.Path] — Filename. Make sure it uses a.vtuextension so ParaView recognizes it.
write_exodus()
write_exodus()def write_exodus(
self,
filename: Union[str, pathlib.Path],
overwrite: bool = True,
title: Optional[str] = None,
compression: Optional[Tuple[str, int]] = None,
) -> None:
...write mesh to exodus file
filenameUnion[str, pathlib.Path] — filename of the meshfileoverwritebool — overwrite if the file already existstitleOptional[str] — title of the mesh, defaults to filenamecompressionOptional[Tuple[str, int]] — Turn on compression. Pass a tuple of(method, option), e.g.("gzip", 2). Slows down writing a lot but the resulting files are potentially much smaller.
write_h5()
write_h5()def write_h5(
self,
filename: Union[str, pathlib.Path],
datatype: Type[numpy.number] = numpy.float64,
compression: Optional[Tuple[str, int]] = None,
mode: str = "model",
write_chunk_size: int = 10000,
overwrite: bool = True,
periodic_bcs: Optional[List[Tuple[str, str]]] = None,
) -> None:
...Write the mesh to an h5 file with xdmf descriptor.
filenameUnion[str, pathlib.Path] — Filename.datatypeType[numpy.number] — Datatype to write.compressionOptional[Tuple[str, int]] — Turn on compression. Pass a tuple of(method, option), e.g.("gzip", 2). Slows down writing a lot but the resulting files are potentially much smaller.modestr — one of"all","model","skeleton"or"minimal". Controls the content of the mesh file and whether an xdmf file is added. ‘all’: largest file size, multiple block xdmf file and faster reading from file with UnstructuredMesh.from_h5() ‘model’: all data to view the model, single block xdmf file for easy opening in paraview ‘skeleton’: only the first order connectivity can be viewed ‘minimal’: smallest file size, no xdmf.write_chunk_sizeint — HDF5 chunk size in bytes.overwritebool — Potentially overwrite an existing file.periodic_bcsOptional[List[Tuple[str, str]]] — Pass a tuple of side sets that you would like to make periodic. For example:[("x0", "x1"), ("z0", "z1)]. This option will only work if the mesh has been derived from theStructuredGrid3D.cube()class.
write_legacy_vtk()
write_legacy_vtk()def write_legacy_vtk(
self,
filename: Union[str, pathlib.Path],
volume: bool = True,
side_sets: List[str] = ["x0", "x1", "y0", "y1", "z0", "z1"],
) -> None:
...Write the mesh to a legacy vtk file, meant for visulization with the GUI. In 3D, only writes the hull.
filenameUnion[str, pathlib.Path] — filenamevolumebool — Also write volumetric data.side_setsList[str] — Side sets to write ifvolumeisFalse.
write_vtp()
write_vtp()def write_vtp(
self,
filename: Union[str, pathlib.Path],
side_sets: List[str] = ["x0", "x1", "y0", "y1", "z0", "z1"],
) -> None:
...Write the mesh to a vtp file, meant for visulization with the GUI. In 3D, only writes the hull.
filenameUnion[str, pathlib.Path] — filenameside_setsList[str] — Side sets to write.