Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pymrm.ibm_recon

Back to modules overview

One-sided normal-derivative operators for the pymrm immersed boundary method.

This module provides Layer 1 of the generalized immersed-interface coupling: for every wall crossing of an pymrm.ibm.IBM object it constructs, on each side separately, a linear formula for the outward normal derivative at the interface point,

.. math:: q_\text{side} ;=; \left.\frac{\partial c}{\partial n_\text{side}} \right|\Gamma ;\approx; \alpha\text{side}, c_\Gamma^\text{side} ;+; \sum_{j \in S_\text{side}} \gamma_j, c_j ,

where :math:c_\Gamma^\text{side} is the (generally unknown) one-sided interface value and :math:S_\text{side} contains nearby same-side cell centres. The weights are polynomially exact generalized finite-difference (GFD) weights obtained from a minimum-weighted-norm problem. These operators are the building blocks for general interface conditions (conjugate diffusion, partition coefficients, contact resistance, surface reactions) assembled in pymrm.ibm_coupling.

Sign conventions

Robustness / length-scale strategy

Stencil selection is governed by two caps: a geometric one (radius_factor * rings * h_local) and a physical one (length_scale_factor * length_scale). When too few good points are available inside the cap the polynomial degree is lowered instead of reaching farther: p=2 -> enlarge once -> p=1 -> two-point normal formula -> flagged unresolved. Candidate cells must be flood-fill connected to the cut cell through same-side cells, so points across a thin gap or a neighbouring solid are never used.

View module source on GitHub

Public API

SymbolTypeSummary
IBMNormalDerivativeclassOne-sided normal-derivative operators and diagnostics per IBM crossing.
construct_ibm_normal_derivativefunctionConstruct one-sided normal-derivative operators for every IBM crossing.
construct_ibm_normal_derivative_opsfunctionExpand the reconstruction operators to the full field layout.
gfd_normal_derivative_weightsfunctionGFD weights for a directional derivative at a single interface point.
interface_normalsfunctionUnit interface normals (solid -> fluid) at each wall crossing.

IBMNormalDerivative()

Open dedicated reference page

One-sided normal-derivative operators and diagnostics per IBM crossing.

The outward normal derivative on each side of crossing k is

``q_side[k] = alpha_side[k] * c_gamma_side[k] + (D_side @ c_spatial)[k]``

with c_spatial the field on the spatial grid (flattened, C-order) and the outward per side sign convention described in the module docstring.

Attributes

Shape information

n_crossings : int Number of wall crossings (matches ibm.n_crossings). spatial_shape : tuple Spatial grid shape. shape : tuple Full field shape (spatial + non-spatial axes). axes : tuple of int Which axes of shape are spatial. ns_size : int Product of the non-spatial dimensions (1 when purely spatial). n_cells : int Total number of cells, prod(shape). n_spatial_cells : int Number of spatial cells, prod(spatial_shape). h_ref : ndarray, shape (ndim_spatial,) Median cell-centre spacing along each spatial axis (reference scale for the GFD weights).

View source on GitHub

Members

D_in

View source on GitHub

D_out

View source on GitHub

alpha_in

View source on GitHub

alpha_out

View source on GitHub

axes

View source on GitHub

cond_in

View source on GitHub

cond_out

View source on GitHub

degree_in

View source on GitHub

degree_out

View source on GitHub

h_ref

View source on GitHub

moment_residual_in

View source on GitHub

moment_residual_out

View source on GitHub

n_cells

View source on GitHub

n_crossings

View source on GitHub

n_spatial_cells

View source on GitHub

n_stencil_in

View source on GitHub

n_stencil_out

View source on GitHub

normals

View source on GitHub

ns_size

View source on GitHub

radius_in

View source on GitHub

radius_out

View source on GitHub

shape

View source on GitHub

spatial_shape

View source on GitHub

unresolved_in

View source on GitHub

unresolved_out

View source on GitHub

weight_norm_in

View source on GitHub

weight_norm_out

View source on GitHub

construct_ibm_normal_derivative(ibm, sdf, x_c, *, degree = 2, length_scale = None, rings = 2, radius_factor = 1.0, length_scale_factor = 0.5, enlarge_factor = 1.5, min_points_factor = 1.5, weight_power = 4, interface_penalty = 1.0, cond_max = 100000000.0, moment_tol = 1e-08, weight_norm_max = 100.0, connectivity = 'flood', normals = None)

Open dedicated reference page

Construct one-sided normal-derivative operators for every IBM crossing.

Parameters

Returns

View source on GitHub

construct_ibm_normal_derivative_ops(ibm, recon)

Open dedicated reference page

Expand the reconstruction operators to the full field layout.

Returns operators acting on the flattened full field c (including non-spatial axes) with rows ordered k * ns_size + j for crossing k and non-spatial layer j — the same column ordering used by the G_out/G_in source matrices of pymrm.apply_ibm:

``q_side.ravel() = alpha_side_full * w_side + N_side @ c.ravel()``

Parameters

Returns

View source on GitHub

gfd_normal_derivative_weights(x_gamma, x_cells, direction, degree = 2, hvec = None, weight_power = 4, interface_penalty = 1.0)

Open dedicated reference page

GFD weights for a directional derivative at a single interface point.

Returns alpha, gamma and diagnostics such that

``dc/du|_Gamma ~= alpha * c_gamma + gamma @ c_cells``

is exact for all polynomials up to degree. This is the single-point convenience form of the batched kernel used by construct_ibm_normal_derivative; direction is the (not necessarily unit) derivative direction u.

Parameters

Returns

View source on GitHub

interface_normals(ibm, sdf, x_c)

Open dedicated reference page

Unit interface normals (solid -> fluid) at each wall crossing.

The cell-centred gradient of sdf is computed with numpy.gradient (non-equidistant aware) and averaged over the two cut cells of each crossing. Crossings with a degenerate gradient (kinks of the level set, e.g. near medial axes of thin solids) fall back to the axis-aligned normal of the crossing.

Parameters

Returns

View source on GitHub