Skip to content
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

div(v)*p and q*div(u) trick in reference space high level API for high order geometric mappings #636

Merged
merged 5 commits into from
Aug 13, 2021

Conversation

amartinhuertas
Copy link
Member

@amartinhuertas amartinhuertas commented Aug 12, 2021

Hi @fverdugo,

I have come up with a proposal to support the following trick for the implementation of this term (Darcy+RT FEs)

Screenshot from 2021-08-12 15-11-47

This will let us by-pass the current limitation that we have in the computation of the divergence operator. (i..e, Gridap assumes that the mapping is affine, and thus that the Jacobian is constant within each cell). This prevents the usage of, e.g., quadrilateral bilinear disctrizations of the sphere using the so-called cubed-sphere mesh, but even worse, it prevents curved elements at all.

In code, you may se the new term in action here: b989735#diff-37219e6468e24d7c4b29903834b894aa426a861aa49ef64122068cbd47ceb5daR24

Concerns to take into account when reviewing:

  • Is there any other possible approach to implementation? If yes, pros/cons?
  • I have tried to do my best to place the difference pieces of code within the source code hierarchy. Review this, please.
  • The DIV() operator is currently only defined for instances of type SingleFieldFEBasis. Should it be defined for any other objects?
  • Is composability ok with the way ReferenceTriangulation triangulation is implemented?
  • ReferenceTriangulation TriangulationStyle here correct?

TO-DO:

  • Modify NEWS.md once we agree on the approach and the details.

PS: @santiagobadia already took a look at the approach to implementation, he thinks it is reasonable, and agreed in the details.

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2021

Codecov Report

Merging #636 (5167a37) into master (67e5ee1) will increase coverage by 0.01%.
The diff coverage is 76.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #636      +/-   ##
==========================================
+ Coverage   87.66%   87.67%   +0.01%     
==========================================
  Files         134      134              
  Lines       14267    14307      +40     
