pyoomph.meshes.mesh module

class pyoomph.meshes.mesh.InterfaceMesh(problem, parent, intername, eqtree, previous_mesh=None)[source]

Bases: InterfaceMesh

A mesh that is added to the boundary to add Neumann terms or setting Dirichlet conditions or add new fields directly on the interface, like e.g. surfactants.

adapt_by_elemental_errors(self, elemental_errors: collections.abc.Sequence[float]) → None

Adapts (refines/unrefines) this mesh according to the given per-element spatial error estimate

Return type:

None

add_boundary_node(self, boundary_index: int, node: pyoomph._pyoomph_core.Node) → None

Adds the given node to the given mesh boundary

Return type:

None

add_interpolated_nodes_at(self, arg0: collections.abc.Sequence[collections.abc.Sequence[float]], arg1: bool, /) → list[pyoomph._pyoomph_core.Node]

Creates and adds new nodes interpolated at the given positions, used e.g. when refining or remeshing

Return type:

list[Node]

add_node_to_mesh(self, node: pyoomph._pyoomph_core.Node) → None

Adds an already-constructed node to this mesh’s list of nodes

Return type:

None

apply_additional_dof_constraints(self) → None

Applies any additional dof constraints that have been registered on this mesh’s nodes

Return type:

None

as_pyoomph_mesh(self) → pyoomph._pyoomph_core.Mesh

Downcasts this mesh to a pyoomph Mesh, if it is one (returns None otherwise)

Return type:

Mesh

assign_global_base_element_indices(self) → None

Numbers this mesh’s root (base) elements in their current order and stores the number on the elements themselves. Must be called before the problem is distributed, while the mesh still holds all of them: afterwards each process only sees its own share. The numbers address elements independently of the partition and are what makes state files interchangeable between serial and distributed runs

Return type:

None

boundary_coordinate_bool(self, boundary_index: int, value: bool = True) → None

Declares that an intrinsic boundary coordinate has been set up for the given mesh boundary. Pass value=False to take the declaration back. (This SETS the flag; is_boundary_coordinate_defined reads it.)

Return type:

None

boundary_element_pt(self, boundary_index: int, element_index: int) → pyoomph._pyoomph_core.OomphGeneralisedElement

Returns the element at the given index among the elements adjacent to the given mesh boundary

Return type:

OomphGeneralisedElement

boundary_node_pt(self, boundary_index: int, node_index: int) → pyoomph._pyoomph_core.Node

Returns the node at the given index among the nodes on the given mesh boundary

Return type:

Node

bump_topology_generation(self) → None

Announces that this mesh’s elements or their coordinates have changed, so that anything caching them (tracer particles, point locators) rebuilds before its next use

Return type:

None

check_halo_consistency(self, throw_on_mismatch: bool = False) → int

In parallel (MPI) runs, checks that all processes agree about the elements they share – their positions, refinement levels and pending refinement flags. Returns the number of inconsistencies found (0 if the processes agree), reporting details to stdout; pass throw_on_mismatch to raise instead. Collective: every process must call it. Returns 0 on a mesh that is not distributed.

Return type:

int

check_integrity(self) → None

Runs internal consistency checks on this mesh, raising an error if a problem is found

Return type:

None

clear_additional_dof_constraints(self) → None

Clears any additional dof constraints (e.g. from remeshing) that have been applied to this mesh’s nodes

Return type:

None

clear_before_adapt(self) → None

Removes this interface mesh’s elements before the adjacent bulk mesh is adapted; they are regenerated afterwards by rebuild_after_adapt

Return type:

None

describe_global_dofs(self) → tuple[numpy.ndarray[dtype=int32], list[str]]

Returns a classification of the problem’s degrees of freedom by this mesh: one entry per global equation number giving the index of its dof type on this mesh (-1 for the dofs this mesh does not carry), plus the human-readable type names those indices refer to. Under MPI only the dofs this rank’s own elements reach are classified, but the type names come from the mesh’s own code and are therefore the same on every rank, including one that holds no element of this mesh at all

Return type:

tuple[NDArray[int32], list[str]]

describe_my_dofs(self, indent: str = '') → str

Returns a human-readable description of all degrees of freedom of this mesh, useful for debugging

Return type:

str

element_pt(self, element_index: int) → pyoomph._pyoomph_core.OomphGeneralisedElement

Returns the element at the given index in this mesh

Return type:

OomphGeneralisedElement

ensure_external_data(self) → None

Ensures that all external Data dependencies (dofs owned by other elements/meshes) required by this mesh’s elements are properly registered

Return type:

None

ensure_halos_for_periodic_boundaries(self) → None

In parallel (MPI) runs, ensures that the required halo elements/nodes are present so periodic boundary conditions also work across processor boundaries

Return type:

None

evaluate_at_points(self, coords: collections.abc.Sequence[collections.abc.Sequence[float]], lagrangian: bool = True, with_position: bool = False, time_level: int = 0) → list[list[float]]

Locate points in this mesh and evaluate its fields there, returning one row per point: [found, continuous fields…, DL fields…, D0 fields…, position…]. The continuous block follows the mesh’s own nodal field index order. An unlocated point yields the single entry [0.0].

Return type:

list[list[float]]

evaluate_local_expression_at_nodes(self, expression_index: int, nondimensional: bool, discontinuous: bool) → numpy.ndarray[dtype=float64]

Evaluates a local (element-defined) expression, identified by its index, at every node of this mesh

Return type:

NDArray[float64]

evaluate_maximum(name, dimensional=True, as_float=False, return_x=False)[source]

Evaluate the maximum of a quantity defined by ExtremumObservables on the mesh.

Parameters:
  • name (str | list[str]) – The name of the observable or a list of names

  • dimensional (bool) – If True, return the value(s) with units, otherwise return float(s)

  • as_float (bool) – If True, return the value(s) as float(s) (without units)

  • return_x (bool) – If True, also return the position(s) of the maximum(s)

Return type:

Expression | GiNaC_GlobalParam | int | float | Sequence[Expression | GiNaC_GlobalParam | int | float] | tuple[Expression | GiNaC_GlobalParam | int | float, Sequence[Expression | GiNaC_GlobalParam | int | float]]

Returns:

If return_x is False, returns the maximum value(s) as ExpressionOrNum or list of ExpressionOrNum. If return_x is True, returns a tuple of (maximum value(s), position(s)) where position(s) is a list of coordinates corresponding to the maximum value(s).

evaluate_minimum(name, dimensional=True, as_float=False, return_x=False)[source]

Evaluate the minimum of a quantity defined by ExtremumObservables on the mesh.

Parameters:
  • name (str | list[str]) – The name of the observable or a list of names

  • dimensional (bool) – If True, return the value(s) with units, otherwise return float(s)

  • as_float (bool) – If True, return the value(s) as float(s) (without units)

  • return_x (bool) – If True, also return the position(s) of the minimum(s)

Return type:

Expression | GiNaC_GlobalParam | int | float | Sequence[Expression | GiNaC_GlobalParam | int | float] | tuple[Expression | GiNaC_GlobalParam | int | float, Sequence[Expression | GiNaC_GlobalParam | int | float]]

Returns:

If return_x is False, returns the minimum value(s) as ExpressionOrNum or list of ExpressionOrNum. If return_x is True, returns a tuple of (minimum value(s), position(s)) where position(s) is a list of coordinates corresponding to the minimum value(s).

face_index_at_boundary(self, boundary_index: int, element_index: int) → int

