-
Notifications
You must be signed in to change notification settings - Fork 103
Scaled contravariant piola map for Div-conforming elements #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi @amboschman ... thanks for your work! It looks good. The only major thing I am missing is a test that stresses the Perhaps you may some tests here: Also, have we tried this with (1) BDM. (2) RT elements on triangles? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1120 +/- ##
==========================================
- Coverage 89.23% 89.16% -0.08%
==========================================
Files 208 208
Lines 26196 26217 +21
==========================================
Hits 23377 23377
- Misses 2819 2840 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a scaled contravariant Piola map for HDiv-conforming elements and enables users to select between the default and scaled Piola maps via an additional argument in the finite element space constructor. Key changes include:
- Adding the scaled_meas operation and its documentation for rescaled Jacobian determinants.
- Updating the interface in CellFE, ReferenceFEs, and various FESpace modules (Div-, Curl-, and ConformingFESpaces) to pass and honor the new contra_variant_piola_map_type argument.
- Adjusting exports and imports across TensorValues, Fields, and FESpace modules to expose the new functionality.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/TensorValues/TensorValues.jl | Exports the new scaled_meas operation. |
src/TensorValues/Operations.jl | Introduces scaled_meas implementations with updated docstrings. |
src/ReferenceFEs/ReferenceFEs.jl | Exports new types for contravariant Piola maps. |
src/ReferenceFEs/RaviartThomasRefFEs.jl | Redefines Piola map types and adds evaluate!/lazy_map overloads for the scaled option. |
src/Fields/FieldsInterfaces.jl & Fields.jl | Imports and exports the scaled_meas operation. |
src/FESpaces/FESpaceFactories.jl, DivConformingFESpaces.jl, CurlConformingFESpaces.jl, ConformingFESpaces.jl | Updates FESpace construction interfaces to pass additional keyword arguments including the new Piola map type. |
Comments suppressed due to low confidence (2)
src/TensorValues/Operations.jl:798
- Consider clarifying in the docstring that this method applies specifically to square matrices and ensure that its behavior is clearly distinguished from the rectangular case defined below.
scaled_meas(a::MultiValue{Tuple{D,D}}) where D = abs(det(a))^(1/D)
src/FESpaces/FESpaceFactories.jl:75
- It may be beneficial to add inline documentation or usage examples for the new 'contra_variant_piola_map_type' keyword argument to help users understand its purpose and usage.
contra_variant_piola_map_type::ContraVariantPiolaMapType=ContraVariantPiolaMap())
detJ::Number, | ||
sign_flip::Bool) | ||
((-1)^sign_flip*v)⋅((1/detJ)*Jt) | ||
((-1)^sign_flip*v)⋅((1/(detJ))*Jt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of extra parentheses around detJ improves clarity; consider applying a consistent formatting style to similar expressions in the codebase.
((-1)^sign_flip*v)⋅((1/(detJ))*Jt) | |
((-1)^sign_flip*v)⋅((1/((detJ)))*Jt) |
Copilot uses AI. Check for mistakes.
Why did we do this in master? I would be working directly on the new moment based branch, otherwise we are doing redundant work. Also, the implementation in the new branch could be done much more elegantly by overwriting the pushforward instead of propagating a kwarg all the way into the depths of the code. |
Thanks Jordi for looking at this.
I had a very brief chat with Antoine, but he mentioned that one or two things still had to be finished, so it might take ~ 1 month(? if I remember correctly) for it to be released. Ideally, I would like to use this switch within a shorter timeframe. But happy to learn what can be done to better coordinate this, or contribute/develop a similar thing in the moment-based branch.
That would not give the option to the user to switch between the two different ContraVariantPiolaMappings. I wanted the standard one to be the default, as that is what a user would expect this code to do. |
I fully agree.
Looking at this at the moment. At a quick glance, having a good test with
I tested this once quickly on my system (h-convergence test), but will include this in a test. |
Anyway, as you say, we also need to implement this in that branch. It would be great if you can assist us with additional details on how to do this. Thanks! |
I wanted to keep both as well, just override the pushforward on the kwarg, directly on the reffe instead of propagating it to the functions.
Sure, but you can always use the branch. It doesn't need to be released for you to be able to use it in another package. |
Anyway, lets just add some tests and merge this as it is, with the understanding it will get modified soon. |
Who are those potential users? The user API implemented here could change in next minor if:
So I'm not sure if its a good idea to let users adopt a possibly temporary API design. But if its mostly for you of course this is not an issue.. |
Let us put this PR on hold ... There are still several issues that we do not understand and thus not ready to be merged. I have transformed the PR into a draft PR. |
…or 3D do not work
…ntegrating proj term for GridapEmbedded#bulk_penalty_stab_div (commit 3b70225)
This PR allows the user to specify whether a HDiv-conforming element (e.g. Raviart-Thomas or BDM) should be used with the (default) contravariant Piola map or a rescaled version through the use of an extra (optional) argument in
FESpace
when constructing an HDiv-conforming finite element space, e.g.FESpace(model, reffe_RT, conformity=:HDiv, contra_variant_piola_map_type=ScaledContraVariantPiolaMap())
. The scaled contravariant Piola map is defined as the standard contravariant Piola map for which the determinant of the Jacobi matrix is rescaled using^{1/D}
(withD
theD1
-dimensional volume of the parallelepiped formed by the rows ofJ
). The use of this scaled contravariant Piola map can result in better conditioning of certain (mixed) problems, such as the Darcy equation.For this to work,
CellFE
has been updated to not only pass alongargs
but alsokwargs
toget_cell_shapefuns
andget_cell_dof_basis
, so that the user can (optionally) specify thecontra_variant_piola_map_type
inFESpace
;scaled_meas
operation has been introduced to define the scaled version of the contravariant Piola map;lazy_map
's andevaluate!
's are changed inRaviartThomasRefFEs.jl
so that either the default operationContraVariantPiolaMap()
or the selected (ContraVariantPiolaMap()
orScaledContraVariantPiolaMap()
) is performed.