Add nodal gradient/Hessian recovery utilities#36
Open
chemiskyy wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.