Returns the local face/edge index at which the given boundary element touches the given mesh boundary

Return type:

int

fill_dof_types(self, dof_type_array: numpy.ndarray[dtype=int32]) → None

Fills the given numpy int array with a type tag for every degree of freedom of this mesh (used e.g. by block preconditioners)

Return type:

None

fill_node_index_to_node_map(self) → list[pyoomph._pyoomph_core.Node]

Returns the list of all nodes of this mesh, ordered consistently with the internal node-to-index map

Return type:

list[Node]

flush_element_storage(self) → None

Clears this mesh’s list of elements without deleting them (ownership is assumed to be transferred elsewhere)

Return type:

None

generate_interface_elements(self, boundary_name: str, interface_mesh: pyoomph._pyoomph_core.Mesh, jitcode: pyoomph._pyoomph_core.DynamicJITCode) → None

Creates interface elements attached to the given boundary of this (bulk) mesh, using the given compiled equation code, and adds them to the given interface mesh

Return type:

None

get_all_refinement_signatures(self) → tuple[numpy.ndarray[dtype=int64], numpy.ndarray[dtype=int32], numpy.ndarray[dtype=int32]]

The refinement tree of every root element this mesh holds, ascending by global index: the roots, the length of each one’s description, and the descriptions concatenated. A tree is described by a preorder walk of son counts (0 marks a leaf), i.e. by its shape rather than by oomph-lib’s level-wise element numbers, so it can be replayed on any partition

Return type:

tuple[NDArray[int64], NDArray[int32], NDArray[int32]]

get_boundary_index(self, boundary_name: str) → int

Returns the numeric index of the mesh boundary with the given name

Return type:

int

get_boundary_names(self) → list[str]

Returns the names of all boundaries of this mesh, ordered by their numeric index

Return type:

list[str]

get_boundary_zeta_period(self, boundary_index: int) → float

Period of the intrinsic boundary coordinate along this boundary, or 0 if it is not periodic.

Return type:

float

get_discontinuous_unrestored_elements(self) → list[int]

Indices of the elements whose own discontinuous fields the last transfer - after an adaptation or a remeshing - could neither take from the old mesh nor fill from a recovery expression (Equations.set_facet_recovery), i.e. the ones left at zero. Describes that last transfer, not the current values, so it is unchanged by a subsequent solve

Return type:

list[int]

get_element_dimension(self) → int

Returns the spatial dimension of the elements of this mesh

Return type:

int

get_element_node_indices(self) → tuple[numpy.ndarray[dtype=int32], int]

For every element, the indices of its nodes in this mesh’s node ordering, padded with -1 to the widest element. Returns the flat array and the stride

Return type:

tuple[NDArray[int32], int]

get_element_structural_keys(self) → numpy.ndarray[dtype=int64]

For every element, in local element order, the pair (index of its root element in the undistributed base mesh, packed path through the refinement tree) as a flat array of 2*nelement entries. This addresses an element independently of the partition; see assign_global_base_element_indices

Return type:

NDArray[int64]

get_elemental_errors(self) → numpy.ndarray[dtype=float64]

Returns the per-element spatial error estimate (as used by adaptive mesh refinement) for every element in this mesh; zero everywhere if adaptation is disabled

Return type:

NDArray[float64]

get_field_information(self) → dict[str, str]

Returns a description of all fields (nodal, discontinuous, elemental) available on this mesh

Return type:

dict[str, str]

get_full_domain_path(self) → str

Human-readable path of this mesh, e.g. ‘droplet’ or ‘droplet/interface’. Used in diagnostics, where a bare boundary index is not actionable.

Return type:

str

get_interface_element_structural_keys(self) → numpy.ndarray[dtype=int64]

For every element of this interface, in local element order, the triple (root element index in the undistributed base mesh, packed refinement path, face index in the bulk element) as a flat array of 3*nelement entries. A face element has no refinement tree of its own, so this addresses it through the bulk element it is attached to; the result is independent of the partition, which is what lets a state file written on one number of processes be read on another. Entries are -1 when the base element indices have not been assigned yet.

Return type:

NDArray[int64]

get_node_reordering(self, old_ordering: bool) → list[pyoomph._pyoomph_core.Node]

Returns the nodes of this mesh in the (potential) reordering used by reorder_nodes, without actually reordering the internal storage

Return type:

list[Node]

get_numpy_element_source_indices(self, tesselate_tri: bool, discontinuous: bool = False) → numpy.ndarray[dtype=int32]

For each element row that to_numpy produces with the same arguments, the index of the mesh element it stems from. The rows are sub-elements (with tesselate_tri, a quad yields two triangles, more if hanging neighbours require it), so they must not be zipped with element_pt() directly - use this to look up the element behind a row, e.g. to decide whether the row belongs to a halo element

Return type:

NDArray[int32]

get_opposite_interface_offset_vector(self) → list[float]

Returns the coordinate offset applied when matching this interface to its opposite side

Return type:

list[float]

get_output_scale(self, name: str) → float

Returns the output (dimensional rescaling) factor previously set for the field of the given name

Return type:

float

get_own_nodal_dg_fields(self) → list[str]

Names and spaces of the nodal discontinuous (D1/D2/…) fields this interface mesh declares itself, as opposed to the ones it merely reads from the bulk domain it sits on. Empty if there are none

Return type:

list[str]

get_refinement_pattern(self) → list[numpy.ndarray[dtype=uint32]]

Returns the refinement pattern of this (tree-based, refineable) mesh, i.e. for every refinement level the list of which base-mesh elements were split, allowing the pattern to be replayed via refine_base_mesh

Return type:

list[NDArray[uint32]]

get_shared_node_numpy_indices(self, proc: int) → numpy.ndarray[dtype=int32]

In parallel (MPI) runs, the row indices - in the node ordering used by to_numpy - of the nodes this mesh shares with process proc. Entry j is the same node as entry j of process proc’s own list for this rank, which makes this an exact node correspondence for merging the distributed mesh data into one global mesh. An entry is -1 if the shared node is not contained in this mesh (interface meshes take the scheme from their bulk mesh, and keep the -1 placeholders so the correspondence is not shifted). Empty on a non-distributed mesh

Return type:

NDArray[int32]

get_topology_generation(self) → int

The counter incremented by bump_topology_generation(); compare against a stored value to detect that cached element information has gone stale

Return type:

int

get_values_at_zetas(self, coords: numpy.ndarray[dtype=float64], with_scales: bool) → tuple[numpy.ndarray[dtype=float64], list[bool], dict[str, int]]

Interpolates all field values of this mesh at the given (N, dim) numpy array of intrinsic coordinates; returns the values, a mask of coordinates that could not be located, and a dict describing which field corresponds to which value column

Return type:

tuple[NDArray[float64], list[bool], dict[str, int]]

has_interface_dof_id(self, name: str) → int

Returns the index of the interface degree of freedom with the given name on this mesh, or -1 if not present

Return type:

int

has_periodic_nodes(self) → bool

Returns True if any node of this mesh is a periodic copy of another node, i.e. if a PeriodicBC or a periodic mesh template is in use

Return type:

bool

has_periodic_position_dofs(self) → bool

Returns True if a periodic copy node of this mesh has unknown (unpinned) positions, i.e. if periodic boundaries are combined with a moving mesh. Only meaningful after the equation numbers have been assigned

Return type:

bool

interpolate_discontinuous_data_from(self, old: pyoomph._pyoomph_core.Mesh) → None

