Skip to content

Add nodal gradient/Hessian recovery utilities#36

Open
chemiskyy wants to merge 2 commits into
masterfrom
feature/hessian
Open

Add nodal gradient/Hessian recovery utilities#36
chemiskyy wants to merge 2 commits into
masterfrom
feature/hessian

Conversation

@chemiskyy
Copy link
Copy Markdown
Member

Introduce fedoo.util.recovery with vectorized FE-aware recover_gradient, recover_hessian, and helpers to_voigt/to_upper_diagonal (double Galerkin L2-projection, no per-vertex Python loops). Export these functions from fedoo and fedoo.util, add tests exercising 2D/3D and various element types, and include an example (examples/adaptive/hessian_recovery.py) demonstrating usage and VTK output.

chemiskyy added 2 commits May 7, 2026 23:43
Introduce fedoo.util.recovery with vectorized FE-aware recover_gradient, recover_hessian, and helpers to_voigt/to_upper_diagonal (double Galerkin L2-projection, no per-vertex Python loops). Export these functions from fedoo and fedoo.util, add tests exercising 2D/3D and various element types, and include an example (examples/adaptive/hessian_recovery.py) demonstrating usage and VTK output.
Improve fedoo/util/recovery.py by reusing per-element cached shape-function derivatives, removing duplicated einsum/reshape logic, and introducing helpers for validation and gradient recovery.

- Use elm.shape_function_derivative_gp cache for dN_xi instead of recomputing.
- Add _validate_scalar_field to centralize input checks for scalar nodal fields.
- Add _recover_gradient to encapsulate element-to-node gradient projection and avoid duplicated code.
- Update recover_gradient and recover_hessian to call the new helpers.
- Add docnotes about element-type restrictions and boundary accuracy.
- Remove optimize=True kwargs from np.einsum calls and tidy minor docstrings/formatting.

These changes reduce duplication, surface clearer errors, and rely on cached per-element data for performance and consistency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant