Repository navigation
fixed Curl2D evaluation for H1 elements (v1.7.2) - #85
Merged
Merged
Conversation
- restored missing minus sign of the -du1/dx2 part in the H1 Curl2D evaluation (regression introduced with the operator restructuring in v1.7.0, commit 9689350), which affected all H1 elements in 2D - added Curl2D evaluation for AbstractH1FiniteElementWithCoefficients elements (e.g. H1BR), which so far ignored the coefficients of the normal-weighted bubble dofs (missing since the introduction of H1BR) - added operator tests for H1P1 and H1BR and a consistency check between Curl2D and Gradient on H1 elements
pjaap
approved these changes
Oct 8, 2026
pjaap
left a comment
Member
There was a problem hiding this comment.
I would tell Qwen to be less verbose next time :)
- added Curl3D, CurlScalar, Laplacian, Hessian, SymmetricHessian and
TangentialGradient evaluations for AbstractH1FiniteElementWithCoefficients
elements (e.g. H1BR, H1P1TEB), which so far fell back to the plain H1
methods and ignored the coefficients of the normal-weighted bubble dofs
- added analytic checks of the derivative operators on the bubble dofs of
H1BR{2} (Gradient, Curl2D, Laplacian, Hessian, SymmetricHessian) and
H1BR{3} (Gradient, Curl3D)
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.
Fixes the
Curl2Doperator evaluation on H1 elements. Two independent defects were found while investigating an inconsistency of rotation-form convection terms in NumCompressibleFlows (velocity spaceH1BR).Bug 1: wrong sign for all 2D H1 elements (regression, introduced in v1.7.0)
update_basis!forCurl2D+AbstractH1FiniteElementcomputeddu2/dx1 + du1/dx2instead ofdu2/dx1 - du1/dx2:turned
into
thereby dropping the minus sign. The code was correct from the initial state (v0.1.0) up to v1.6.1 and is wrong in v1.7.0 and v1.7.1.
Bug 2: coefficients ignored for
AbstractH1FiniteElementWithCoefficients(present sinceH1BRwas introduced)There was no
Curl2Dmethod forAbstractH1FiniteElementWithCoefficients, soH1BRsilently used the plain H1 method, which never applies_update_coefficients!. Consequently the normal-weighted face bubble dofs ofH1BRwere evaluated without their face-normal weights.Identity,Gradient,DivergenceandNormalFluxreceived coefficient-aware methods in 0fa8ce9 (2023-09-05),Curl2Dwas overlooked, so this defect exists sinceH1BRwas added in the initial commit (82d73e5, v0.1.0).The same gap existed for
Curl3D,CurlScalar,Laplacian,Hessian,SymmetricHessianandTangentialGradient, which is also fixed here (second commit).Why the existing tests did not catch it
test_derivatives2D(H1P2{2, 2}, 2)is the only exactCurl2Dtest on an H1 element, and its test functionu = (x1^2, 3*x2^2 + x1*x2)hasdu1/dx2 = 0at the test midpoint, so both signs produce the same expected value1/3.H1BRwas not covered by the operator tests at all (it appeared only intest_reconstructions, which does not evaluateCurl2D).Extension: the remaining operators (second commit)
The identical problem existed for all other derivative operators without a coefficient-aware method. Added
Curl3D,CurlScalar,Laplacian,Hessian,SymmetricHessianandTangentialGradientmethods forAbstractH1FiniteElementWithCoefficients, each just multiplying by_update_coefficients!like the existingIdentity/Gradient/Divergence/NormalFluxmethods.New checks
test_bubble_operators2D/3Dcompare the operatorcvalsof theH1BRbubble dofs against analytic values (b * nwith the face bubbleband the face normalnread from the grid), evaluated at the midpoint of a single non-reference triangle/tetrahedron: Gradient, Curl2, Laplacian, Hessian, SymmetricHessian{1} and SymmetricHessian{sqrt(2)} in 2D, Gradient and Curl3 in 3D. Without the coefficient multiplication these produce errors of O(1)..O(10), with it they agree to machine precision.Two caveats found on the way (both pre-existing, not touched here):
TangentialGradientcould not be tested:update_basis!of anON_FACESevaluator fails for items > 1 on a 2D grid (update_trafo!bounds error), and its plain implementation only fillscvals[1, ...]H1BR{3}are covered only indirectly (same code pattern as the analytically verified 2D case)Changes
Curl2DevaluationCurl2Dmethod forAbstractH1FiniteElementWithCoefficientstest_derivatives2D(H1P1{2}, 1)andtest_derivatives2D(H1BR{2}, 1)(exact operator values incl.Curl2 = -2),test_derivatives2D(H1BR{2}, 2)and aCurl2vs.Gradientconsistency check for all H1 elements. Since the BR space is a proper subspace of P2, a quadratic test function is not reproduced exactly by interpolation; there the identitycurl(u_h) = du_h2/dx1 - du_h1/dx2is checked instead, which is exact and exercises the bubble dofs.Verification
2.0and2.707instead of< 1e-14), so they pin the bugrunic --checkis clean for the changed files