Transfers this interface mesh’s own discontinuous fields - DL, D0 and the nodal DG spaces - including their time history, from the corresponding interface mesh of a superseded mesh after a remeshing. Elements that receive nothing are filled from their recovery expressions (Equations.set_facet_recovery) or else left at zero and listed by get_discontinuous_unrestored_elements()

Return type:

None

is_boundary_coordinate_defined(self, boundary_index: int) → bool

Returns whether an intrinsic boundary coordinate is defined and up to date for the given mesh boundary

Return type:

bool

is_mesh_distributed(self) → bool

Returns whether this mesh is distributed across multiple MPI processes

Return type:

bool

list_integral_functions(self) → list[str]

Returns the names of all integral (domain-averaged/summed) observable functions defined on this mesh

Return type:

list[str]

list_local_expressions(self) → list[str]

Returns the names of all local (per-element/per-node) observable expressions defined on this mesh

Return type:

list[str]

load_elemental_state(self, data: collections.abc.Sequence[float], lengths: collections.abc.Sequence[int]) → None

Restores what save_elemental_state wrote, in the same element order

Return type:

None

load_nodal_state(self, data: collections.abc.Sequence[float], lengths: collections.abc.Sequence[int]) → None

Restores what save_nodal_state wrote, in the same node_pt order

Return type:

None

locate_points(self, coords: collections.abc.Sequence[collections.abc.Sequence[float]], lagrangian: bool = True) → list[list[float]]

Locate points in this mesh, returning one row per point: [found, offset, s…]. Diagnostic access to the point locator; offset is the perpendicular distance for codimension-1 (projection) meshes and 0 for exact inversion.

Return type:

list[list[float]]

map_nodes_on_macro_elements(self) → None

Updates the nodal positions of every element that has a macro element from that macro element’s mapping

Return type:

None

property max_keep_unrefined

Number of adaptation cycles for which an element flagged for unrefinement is kept before it is actually unrefined

property max_permitted_error

Upper threshold of the per-element spatial error estimate above which elements are refined during adaptation

property max_refinement_level

Maximum refinement level (tree depth) that adaptive mesh refinement is allowed to reach on this mesh

property min_permitted_error

Lower threshold of the per-element spatial error estimate below which elements are unrefined during adaptation

property min_refinement_level

Minimum refinement level (tree depth) that adaptive mesh unrefinement is allowed to go below on this mesh

nboundary(self) → int

Returns the number of boundaries of this mesh

Return type:

int

nboundary_element(self, boundary_index: int) → int

Returns the number of elements adjacent to the given mesh boundary

Return type:

int

nboundary_node(self, boundary_index: int) → int

Returns the number of nodes on the given mesh boundary

Return type:

int

nelement(self) → int

Returns the number of elements in this mesh

Return type:

int

nnode(self) → int

Returns the number of nodes in this mesh

Return type:

int

nodal_interpolate_along_boundary(self, old_mesh: pyoomph._pyoomph_core.Mesh, boundary_index: int, old_boundary_index: int, interface_mesh: pyoomph._pyoomph_core.Mesh, old_interface_mesh: pyoomph._pyoomph_core.Mesh, boundary_max_dist: float, only_interface_fields: bool = False) → None

Interpolates the nodal field values of the nodes on a boundary of this mesh from the corresponding boundary of an old mesh, using the interface meshes to also interpolate interface-only fields; boundary_max_dist limits how far a node may be from the boundary line/surface to still be considered. With only_interface_fields=True, only the dofs the interface mesh adds on top of the bulk are transferred and the bulk fields are left untouched - what the codimension-2 pass needs, since the per-boundary passes have already interpolated the bulk fields on those nodes and this routine matches by nearest node rather than interpolating.

Return type:

None

nodal_interpolate_from(self, old_mesh: pyoomph._pyoomph_core.Mesh, boundary_index: int = -1, use_boundary_coordinate: bool = True, only_interface_fields: bool = False) → None

Interpolates all nodal field values of this mesh from the given old mesh (e.g. after adaptive remeshing), optionally restricted to a single boundary. On a boundary, use_boundary_coordinate=False matches by projecting onto the old interface geometry instead of through its zeta coordinate, which is what a 2d interface in 3d requires since it has no chart. With only_interface_fields=True, only the dofs the interface adds on top of the bulk are written and the bulk fields, position history and Lagrangian coordinates are left alone - for a chart that deliberately does not follow the geometry, such as the one carrying surface fields across a pinch-off.

Return type:

None

node_pt(self, node_index: int) → pyoomph._pyoomph_core.Node

Returns the node at the given index in this mesh

Return type:

Node

nodes()[source]

The nodes of this interface, each once, in the order the elements first reach them.

An interface mesh has no Node_pt array of its own, so the nodes have to be collected from the elements. Collecting them in a set made the yielded order the id() order of the Node objects, i.e. their allocation addresses: reproducible within one process, but different on every MPI rank and between two runs. Callers that pair this order with anything else broke silently - update_history() indexes evaluate_local_expression_at_nodes(), which is in the C++ node order, and the preCICE adapter numbers its coupling vertices by it. The dict is only a set that keeps insertion order.

Return type:

Iterator[Node]

nrefined(self) → int

Returns the number of elements that were refined during the last adaptation step

Return type:

int

nroot_halo_element(self) → int

In parallel (MPI) runs, returns the number of root (non-refined) halo elements of this mesh

Return type:

int

nullify_selected_bulk_dofs(self) → None

Nullifies the contribution of selected bulk degrees of freedom that are being superseded by this interface’s own degrees of freedom

Return type:

None

nunrefined(self) → int

Returns the number of elements that were unrefined during the last adaptation step

Return type:

int

output_paraview(self, filename: str, order: int) → None

Writes this mesh to a ParaView-compatible file at the given polynomial output order

Return type:

None

prepare_interpolation(self) → None

Builds the internal spatial search structures (e.g. a kd-tree) required for interpolating field values on this mesh

Return type:

None

prepare_zeta_interpolation(self, old_mesh: pyoomph._pyoomph_core.Mesh) → None

Prepares the internal data structures required to interpolate field values from an old mesh onto this (typically newly adapted) mesh

Return type:

None

prune_dead_nodes(self, with_bounds: bool) → None

Removes nodes marked as obsolete (e.g. after adaptive unrefinement) from the mesh; if with_bounds is False, boundary membership bookkeeping is skipped

Return type:

None

rebuild_after_adapt(self) → None

Regenerates this interface mesh’s elements after the adjacent bulk mesh has been adapted

Return type:

None

refine_base_mesh(self, refinement_pattern: collections.abc.Sequence[collections.abc.Sequence[int]]) → None

Replays a refinement pattern (as returned by get_refinement_pattern) on the base mesh, e.g. to restore a checkpointed mesh

Return type:

None

refine_selected_elements_by_index(self, element_indices: collections.abc.Sequence[int]) → None

Refines (splits) the elements with the given local indices by one level. Used to replay a refinement signature

Return type:

None

remove_boundary_nodes(self) → None

Removes all nodes from all mesh boundaries (i.e. clears the boundary node lookup, without deleting the nodes themselves)

Return type:

None

remove_boundary_nodes_of_bound(self, boundary_index: int) → None

Removes all nodes from the given mesh boundary (without deleting the nodes themselves)

Return type:

None

reorder_nodes(self, old_ordering: bool) → None

Reorders the internal node storage of this mesh (e.g. to improve cache locality/bandwidth of the resulting linear system)

