dragonfly_sim.core.mesh_manager

Classes

BoundaryNodeSet

Owned nodes on tagged boundary facets, numbered globally in rank-block order.

Mesh

Module Contents

class dragonfly_sim.core.mesh_manager.BoundaryNodeSet

Owned nodes on tagged boundary facets, numbered globally in rank-block order.

Built by Mesh.boundary_node_set. local_idx are this rank’s OWNED geometry-node indices; they carry the global ids global_idx = offset + arange(n_local), so the ranks’ blocks tile [0, n_global) in rank order. coords and geom_gids (dolfinx global geometry ids) are replicated on every rank, row for row in that same order. shape_parameterization.WallFFD relies on this numbering.

coords: numpy.ndarray
geom_gids: numpy.ndarray
property global_idx
local_idx: numpy.ndarray
n_global: int
property n_local
offset: int
tags: tuple
class dragonfly_sim.core.mesh_manager.Mesh(inp_mesh, inner_bdry_function, node_match_tol=1e-10)
_check_vertex_geometry_numbering()

Owned vertex indices must equal owned geometry-node indices.

find_local_surface_nodes works in topology vertex indices, the facet connectivity in geometry node indices. For first-order meshes the two coincide over the OWNED range, and only that range is used, so the node sets and the connectivity stay consistent.

They do NOT coincide over the ghost range – every rank has a few hundred ghosts numbered differently in the two index spaces. That is fine: ghosts only enter through the facet connectivity, which is converted to global geometry ids via geometry.index_map().local_to_global before being used, and that map is valid for ghosts.

_global_bounding_box(coords)
_setup_quality()

DG0 fields for the quality metrics apply_node_motions reports.

_update_quality()

Evaluate, print and (if configured) write the quality metrics; set is_valid.

_wall_boundary_node_coords(wall_tag_value)
apply_node_motions(node_motions)

Move the mesh to baseline + node_motions and re-check its cells.

node_motions is (n_owned_nodes, gdim) in geometry-node order. Starting from the baseline makes the result depend on this call only, so repeated calls do not accumulate. Ghost nodes are updated from their owners. Sets is_valid (no inverted or zero-volume cell) and returns it. Collective.

boundary_node_set(tags, exclude=None)

Owned nodes on facets tagged with any of tags, numbered globally.

exclude (another BoundaryNodeSet) removes its nodes – e.g. the wall from the farfield anchors, so a node shared by both stays with the wall. See BoundaryNodeSet for the numbering. Cached per (tags, exclude), so every caller gets the same numbering. Collective on first call; requires tag_boundary_facets.

compute_wall_bounding_box(wall_tag_value)
configure_output(suffix, deformation=True, quality=False)

Enable the per-evaluation mesh output files, named with suffix.

deformation writes mesh_deformation_<suffix>.bp (through write_deformation_output); quality writes the DG0 quality fields mesh_{vol,jac,min_edge,max_edge,cell_aspect_ratio}_<suffix>.bp on every apply_node_motions. suffix also names the memory logs of the classes that use this mesh. Collective.

facet_cell_midpoints(facets)

(n_facets, 3) midpoint of the single cell attached to each exterior facet.

static newell_normals(face_coords)

Newell’s method: (n_faces, k, 3) -> (n_faces, 3), twice the area vector.

nodal_function(node_values)

An (n_owned_nodes, gdim) nodal array as a Function on coordinate_space.

The Function is reused between calls.

static orient_facets(conn, coords, cell_mids)

Reverse the traversal of faces whose Newell normal points into the fluid.

After this every face normal points out of its adjacent fluid cell. DOLFINx orders facet vertices from the sorted global vertex numbering, which fixes neither the traversal order nor a consistent winding. Measured on the 3D wing mesh: without this, only ~51% of facets come out consistently oriented. Returns (conn, n_flipped).

reset_nodes()

Put every local node, ghosts included, back at its baseline position.

tag_boundary_facets(bdry_facet_value_tuples)
tagged_facets(tags, node_gids)

This rank’s OWNED facets tagged with any of tags, as node-id rows.

A node id is the node’s position in node_gids, a replicated array of global geometry ids (a BoundaryNodeSet’s geom_gids, or several concatenated). Quad facets come back in cyclic vertex order. Only owned facets are taken: a facet shared between two ranks appears in both ranks’ meshtags, and counting it twice would double it.

Returns (conn, facets): (n_facets, nodes_per_facet) int64 node ids and the local facet indices.

wall_facets(wall_tag)

Replicated wall facets as rows of wall node ids in [0, n_global).

Node ids are the boundary_node_set((wall_tag,)) numbering. Segments in 2D, triangles or quads (cyclic vertex order) in 3D, in rank order, so every rank holds the same array. Consistently wound: the facet normal – Newell’s in 3D, (dy, -dx) of the traversal in 2D – points out of the adjacent fluid cell, i.e. into the body. Collective.

write_deformation_output(node_motions, write_counter)

Write (n_owned_nodes, gdim) node motions to mesh_deformation_<suffix>.bp.

A no-op unless configure_output enabled it. Called once per design evaluation with write_counter = eval_idx, so this file and the solution file share one index axis.

_QUAD_CYCLIC_PERM
_coordinate_space = None
_deformation_writer = None
_dof_to_node_map = None
_nodal_function = None
_node_sets
_quality = None
_quality_writers = None
baseline_nodes
bdry_facets
bdry_midpoints
cell_volume
property coordinate_space

Vector CG1 space whose dofs coincide with the geometry nodes.

The space mesh-coordinate derivatives (dR/dx_mesh) are taken in. Built on first use.

property dof_to_node_map

(owned CG1 dofs) x (owned geometry nodes) 0/1 permutation matrix.

The CG1 vector dofs correspond 1:1 with the geometry nodes but are numbered differently: dof_to_node_map @ node_values reorders an (n_owned_nodes, gdim) nodal array into dof order, and its transpose maps dof-ordered derivatives back to geometry-node order. Matched by coordinates within node_match_tol – an exact-match test with room for round-off. Built on first use.

form_manager
h_vol
inner_bdry_facet_mask
is_valid = True
mesh
meshtags = None
n
n_owned_nodes
node_match_tol = 1e-10
output_suffix = None