==========================================
+ Hits        12507    12544      +37     
- Misses       1760     1763       +3     
Impacted Files Coverage Δ
src/FESpaces/FESpaces.jl 0.00% <ø> (ø)
src/Fields/DiffOperators.jl 67.21% <0.00%> (-2.28%) ⬇️
src/CellData/CellQuadratures.jl 76.63% <71.42%> (-4.09%) ⬇️
src/FESpaces/DivConformingFESpaces.jl 96.38% <100.00%> (+0.61%) ⬆️
src/FESpaces/FESpaceInterface.jl 77.41% <100.00%> (+0.31%) ⬆️
src/ReferenceFEs/CLagrangianRefFEs.jl 94.81% <0.00%> (+0.76%) ⬆️
src/ReferenceFEs/RaviartThomasRefFEs.jl 93.07% <0.00%> (+2.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67e5ee1...5167a37. Read the comment docs.

@fverdugo
Copy link
Member

Which is the math definition of the new operator DIV? It is more than the div wrt reference coordinates right?

@amartinhuertas
Copy link
Member Author

There is one paper by botchev ... Rehabilitation of lowest order ... That defines a discrete variant of the physical div as the normal flux integrated over the boundary divided by the element measure. I am not sure of the connections of that DIV operator and the one at hand (divergence in reference space)

@fverdugo
Copy link
Member

I want to understand why this new feature does not fit well in our current design.

Perhaps it is related with the fact that the high level API always refers to the physical space (i.e. the gradient and div are always wrt the physical coordinate), but in some situations you also want to write integrals of gradients/divs in the reference cell with the high level API (which is not supported now)

If this is the reason, perhaps we need to introduce a ReferenceMeasure instead of a ReferenceTriangulation Or instead of a ReferenceMeasure parametrize Measure with DomainStyle. E.g.,:

= Measure(Ω) # PhysicalDomain() by default= Measure(Ω,ReferenceDomain())
( (u)(v) )dΩ # Gradients wrt physical coordinate
( (u)(v) )dω # Gradients wrt reference coordinate

I like this API, but not sure how difficult it is to implement it.

@fverdugo
Copy link
Member

There is one paper by botchev ... Rehabilitation of lowest order ... That defines a discrete variant of the physical div as the normal flux integrated over the boundary divided by the element measure. I am not sure of the connections of that DIV operator and the one at hand (divergence in reference space)

Ok! So the DIV operator is not a trick. it is something with a math definition, right? So it is perfectly fine to add it.

Which is the "tricky" part of the PR then? The ReferenceTriangulation ?

@amartinhuertas
Copy link
Member Author

Yes the reason you say. The high level API is designed to always perform the change of domain from physical to reference space. It computes the Jacobian of the mapping from reference to physical and uses it to transform the differential integral measure

@fverdugo
Copy link
Member

OK! then the part we have to work a bit more is the ReferenceTriangulation

@santiagobadia
Copy link
Member

@fverdugo is not a trick, it is the right way to do it, there is a mathematically sound reason for all this.

I like how it is implemented, but as you say, if you think there is a better way to deal with the ReferenceTriangulation is ok.

What is the problem with the current design of this triangulation?

@amartinhuertas
Copy link
Member Author

I called it trick because by exploiting the particular definition of the pull back of RT shape function it lets you compute that integral without having to compute the divergence in physical space which is complicated for non affine geometries due to the piola map

* Added a new trait template parameter to CellQuadrature (of type DomainStyle)
  to let one select whether to integrate in
  ReferenceDomain() or PhysicalDomain()
@amartinhuertas
Copy link
Member Author

amartinhuertas commented Aug 12, 2021

I like this API, but not sure how difficult it is to implement it.

Ok, I already removed ReferenceTriangulation and implemented the API you proposed. See:

a6cc908#diff-37219e6468e24d7c4b29903834b894aa426a861aa49ef64122068cbd47ceb5daR20

BTW, another difference (benefit?) in the proposed solution is that we don't have different entries in the dictionary within DomainConstribution for each kind of domain (i.e., reference versus physical). I guess that mixing in the same lazy_map both contributions one might open the door for further optimizations.

Copy link
Member

@fverdugo fverdugo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @amartinhuertas thanks for the changes.

Just a very minor comment and it's ready to merge!

cell_quad::AbstractArray{<:Quadrature}
cell_point::AbstractArray{<:AbstractArray{<:Point}}
cell_weight::AbstractArray{<:AbstractArray{<:Real}}
trian::Triangulation
domain_style::DS
data_domain_style::DDS
integration_domain_style::IDS
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default constructor of the struct has changed. Can you add an extra constructor with the old signature? and perhaps calling it in the tests? Just to be backwards compatible, I.e.,

function CellQuadrature(
  cell_quad::AbstractArray{<:Quadrature},
  cell_point::AbstractArray{<:AbstractArray{<:Point}},
  cell_weight::AbstractArray{<:AbstractArray{<:Real}},
  trian::Triangulation,
  data_domain_style::DomainStyle)
  CellQuadrature(cell_quad,cell_point,cell_weigth,trian,data_domain_style,PhysicalDomain())
end

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I will do that soon (I am in the middle of another task).

I guess that the current set of tests do not fail because they are not calling to the (old) default constructtor, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I will do that soon (I am in the middle of another task).

Done!

@fverdugo
Copy link
Member

I guess that the current set of tests do not fail because they are not calling to the (old) default constructtor, right?

Yes....

old CellQuadrature inner constructor for backward compatibility

Added missing test
@amartinhuertas
Copy link
Member Author

@fverdugo ... the PR can be accepted, right?

@fverdugo fverdugo merged commit 8522d93 into master Aug 13, 2021
@fverdugo fverdugo deleted the div_v_p_div_u_q_term_trick_for_rt_fes branch August 13, 2021 09:15
@amartinhuertas
Copy link
Member Author

Thanks!

amartinhuertas added a commit that referenced this pull request Aug 13, 2021
- Some fixes to DIV pending from PR #636
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.

4 participants