Return type:

None

resolve_copy_master_node(self, node: pyoomph._pyoomph_core.Node) → pyoomph._pyoomph_core.Node

If the given node is a copy (e.g. due to periodic boundaries), returns its master node; otherwise returns None

Return type:

Node

save_elemental_state(self) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32]]

Serializes every element’s internal data (all history levels) and its geometric reference scalars, in element order

Return type:

tuple[NDArray[float64], NDArray[int32]]

save_nodal_state(self) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32]]

Serializes every node’s positions (all history levels), Lagrangian coordinates and values (all history levels) in node_pt order, returning the flat data and the per-node block length. Unlike _save_state this ordering can be addressed from outside, which is what state files of distributed problems need

Return type:

tuple[NDArray[float64], NDArray[int32]]

set_boundary_zeta_period(self, boundary_index: int, period: float) → None

Declare the intrinsic boundary coordinate along this boundary periodic with the given period (0 to clear). Required for a closed interface loop, whose zeta otherwise has a seam element spanning the entire range.

Return type:

None

set_initial_condition(self, fieldname: str, expression: pyoomph._pyoomph_core.Expression) → None

Sets the initial condition expression for the given field on this mesh

Return type:

None

set_lagrangian_nodal_coordinates(self) → None

Sets the Lagrangian (undeformed/reference) coordinates of all nodes to their current Eulerian coordinates

Return type:

None

set_opposite_interface_offset_vector(self, offset: collections.abc.Sequence[float]) → None

Sets a constant coordinate offset applied when matching this interface to its opposite side (e.g. for periodic geometries)

Return type:

None

set_output_scale(self, name: str, scale: pyoomph._pyoomph_core.Expression, jitcode: pyoomph._pyoomph_core.DynamicJITCode) → None

Sets an output (dimensional rescaling) factor for the field of the given name, used e.g. when exporting to numpy/VTK

Return type:

None

set_report_interpolation_timing = <nanobind.nb_func object>
set_spatial_error_estimator_pt(self, error_estimator: pyoomph._pyoomph_core.Z2ErrorEstimator) → None

Assigns the Z2ErrorEstimator used to drive adaptive mesh refinement on this mesh

Return type:

None

setup_Dirichlet_conditions(self, only_update_values: bool) → None

(Re-)applies all Dirichlet boundary conditions defined on this mesh; if only_update_values is True, the set of pinned dofs is left unchanged and only their prescribed values are updated

Return type:

None

setup_initial_conditions(self, resetting_first_step: bool, ic_name: str) → None

Applies the initial condition(s) with the given name to this mesh; resetting_first_step indicates whether this is done for the very first time step

Return type:

None

setup_interior_boundary_elements(self, boundary_index: int) → None

Sets up the boundary-element lookup for an interior (non-outer) boundary of a templated mesh

Return type:

None

to_numpy(self, tesselate_tri: bool, nondimensional: bool, history_index: int = 0, discontinuous: bool = False) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32], numpy.ndarray[dtype=int32], dict[str, int], numpy.ndarray[dtype=float64], numpy.ndarray[dtype=float64], dict[str, int]]

Exports this mesh’s nodal positions/fields, element connectivity, discontinuous and elemental fields as numpy arrays, together with dicts describing which array column corresponds to which field. tesselate_tri splits e.g. quads into triangles for plotting, nondimensional selects dimensional or non-dimensional output, history_index the time level, and discontinuous whether discontinuous fields are stored per-node (interpolated) or per-element

Return type:

tuple[NDArray[float64], NDArray[int32], NDArray[int32], dict[str, int], NDArray[float64], NDArray[float64], dict[str, int]]

update_equation_remapping(self) → None

Updates the mapping between this interface’s local equation numbers and the global equation numbers after the dof numbering has changed

Return type:

None

update_zeta_in_buffer(self) → None

Updates the buffered intrinsic (zeta) coordinates of the interface nodes, used for locating the opposite side of a two-sided interface

Return type:

None

class pyoomph.meshes.mesh.MeshTemplate[source]

Bases: MeshTemplate

A class to construct meshes by defining nodes with the add_node() or add_node_unique() method. Elements must be specified by first creating one or multiple domains with the new_domain() method and adding elements on each domain. Nodes can be also marked to be on particular boundaries with the add_facet_to_boundary() method.

add_facet_to_boundary(self, boundary_name: str, all_node_indices: collections.abc.Sequence[int], vertex_node_indices: collections.abc.Sequence[int] = [], curved_entity: pyoomph._pyoomph_core.MeshTemplateCurvedEntityBase | None = None) → None

Adds a list of nodes, i.e. a facet, to a boundary. Must pass all nodes of the facet, the vertex nodes and a potential curved entity for MacroElements

Return type:

None

add_facet_to_curve_entity(self, node_indices: collections.abc.Sequence[int], curved_entity: pyoomph._pyoomph_core.MeshTemplateCurvedEntityBase | None = None) → None
Return type:

None

add_node(self, x: float, y: float = 0.0, z: float = 0.0) → int

Adds a node at the given position. Creates overlapping nodes, if there is already a node at this position.

Return type:

int

add_node_unique(self, x: float, y: float = 0.0, z: float = 0.0) → int

Adds a node at the given position. If there is already a node at this position,no new node is created

Return type:

int

add_nodes_to_boundary(self, boundary_name: str, node_indices: collections.abc.Sequence[int]) → None
Return type:

None

create_curved_entity(typ, *args, **kwargs)[source]

Creates a curved entity, i.e. the exact geometry that facets of this mesh lie on. Nodes created by spatial refinement are then placed on that geometry instead of on the straight-sided interpolation between the coarse mesh’s nodes.

Supported types, with the arguments each expects (points may be given either as node indices or as coordinate lists):

  • "circle_arc": the arc’s start and end as positional arguments, plus center.

  • "sphere_part": one point_on_sphere as positional argument, plus center. The parametrisation is the outward unit normal, so a patch may be of any size short of half the sphere and may contain the poles.

  • "cylinder_arc": the arc’s start and end as positional arguments, plus center. The cylinder’s axis follows from those three points.

Parameters:
  • typ (str) – One of "circle_arc", "sphere_part", "cylinder_arc".

  • args (Any) – Positional arguments for the curved entity, as listed above.

  • kwargs (Any) – Keyword arguments for the curved entity, in particular center.

Return type:

MeshTemplateCurvedEntityBase

Returns:

The created curved entity to be used in add_facet_to_boundary().

define_geometry()[source]

This method must be specialized in a derived class to define the geometry, i.e. the nodes, domains and elements of the mesh.

Return type:

None

get_node_position(self, node_index: int) → list[float]

Returns the position [x, y, z] of the node at the given index of this template

Return type:

list[float]

has_domain(name)[source]

Test if a domain with the given name is available, i.e. constructed with new_domain() before.

Return type:

bool

max_permitted_error

The maximum permitted error for the spatial error estimator. If None, we use the value from the Problem object.

max_refinement_level

The maximum refinement level for spatial adaptivity. If None, we use the value from the Problem object.

min_permitted_error

The minimum permitted error for the spatial error estimator. If None, we use the value from the Problem object.

min_refinement_level

The minimum refinement level for spatial adaptivity. If None, we use the value from the Problem object.

new_domain(name, nodal_dimension=None)[source]

Create a new domain with the given name. With the help of this domain, elements can be added to the mesh.

Return type:

MeshTemplateElementCollection

nondim_size(a)[source]

