Helpers#

Weakform Helpers#

WeakForm/Expr helpers (symbolic operators).

fluxfem.helpers_wf.I(dim: int) Expr#

Identity matrix of size dim.

fluxfem.helpers_wf.action(v, s) Expr#

Test-function action: v.val * s -> (q, n_ldofs).

fluxfem.helpers_wf.dOmega() Expr#

Volume quadrature measure (w * detJ).

fluxfem.helpers_wf.ddot(a, b, c=None) Expr#

Double contraction or a^T b c.

fluxfem.helpers_wf.det(a) Expr#

Determinant of a square matrix.

fluxfem.helpers_wf.dot(a, b) Expr#

Dot product or vector load helper.

fluxfem.helpers_wf.ds() Expr#

Surface quadrature measure (w * detJ).

fluxfem.helpers_wf.gaction(v, q) Expr#

Gradient action: v.grad · q -> (q, n_ldofs).

fluxfem.helpers_wf.grad(field) Expr#

Return basis gradients for a scalar or vector FormField.

fluxfem.helpers_wf.inner(a, b) Expr#

Inner product over the last axis (tensor-level).

fluxfem.helpers_wf.inv(a) Expr#

Matrix inverse.

fluxfem.helpers_wf.linear_stress(sym_grad_u, p)#

Linear elastic stress from symmetric gradient in Voigt notation.

fluxfem.helpers_wf.log(a) Expr#

Natural logarithm.

fluxfem.helpers_wf.matmul(a, b) Expr#

FEM-specific batched contraction (same semantics as @).

fluxfem.helpers_wf.matmul_std(a, b) Expr#

Standard matrix product (jnp.matmul semantics).

fluxfem.helpers_wf.normal() Expr#

Surface normal vector (from SurfaceFormContext).

fluxfem.helpers_wf.outer(a, b) Expr#

Outer product of scalar fields: outer(v, u) (test, trial).

fluxfem.helpers_wf.sdot(a, b) Expr#

Surface dot product or vector load helper.

fluxfem.helpers_wf.sym_grad(field) Expr#

Return symmetric-gradient B-matrix for a vector FormField.

fluxfem.helpers_wf.traction(field, n, p)#

Traction vector for a field using linear elastic stress.

fluxfem.helpers_wf.transpose(a) Expr#

Swap the last two axes.

fluxfem.helpers_wf.transpose_last2(a) Expr#

Swap the last two axes.

fluxfem.helpers_wf.voigt_to_tensor(sym_grad_u, p=None)#

Convert Voigt-form symmetric gradient to a 3x3 tensor.

Uses the standard Voigt mapping with 1/2 on shear terms.

Tensor-Style Helpers#

Tensor helpers (array operators).

fluxfem.helpers_ts.ddot(a: ArrayLike, b: ArrayLike, c: ArrayLike | None = None) ArrayLike#

Double contraction on the last two axes.

  • ddot(a, b): sum_ij a_ij * b_ij

  • ddot(a, b, c): a^T b c (Voigt-style linear elasticity blocks)

fluxfem.helpers_ts.dot(a: FormFieldLike | ArrayLike, b: ArrayLike) ArrayLike#

Batched matrix product on the last two axes.

If the first argument is a FormField, dispatch to vector_load_form to build the linear form contribution for a vector load.

fluxfem.helpers_ts.sym_grad(field: FormFieldLike) jax.numpy.ndarray#

Symmetric gradient operator for vector mechanics (small strain).

Parameters:

field (FormField-like) –

Must provide:
  • field.gradN : (n_q, n_nodes, 3)

  • field.basis.dofs_per_node (usually 3)

Returns:

B – (n_q, 6, dofs_per_node*n_nodes) Voigt order [xx, yy, zz, xy, yz, zx] Such that eps_voigt(q,:) = B(q,:,:) @ u_elem

Return type:

jnp.ndarray

fluxfem.helpers_ts.transpose_last2(a: jax.numpy.ndarray) jax.numpy.ndarray#

Swap the last two axes (batched transpose).