Small raw-ATen helpers for the batched finite-element assembly used by the Torch FEM kernels. More...
Functions | |
| at::Tensor | scatter (const at::Tensor &v, const at::Tensor &dof_map) |
| Gather global solution values into element-local DOF values: out[e,a,...] = v[dof_map[e,a,...]]. | |
| at::Tensor | interpolate (const at::Tensor &elem_dofs, const at::Tensor &basis) |
| Interpolate element-local DOF values onto quadrature points by contracting over the per-element DOF axis (dim 1) against a basis: out[e,...] = sum_a elem_dofs[e,a] * basis[e,a,...]. | |
| at::Tensor | assemble (const at::Tensor &scattered, const at::Tensor &dof_map, int64_t ndof) |
| Scatter-add element-local contributions into a global vector: out[dof_map.flatten()[k]] += scattered.flatten()[k]. | |
| at::Tensor | fullToMandel (const at::Tensor &full) |
| Convert a full (symmetric) rank-2 tensor to its 6-component Mandel representation, matching NEML2's SR2 convention: components [00, 11, 22, sqrt(2)*12, sqrt(2)*02, sqrt(2)*01]. | |
| at::Tensor | mandelToFull (const at::Tensor &mandel) |
| Inverse of fullToMandel: expand a 6-component Mandel tensor to a full symmetric (..., 3, 3), matching neml2::R2(SR2) (off-diagonals divided by sqrt(2)). | |
Small raw-ATen helpers for the batched finite-element assembly used by the Torch FEM kernels.
These reproduce the trivial torch operations that NEML2 v2 exposed through its (now-deleted) C++ typed-tensor API (neml2::discretization::{scatter,interpolate,assemble} and the SR2<->R2 Mandel conversions). All tensors are plain at::Tensor with explicit batch dimensions; the leading dims are batch (nelem, ndofe, nqp, ...) and any trailing dims are the tensor base shape.
|
inline |
Scatter-add element-local contributions into a global vector: out[dof_map.flatten()[k]] += scattered.flatten()[k].
| scattered | Element-local contributions, same shape as dof_map. |
| dof_map | Integer local-dof indices, same shape as scattered. |
| ndof | Length of the assembled global vector. |
Definition at line 57 of file TorchFEMUtils.h.
|
inline |
Convert a full (symmetric) rank-2 tensor to its 6-component Mandel representation, matching NEML2's SR2 convention: components [00, 11, 22, sqrt(2)*12, sqrt(2)*02, sqrt(2)*01].
The caller is responsible for symmetrizing the input if needed (mirrors neml2::SR2(R2), which uses the symmetric part).
| full | (..., 3, 3). |
Definition at line 70 of file TorchFEMUtils.h.
|
inline |
Interpolate element-local DOF values onto quadrature points by contracting over the per-element DOF axis (dim 1) against a basis: out[e,...] = sum_a elem_dofs[e,a] * basis[e,a,...].
| elem_dofs | Element-local values, shape (nelem, ndofe). |
| basis | Shape functions (nelem, ndofe, nqp) or their gradients (nelem, ndofe, nqp, 3). |
Definition at line 43 of file TorchFEMUtils.h.
Referenced by TorchFEInterpolation::updateInterpolations().
|
inline |
Inverse of fullToMandel: expand a 6-component Mandel tensor to a full symmetric (..., 3, 3), matching neml2::R2(SR2) (off-diagonals divided by sqrt(2)).
| mandel | (..., 6). |
Definition at line 82 of file TorchFEMUtils.h.
|
inline |
Gather global solution values into element-local DOF values: out[e,a,...] = v[dof_map[e,a,...]].
| v | Flat (local) solution vector, shape (local_ndof,). |
| dof_map | Integer local-dof indices, shape (nelem, ndofe). |
Definition at line 32 of file TorchFEMUtils.h.
Referenced by TorchFEInterpolation::updateInterpolations().