Nondimensionalize a coordinate or a length scale by dividing by the spatial scale of the problem.

Parameters:

a (Expression | GiNaC_GlobalParam | int | float | list[Expression | GiNaC_GlobalParam | int | float]) – The coordinate or length scale to nondimensionalize.

Return type:

float | list[float]

Returns:

The arguments divided by the spatial scale of the problem.

remesher: RemesherBase | None

Must be set to allow for remeshing.

class pyoomph.meshes.mesh.MeshedMeshTemplate[source]

Bases: MeshTemplate

Base class of all MeshTemplate classes that let an external mesh generator (e.g. Gmsh) create the mesh from a geometry description given in define_geometry().

Since the geometry is described by a method that can be called again at any time, remeshing is done by recreation: a RemesherViaRecreation is attached by default, which calls define_geometry() again whenever remeshing is required. It is therefore up to you to describe both the initial and the remeshed geometry in that single method: use is_remeshing() (or its complement is_first_time()) to distinguish the two cases and get_boundary_coordinates() to reconstruct the boundaries that have moved meanwhile.

A define_geometry() that never asks either of the two would describe the very same geometry again, i.e. recreating it cannot give a different mesh. Such a template is therefore skipped when force_remesh() gathers the meshes to remesh by itself, but not when it is asked for this particular mesh, e.g. by a RemeshWhen.

If you prefer the mesh generator to reconstruct the geometry automatically from the deformed mesh, overwrite the remesher attribute by e.g. a Remesher2d instead.

Note

On a mesh distributed with --distribute, define_geometry() is a collective region: get_boundary_coordinates() gathers the boundary from all ranks, since no rank holds more than its own part of it. Every rank must therefore reach the same calls, with the same arguments and in the same order - do not branch on the MPI rank inside define_geometry, and do not ask for a boundary on some ranks only. A define_geometry that raises on one rank is caught and turned into an error on all of them; one whose ranks disagree on which collectives to enter can only hang. See dev_docs/distributed_remeshing.md.

add_facet_to_boundary(self, boundary_name: str, all_node_indices: collections.abc.Sequence[int], vertex_node_indices: collections.abc.Sequence[int] = [], curved_entity: pyoomph._pyoomph_core.MeshTemplateCurvedEntityBase | None = None) → None

Adds a list of nodes, i.e. a facet, to a boundary. Must pass all nodes of the facet, the vertex nodes and a potential curved entity for MacroElements

Return type:

None

add_facet_to_curve_entity(self, node_indices: collections.abc.Sequence[int], curved_entity: pyoomph._pyoomph_core.MeshTemplateCurvedEntityBase | None = None) → None
Return type:

None

add_node(self, x: float, y: float = 0.0, z: float = 0.0) → int

Adds a node at the given position. Creates overlapping nodes, if there is already a node at this position.

Return type:

int

add_node_unique(self, x: float, y: float = 0.0, z: float = 0.0) → int

Adds a node at the given position. If there is already a node at this position,no new node is created

Return type:

int

add_nodes_to_boundary(self, boundary_name: str, node_indices: collections.abc.Sequence[int]) → None
Return type:

None

create_curved_entity(typ, *args, **kwargs)

Creates a curved entity, i.e. the exact geometry that facets of this mesh lie on. Nodes created by spatial refinement are then placed on that geometry instead of on the straight-sided interpolation between the coarse mesh’s nodes.

Supported types, with the arguments each expects (points may be given either as node indices or as coordinate lists):

  • "circle_arc": the arc’s start and end as positional arguments, plus center.

  • "sphere_part": one point_on_sphere as positional argument, plus center. The parametrisation is the outward unit normal, so a patch may be of any size short of half the sphere and may contain the poles.

  • "cylinder_arc": the arc’s start and end as positional arguments, plus center. The cylinder’s axis follows from those three points.

Parameters:
  • typ (str) – One of "circle_arc", "sphere_part", "cylinder_arc".

  • args (Any) – Positional arguments for the curved entity, as listed above.

  • kwargs (Any) – Keyword arguments for the curved entity, in particular center.

Return type:

MeshTemplateCurvedEntityBase

Returns:

The created curved entity to be used in add_facet_to_boundary().

define_geometry()

This method must be specialized in a derived class to define the geometry, i.e. the nodes, domains and elements of the mesh.

Return type:

None

get_boundary_coordinates(name, sort_along_axis=None, start_near_point=None, nondimensional=False)[source]

Returns a list of boundary segments, which are lists of (x,y) coordinates (dimensional or not can be controlled by the nondimensional argument). The segments are sorted and reversed based on the sort_along_axis or start_near_point arguments. If both are None, the order is arbitrary.

On a mesh distributed with --distribute this is a collective call that returns the whole boundary on every rank, not just this rank’s part of it. Every rank must therefore reach it, with the same arguments and in the same order - see MeshedMeshTemplate.

Parameters:
  • name (str) – Name of the boundary, e.g. “domain1/boundary1”

  • sort_along_axis (Optional[Literal['x+', 'x-', 'y+', 'y-', 'z+', 'z-']]) – Sort the segments along a given axis, e.g. “x+” means sort along x in increasing order, “y-” means sort along y in decreasing order. Defaults to None.

  • start_near_point (tuple[Expression | GiNaC_GlobalParam | int | float, Expression | GiNaC_GlobalParam | int | float] | None) – Sort the segments by their distance to this point, closest first, and start each segment at its end closer to the point. May carry units. Defaults to None.

  • nondimensional (bool) – Whether to return nondimensional coordinates. Defaults to False.

Return type:

list[list[tuple[Expression | GiNaC_GlobalParam | int | float, Expression | GiNaC_GlobalParam | int | float]]]

Returns:

A list of boundary segments, which are each a list of (x,y) coordinates. These are plain floats only for nondimensional; otherwise they carry the spatial scaling and are therefore dimensional expressions.

get_node_position(self, node_index: int) → list[float]

Returns the position [x, y, z] of the node at the given index of this template

Return type:

list[float]

has_domain(name)

Test if a domain with the given name is available, i.e. constructed with new_domain() before.

Return type:

bool

is_first_time()[source]

Will return True, if the mesh is being generated for the first time. Otherwise, it will return False, which means that the mesh is being remeshed. You can use this to define different geometries for the initial mesh and the remeshed mesh.

May only be called from within define_geometry(), since only there the answer is meaningful.

Return type:

bool

Returns:

Whether it is the first time the mesh is generated or not. True means first time, False means remeshing.

is_remeshing()[source]

Complement of is_first_time(), i.e. True whenever define_geometry() is called to remesh an already existing mesh.

Return type:

bool

Returns:

Whether the mesh is currently being recreated for remeshing.

max_permitted_error

The maximum permitted error for the spatial error estimator. If None, we use the value from the Problem object.

max_refinement_level

The maximum refinement level for spatial adaptivity. If None, we use the value from the Problem object.

min_permitted_error

The minimum permitted error for the spatial error estimator. If None, we use the value from the Problem object.

min_refinement_level

The minimum refinement level for spatial adaptivity. If None, we use the value from the Problem object.

new_domain(name, nodal_dimension=None)

Create a new domain with the given name. With the help of this domain, elements can be added to the mesh.

Return type:

MeshTemplateElementCollection

nondim_size(a)

Nondimensionalize a coordinate or a length scale by dividing by the spatial scale of the problem.

Parameters:

a (Expression | GiNaC_GlobalParam | int | float | list[Expression | GiNaC_GlobalParam | int | float]) – The coordinate or length scale to nondimensionalize.

Return type:

float | list[float]

Returns:

The arguments divided by the spatial scale of the problem.

remesher: RemesherBase | None

Must be set to allow for remeshing.

class pyoomph.meshes.mesh.ODEStorageMesh(problem, eqtree, domainname)[source]

Bases: ODEStorageMesh

A sort of a mesh storing ODE values. This is not a real mesh, but a container for ODE values.

adapt_by_elemental_errors(self, elemental_errors: collections.abc.Sequence[float]) → None

Adapts (refines/unrefines) this mesh according to the given per-element spatial error estimate

Return type:

None

add_boundary_node(self, boundary_index: int, node: pyoomph._pyoomph_core.Node) → None

Adds the given node to the given mesh boundary

Return type:

None

add_interpolated_nodes_at(self, arg0: collections.abc.Sequence[collections.abc.Sequence[float]], arg1: bool, /) → list[pyoomph._pyoomph_core.Node]

Creates and adds new nodes interpolated at the given positions, used e.g. when refining or remeshing

Return type:

list[Node]

add_node_to_mesh(self, node: pyoomph._pyoomph_core.Node) → None

Adds an already-constructed node to this mesh’s list of nodes

Return type:

None

apply_additional_dof_constraints(self) → None

Applies any additional dof constraints that have been registered on this mesh’s nodes

Return type:

None

as_pyoomph_mesh(self) → pyoomph._pyoomph_core.Mesh

Downcasts this mesh to a pyoomph Mesh, if it is one (returns None otherwise)

Return type:

Mesh

assign_global_base_element_indices(self) → None

Numbers this mesh’s root (base) elements in their current order and stores the number on the elements themselves. Must be called before the problem is distributed, while the mesh still holds all of them: afterwards each process only sees its own share. The numbers address elements independently of the partition and are what makes state files interchangeable between serial and distributed runs

Return type:

None

boundary_coordinate_bool(self, boundary_index: int, value: bool = True) → None

Declares that an intrinsic boundary coordinate has been set up for the given mesh boundary. Pass value=False to take the declaration back. (This SETS the flag; is_boundary_coordinate_defined reads it.)

Return type:

None

boundary_element_pt(self, boundary_index: int, element_index: int) → pyoomph._pyoomph_core.OomphGeneralisedElement

Returns the element at the given index among the elements adjacent to the given mesh boundary

Return type:

OomphGeneralisedElement

boundary_node_pt(self, boundary_index: int, node_index: int) → pyoomph._pyoomph_core.Node

Returns the node at the given index among the nodes on the given mesh boundary

Return type:

Node

bump_topology_generation(self) → None

Announces that this mesh’s elements or their coordinates have changed, so that anything caching them (tracer particles, point locators) rebuilds before its next use

Return type:

None

check_halo_consistency(self, throw_on_mismatch: bool = False) → int

In parallel (MPI) runs, checks that all processes agree about the elements they share – their positions, refinement levels and pending refinement flags. Returns the number of inconsistencies found (0 if the processes agree), reporting details to stdout; pass throw_on_mismatch to raise instead. Collective: every process must call it. Returns 0 on a mesh that is not distributed.

Return type:

int

check_integrity(self) → None

Runs internal consistency checks on this mesh, raising an error if a problem is found

Return type:

None

clear_additional_dof_constraints(self) → None

Clears any additional dof constraints (e.g. from remeshing) that have been applied to this mesh’s nodes

Return type:

None

describe_global_dofs(self) → tuple[numpy.ndarray[dtype=int32], list[str]]

Returns a classification of the problem’s degrees of freedom by this mesh: one entry per global equation number giving the index of its dof type on this mesh (-1 for the dofs this mesh does not carry), plus the human-readable type names those indices refer to. Under MPI only the dofs this rank’s own elements reach are classified, but the type names come from the mesh’s own code and are therefore the same on every rank, including one that holds no element of this mesh at all

Return type:

tuple[NDArray[int32], list[str]]

describe_my_dofs(self, indent: str = '') → str

Returns a human-readable description of all degrees of freedom of this mesh, useful for debugging

Return type:

str

element_pt(self, element_index: int) → pyoomph._pyoomph_core.OomphGeneralisedElement

Returns the element at the given index in this mesh

Return type:

OomphGeneralisedElement

ensure_external_data(self) → None

Ensures that all external Data dependencies (dofs owned by other elements/meshes) required by this mesh’s elements are properly registered

Return type:

None

ensure_halos_for_periodic_boundaries(self) → None

In parallel (MPI) runs, ensures that the required halo elements/nodes are present so periodic boundary conditions also work across processor boundaries

Return type:

None

evaluate_at_points(self, coords: collections.abc.Sequence[collections.abc.Sequence[float]], lagrangian: bool = True, with_position: bool = False, time_level: int = 0) → list[list[float]]

Locate points in this mesh and evaluate its fields there, returning one row per point: [found, continuous fields…, DL fields…, D0 fields…, position…]. The continuous block follows the mesh’s own nodal field index order. An unlocated point yields the single entry [0.0].

Return type:

list[list[float]]

evaluate_local_expression_at_nodes(self, expression_index: int, nondimensional: bool, discontinuous: bool) → numpy.ndarray[dtype=float64]

Evaluates a local (element-defined) expression, identified by its index, at every node of this mesh

Return type:

NDArray[float64]

face_index_at_boundary(self, boundary_index: int, element_index: int) → int

Returns the local face/edge index at which the given boundary element touches the given mesh boundary

Return type:

int

fill_dof_types(self, dof_type_array: numpy.ndarray[dtype=int32]) → None

Fills the given numpy int array with a type tag for every degree of freedom of this mesh (used e.g. by block preconditioners)

Return type:

None

fill_node_index_to_node_map(self) → list[pyoomph._pyoomph_core.Node]

Returns the list of all nodes of this mesh, ordered consistently with the internal node-to-index map

Return type:

list[Node]

flush_element_storage(self) → None

Clears this mesh’s list of elements without deleting them (ownership is assumed to be transferred elsewhere)

Return type:

None

generate_interface_elements(self, boundary_name: str, interface_mesh: pyoomph._pyoomph_core.Mesh, jitcode: pyoomph._pyoomph_core.DynamicJITCode) → None

Creates interface elements attached to the given boundary of this (bulk) mesh, using the given compiled equation code, and adds them to the given interface mesh

Return type:

None

get_all_refinement_signatures(self) → tuple[numpy.ndarray[dtype=int64], numpy.ndarray[dtype=int32], numpy.ndarray[dtype=int32]]

The refinement tree of every root element this mesh holds, ascending by global index: the roots, the length of each one’s description, and the descriptions concatenated. A tree is described by a preorder walk of son counts (0 marks a leaf), i.e. by its shape rather than by oomph-lib’s level-wise element numbers, so it can be replayed on any partition

Return type:

tuple[NDArray[int64], NDArray[int32], NDArray[int32]]

get_boundary_index(self, boundary_name: str) → int

Returns the numeric index of the mesh boundary with the given name

Return type:

int

get_boundary_names(self) → list[str]

Returns the names of all boundaries of this mesh, ordered by their numeric index

Return type:

list[str]

get_boundary_zeta_period(self, boundary_index: int) → float

Period of the intrinsic boundary coordinate along this boundary, or 0 if it is not periodic.

Return type:

float

get_element_dimension(self) → int

Returns the spatial dimension of the elements of this mesh

Return type:

int

get_element_node_indices(self) → tuple[numpy.ndarray[dtype=int32], int]

For every element, the indices of its nodes in this mesh’s node ordering, padded with -1 to the widest element. Returns the flat array and the stride

Return type:

tuple[NDArray[int32], int]

get_element_structural_keys(self) → numpy.ndarray[dtype=int64]

For every element, in local element order, the pair (index of its root element in the undistributed base mesh, packed path through the refinement tree) as a flat array of 2*nelement entries. This addresses an element independently of the partition; see assign_global_base_element_indices

Return type:

NDArray[int64]

get_elemental_errors(self) → numpy.ndarray[dtype=float64]

Returns the per-element spatial error estimate (as used by adaptive mesh refinement) for every element in this mesh; zero everywhere if adaptation is disabled

Return type:

NDArray[float64]

get_field_information(self) → dict[str, str]

Returns a description of all fields (nodal, discontinuous, elemental) available on this mesh

Return type:

dict[str, str]

get_full_domain_path(self) → str

Human-readable path of this mesh, e.g. ‘droplet’ or ‘droplet/interface’. Used in diagnostics, where a bare boundary index is not actionable.

Return type:

str

get_node_reordering(self, old_ordering: bool) → list[pyoomph._pyoomph_core.Node]

Returns the nodes of this mesh in the (potential) reordering used by reorder_nodes, without actually reordering the internal storage

Return type:

list[Node]

get_numpy_element_source_indices(self, tesselate_tri: bool, discontinuous: bool = False) → numpy.ndarray[dtype=int32]

For each element row that to_numpy produces with the same arguments, the index of the mesh element it stems from. The rows are sub-elements (with tesselate_tri, a quad yields two triangles, more if hanging neighbours require it), so they must not be zipped with element_pt() directly - use this to look up the element behind a row, e.g. to decide whether the row belongs to a halo element

Return type:

NDArray[int32]

get_output_scale(self, name: str) → float

Returns the output (dimensional rescaling) factor previously set for the field of the given name

Return type:

float

get_refinement_pattern(self) → list[numpy.ndarray[dtype=uint32]]

Returns the refinement pattern of this (tree-based, refineable) mesh, i.e. for every refinement level the list of which base-mesh elements were split, allowing the pattern to be replayed via refine_base_mesh

Return type:

list[NDArray[uint32]]

get_shared_node_numpy_indices(self, proc: int) → numpy.ndarray[dtype=int32]

In parallel (MPI) runs, the row indices - in the node ordering used by to_numpy - of the nodes this mesh shares with process proc. Entry j is the same node as entry j of process proc’s own list for this rank, which makes this an exact node correspondence for merging the distributed mesh data into one global mesh. An entry is -1 if the shared node is not contained in this mesh (interface meshes take the scheme from their bulk mesh, and keep the -1 placeholders so the correspondence is not shifted). Empty on a non-distributed mesh

Return type:

NDArray[int32]

get_topology_generation(self) → int

The counter incremented by bump_topology_generation(); compare against a stored value to detect that cached element information has gone stale

Return type:

int

get_value(name, *, dimensional=True, as_float=False)[source]

Get the value(s) associated with the given name(s) from the ODE.

Parameters:
  • name (str | tuple[str] | list[str]) – The name(s) of the value(s) to retrieve.

  • dimensional (bool) – Whether to return the value(s) in dimensional form. Defaults to True.

  • as_float (bool) – Whether to return the value(s) as float(s). Defaults to False.

Returns:

The value(s) associated with the given name(s).

Return type:

Expression | float | tuple[float, ...] | tuple[Expression, ...]

Raises:

RuntimeError – If the ODE has no value with the given name(s).

get_values_at_zetas(self, coords: numpy.ndarray[dtype=float64], with_scales: bool) → tuple[numpy.ndarray[dtype=float64], list[bool], dict[str, int]]

Interpolates all field values of this mesh at the given (N, dim) numpy array of intrinsic coordinates; returns the values, a mask of coordinates that could not be located, and a dict describing which field corresponds to which value column

Return type:

tuple[NDArray[float64], list[bool], dict[str, int]]

has_interface_dof_id(self, name: str) → int

Returns the index of the interface degree of freedom with the given name on this mesh, or -1 if not present

Return type:

int

has_periodic_nodes(self) → bool

Returns True if any node of this mesh is a periodic copy of another node, i.e. if a PeriodicBC or a periodic mesh template is in use

Return type:

bool

has_periodic_position_dofs(self) → bool

Returns True if a periodic copy node of this mesh has unknown (unpinned) positions, i.e. if periodic boundaries are combined with a moving mesh. Only meaningful after the equation numbers have been assigned

Return type:

bool

is_boundary_coordinate_defined(self, boundary_index: int) → bool

Returns whether an intrinsic boundary coordinate is defined and up to date for the given mesh boundary

Return type:

bool

is_mesh_distributed(self) → bool

Returns whether this mesh is distributed across multiple MPI processes

Return type:

bool

list_integral_functions(self) → list[str]

Returns the names of all integral (domain-averaged/summed) observable functions defined on this mesh

Return type:

list[str]

list_local_expressions(self) → list[str]

Returns the names of all local (per-element/per-node) observable expressions defined on this mesh

Return type:

list[str]

load_elemental_state(self, data: collections.abc.Sequence[float], lengths: collections.abc.Sequence[int]) → None

Restores what save_elemental_state wrote, in the same element order

Return type:

None

load_nodal_state(self, data: collections.abc.Sequence[float], lengths: collections.abc.Sequence[int]) → None

Restores what save_nodal_state wrote, in the same node_pt order

Return type:

None

locate_points(self, coords: collections.abc.Sequence[collections.abc.Sequence[float]], lagrangian: bool = True) → list[list[float]]

Locate points in this mesh, returning one row per point: [found, offset, s…]. Diagnostic access to the point locator; offset is the perpendicular distance for codimension-1 (projection) meshes and 0 for exact inversion.

Return type:

list[list[float]]

map_nodes_on_macro_elements(self) → None

Updates the nodal positions of every element that has a macro element from that macro element’s mapping

Return type:

None

property max_keep_unrefined

Number of adaptation cycles for which an element flagged for unrefinement is kept before it is actually unrefined

property max_permitted_error

Upper threshold of the per-element spatial error estimate above which elements are refined during adaptation

property max_refinement_level

Maximum refinement level (tree depth) that adaptive mesh refinement is allowed to reach on this mesh

property min_permitted_error

Lower threshold of the per-element spatial error estimate below which elements are unrefined during adaptation

property min_refinement_level

Minimum refinement level (tree depth) that adaptive mesh unrefinement is allowed to go below on this mesh

nboundary(self) → int

Returns the number of boundaries of this mesh

Return type:

int

nboundary_element(self, boundary_index: int) → int

Returns the number of elements adjacent to the given mesh boundary

Return type:

int

nboundary_node(self, boundary_index: int) → int

Returns the number of nodes on the given mesh boundary

Return type:

int

nelement(self) → int

Returns the number of elements in this mesh

Return type:

int

nnode(self) → int

Returns the number of nodes in this mesh

Return type:

int

nodal_interpolate_along_boundary(self, old_mesh: pyoomph._pyoomph_core.Mesh, boundary_index: int, old_boundary_index: int, interface_mesh: pyoomph._pyoomph_core.Mesh, old_interface_mesh: pyoomph._pyoomph_core.Mesh, boundary_max_dist: float, only_interface_fields: bool = False) → None

Interpolates the nodal field values of the nodes on a boundary of this mesh from the corresponding boundary of an old mesh, using the interface meshes to also interpolate interface-only fields; boundary_max_dist limits how far a node may be from the boundary line/surface to still be considered. With only_interface_fields=True, only the dofs the interface mesh adds on top of the bulk are transferred and the bulk fields are left untouched - what the codimension-2 pass needs, since the per-boundary passes have already interpolated the bulk fields on those nodes and this routine matches by nearest node rather than interpolating.

Return type:

None

nodal_interpolate_from(self, old_mesh: pyoomph._pyoomph_core.Mesh, boundary_index: int = -1, use_boundary_coordinate: bool = True, only_interface_fields: bool = False) → None

Interpolates all nodal field values of this mesh from the given old mesh (e.g. after adaptive remeshing), optionally restricted to a single boundary. On a boundary, use_boundary_coordinate=False matches by projecting onto the old interface geometry instead of through its zeta coordinate, which is what a 2d interface in 3d requires since it has no chart. With only_interface_fields=True, only the dofs the interface adds on top of the bulk are written and the bulk fields, position history and Lagrangian coordinates are left alone - for a chart that deliberately does not follow the geometry, such as the one carrying surface fields across a pinch-off.

Return type:

None

node_pt(self, node_index: int) → pyoomph._pyoomph_core.Node

Returns the node at the given index in this mesh

Return type:

Node

nrefined(self) → int

Returns the number of elements that were refined during the last adaptation step

Return type:

int

nroot_halo_element(self) → int

In parallel (MPI) runs, returns the number of root (non-refined) halo elements of this mesh

Return type:

int

nunrefined(self) → int

Returns the number of elements that were unrefined during the last adaptation step

Return type:

int

output_paraview(self, filename: str, order: int) → None

Writes this mesh to a ParaView-compatible file at the given polynomial output order

Return type:

None

prepare_interpolation(self) → None

Builds the internal spatial search structures (e.g. a kd-tree) required for interpolating field values on this mesh

Return type:

None

prepare_zeta_interpolation(self, old_mesh: pyoomph._pyoomph_core.Mesh) → None

Prepares the internal data structures required to interpolate field values from an old mesh onto this (typically newly adapted) mesh

Return type:

None

prune_dead_nodes(self, with_bounds: bool) → None

Removes nodes marked as obsolete (e.g. after adaptive unrefinement) from the mesh; if with_bounds is False, boundary membership bookkeeping is skipped

Return type:

None

refine_base_mesh(self, refinement_pattern: collections.abc.Sequence[collections.abc.Sequence[int]]) → None

Replays a refinement pattern (as returned by get_refinement_pattern) on the base mesh, e.g. to restore a checkpointed mesh

Return type:

None

refine_selected_elements_by_index(self, element_indices: collections.abc.Sequence[int]) → None

Refines (splits) the elements with the given local indices by one level. Used to replay a refinement signature

Return type:

None

remove_boundary_nodes(self) → None

Removes all nodes from all mesh boundaries (i.e. clears the boundary node lookup, without deleting the nodes themselves)

Return type:

None

remove_boundary_nodes_of_bound(self, boundary_index: int) → None

Removes all nodes from the given mesh boundary (without deleting the nodes themselves)

Return type:

None

reorder_nodes(self, old_ordering: bool) → None

Reorders the internal node storage of this mesh (e.g. to improve cache locality/bandwidth of the resulting linear system)

Return type:

None

resolve_copy_master_node(self, node: pyoomph._pyoomph_core.Node) → pyoomph._pyoomph_core.Node

If the given node is a copy (e.g. due to periodic boundaries), returns its master node; otherwise returns None

Return type:

Node

save_elemental_state(self) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32]]

Serializes every element’s internal data (all history levels) and its geometric reference scalars, in element order

Return type:

tuple[NDArray[float64], NDArray[int32]]

save_nodal_state(self) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32]]

Serializes every node’s positions (all history levels), Lagrangian coordinates and values (all history levels) in node_pt order, returning the flat data and the per-node block length. Unlike _save_state this ordering can be addressed from outside, which is what state files of distributed problems need

Return type:

tuple[NDArray[float64], NDArray[int32]]

set_boundary_zeta_period(self, boundary_index: int, period: float) → None

Declare the intrinsic boundary coordinate along this boundary periodic with the given period (0 to clear). Required for a closed interface loop, whose zeta otherwise has a seam element spanning the entire range.

Return type:

None

set_initial_condition(self, fieldname: str, expression: pyoomph._pyoomph_core.Expression) → None

Sets the initial condition expression for the given field on this mesh

Return type:

None

set_lagrangian_nodal_coordinates(self) → None

Sets the Lagrangian (undeformed/reference) coordinates of all nodes to their current Eulerian coordinates

Return type:

None

set_output_scale(self, name: str, scale: pyoomph._pyoomph_core.Expression, jitcode: pyoomph._pyoomph_core.DynamicJITCode) → None

Sets an output (dimensional rescaling) factor for the field of the given name, used e.g. when exporting to numpy/VTK

Return type:

None

set_report_interpolation_timing = <nanobind.nb_func object>
set_spatial_error_estimator_pt(self, error_estimator: pyoomph._pyoomph_core.Z2ErrorEstimator) → None

Assigns the Z2ErrorEstimator used to drive adaptive mesh refinement on this mesh

Return type:

None

set_value(dimensional=True, **namvals)[source]

Set the current values of ODE variables.

Parameters:
  • dimensional (bool) – Flag indicating whether the values should be set in dimensional form. Defaults to True.

  • **namvals (Expression | GiNaC_GlobalParam | int | float) – Keyword arguments representing the names and values of the ODE variables to be set.

Raises:
  • RuntimeError – If the ODE variable does not exist.

  • RuntimeError – If the value cannot be converted to the required unit.

Return type:

None

Returns:

None

setup_Dirichlet_conditions(self, only_update_values: bool) → None

(Re-)applies all Dirichlet boundary conditions defined on this mesh; if only_update_values is True, the set of pinned dofs is left unchanged and only their prescribed values are updated

Return type:

None

setup_initial_conditions(self, resetting_first_step: bool, ic_name: str) → None

Applies the initial condition(s) with the given name to this mesh; resetting_first_step indicates whether this is done for the very first time step

Return type:

None

setup_interior_boundary_elements(self, boundary_index: int) → None

Sets up the boundary-element lookup for an interior (non-outer) boundary of a templated mesh

Return type:

None

to_numpy(self, tesselate_tri: bool, nondimensional: bool, history_index: int = 0, discontinuous: bool = False) → tuple[numpy.ndarray[dtype=float64], numpy.ndarray[dtype=int32], numpy.ndarray[dtype=int32], dict[str, int], numpy.ndarray[dtype=float64], numpy.ndarray[dtype=float64], dict[str, int]]

Exports this mesh’s nodal positions/fields, element connectivity, discontinuous and elemental fields as numpy arrays, together with dicts describing which array column corresponds to which field. tesselate_tri splits e.g. quads into triangles for plotting, nondimensional selects dimensional or non-dimensional output, history_index the time level, and discontinuous whether discontinuous fields are stored per-node (interpolated) or per-element

Return type:

tuple[NDArray[float64], NDArray[int32], NDArray[int32], dict[str, int], NDArray[float64], NDArray[float64], dict[str, int]]