Skip to content

Moment based reffes#1048

Draft
JordiManyer wants to merge 444 commits intomasterfrom
moment-based-reffes
Draft

Moment based reffes#1048
JordiManyer wants to merge 444 commits intomasterfrom
moment-based-reffes

Conversation

@JordiManyer
Copy link
Member

@JordiManyer JordiManyer commented Nov 8, 2024

So we've been having a look at the current implementation of Raviart-Thomas and Nedelec. It has become clear that the current implementation

  • has issues with high-order, that have to do with how we choose our basis/prebasis when computing the moments.
  • has issues related to scaling in mixed formulations.
  • is outright wrong when using high-order approximations for the geometry.
  • is very hard to read, modify and extend.

Moreover, there has been interest lately in implementing more types of moment-based discretisations like Crouzeix-Raviart.

We believe the best way to solve all these issues at once is to create some extendable machinery to easily create moment-based FEs.

TODOs:

  • Create the moment-based machinery
  • Create the pullback machinery Pullbacks #1067
  • Replicate RT and ND in 2D/3D with oriented meshes
  • Replicate RT and ND in 2D/3D with non-oriented meshes
  • Benchmark against current implementations
  • Change of basis needs to be transposed and inverted on pushforward.

New RefFEs:

  • Crouzeix-Raviart
  • Hellan-Herrmann-Jhonson
  • Mardal-Tai-Winther
  • Arnold-Winther

Other: Polynomial bases

The solution to the first issue requires extending Jacobi-type polynomial bases. Although it could be done blindly, I think we could try to merge a lot of code together. In the future we might want to have even more basis of polynomials, which would require a lot of copied code.

@JordiManyer JordiManyer self-assigned this Nov 8, 2024
@codecov
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

❌ Patch coverage is 89.23851% with 342 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.76%. Comparing base (d44d036) to head (26cd43e).

Files with missing lines Patch % Lines
src/FESpaces/deprecated/DivConformingFESpaces.jl 0.00% 94 Missing ⚠️
src/ReferenceFEs/AWRefFEs.jl 0.00% 38 Missing ⚠️
src/ReferenceFEs/HHJRefFEs.jl 0.00% 29 Missing ⚠️
src/ReferenceFEs/Pullbacks.jl 65.00% 28 Missing ⚠️
src/ReferenceFEs/MTWRefFEs.jl 0.00% 27 Missing ⚠️
src/Fields/FieldArrays.jl 58.82% 21 Missing ⚠️
ext/TikzPicturesExt.jl 0.00% 14 Missing ⚠️
src/ReferenceFEs/Dofs.jl 86.58% 11 Missing ⚠️
src/FESpaces/Pullbacks.jl 88.31% 9 Missing ⚠️
src/ReferenceFEs/GeometricDecompositions.jl 94.73% 9 Missing ⚠️
... and 23 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1048      +/-   ##
==========================================
- Coverage   89.33%   86.76%   -2.57%     
==========================================
  Files         213      234      +21     
  Lines       27532    29205    +1673     
==========================================
+ Hits        24595    25339     +744     
- Misses       2937     3866     +929     
Flag Coverage Δ
drivers 0.00% <0.00%> (ø)
extensions 0.00% <0.00%> (ø)
tests 86.76% <89.23%> (-2.58%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

export nedelec
export bezier
export modalC0
export cr
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we name Crouziex-Raviart reffename: crouziex_raviart = CrouziexRaviart() for clarity and consistency with raviart_thomas = RaviartThomas() ?

Copy link
Contributor

@Jai-Tushar Jai-Tushar Jan 14, 2025

Choose a reason for hiding this comment

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

In the literature, people just refer to it as "cr" just like "bdm". I would suggest that we should name "raviart_thomas" as "RT" instead, which is how people refer to it in the literature and probably modify "cr" to "CR" and "bdm" to "BDM".

Copy link
Member Author

@JordiManyer JordiManyer Jan 14, 2025

Choose a reason for hiding this comment

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

I prefer longer names. CR, RT, ... could mean anything. If you start abbreviating you end up with fortran77 codes...
If a user doesn't know that CR means Crouziex-Raviart, maybe they should not be using it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also: If you don't know what Raviart-Thomas is, you can google it. Going the other direction is not as easy.

Antoinemarteau and others added 27 commits April 29, 2025 16:39
- fix @inbounds propagation to prevent bound checks
- fix getindex in performence mode
fixing precomputation performences and a typo
removed generated function and stored indices in the basis
Fixed test coverage, fixed singular simplex detection, simplified
bernstein_term_id, updated NEWS.md.
Moment based reffes - Implementation of scalar Bernstein basis in barycentric coordinates.
Cf added tests that wouldn't pass before.
Antoinemarteau and others added 30 commits October 16, 2025 17:18
I was initially reluctant to implement this for non scalar valued bases,
but then I realized that `MonomialBasis` always implemented `get_orders`
for tensor-valued bases, so I updated the doc in function.
[moment-based-reffes] Geometric decomposition on n-cubes, choice of poly basis in Lagrangian and Serendipity FES
- Enable chosing the term of component-wise tensor product polynomial
  bases
- Fixed allocation issue in derivatives evaluations
- Generalized their derivatives to basis with tensor-type value having
  dependent components
- enabled return_type to work on linear-combination of PolynomialBasis
following Santi's review
following Santi's review
[Moment based reffes] Improve CompWiseTensorPolyBasis and fix perf regression, minor renamings
It should now work for any MultiValue type (previously broken for
SkewSymTensorValue).
- homogenized the content of former face_dofs field of GenericRefFE
  accross all elements, by putting face_own_dofs inside, which most
  element did.
- face_dofs is now computed on demand, but are (almost?) never used in
  practice
PolynomialBasis used to do type pyracy of Arrays' return_type, the
signature return_type(::PolynomialBasis) is now deprecated in favor of
`value_type(::PolynomialBasis)`.
Implemented `vcat` on tuple of `Dof` vectors such that:

`evaluate(vcat(dofs...), φ) == vcat( (evaluate(dof, φ) for dof in dofs)...)`
Generalized `representatives_of_componentbasis_dual`, to any given basis
of a subspace of span(component_basis(V)).

Usefull to compute a dual basis to a tensor-product space of tensors
when at least one has dependant components

Improved the docs of `component_basis`,
`representatives_of_componentbasis_dual` and
`representatives_of_basis_dual`.
Moment dof bases now accept a `operator` argument, the operator is
broadcasted over the fields before evaluating the moment.

This is useful to implement e.g. directional derivative dofs.
[Moment based reffes] small TensorValues and Polynomials improvements, MomentDofBasis generalization to differential operators
- Added HighOrderTensorValue{S,T,N,L} <: MultiValue{S,T,N,L} wrapping a
  SArray of arbitrary order.
- Replaced the concrete implementation of ThirdOrderTensorValue with an
  alias to HighOrderTensorValue{Tuple{D1,D2,D3},T,3,L}
- implemented generic outer product, inner product, dot product and
  double dot product for tensor of arbitrary order, via the
  contraced_product method
- fixed the component naming for order 2 & 3 tensors
[Moment based reffes] Generalized MultiValue types and product operation to arbitrary order
I earlier introduced this dynamic dispatch when removing the polynomial
order `K` from the abstract type `PolynomialBasis{D,V,K}`, because
knowing K at compile time is necessary for Bernstein based bases

But it was very inelegant. Instead, I added again `K` in the type
parameters of the basis that want to statically know it at compile time
(Bernstein based basis), and refactor _get_static_parameters into
_get_parameters.

It now returns K::Int for bases that don't need to know K at compile
time, and ::Val(K) for Bernstein bases. As a consequence, all evaluation
methods are not both type stable and statically inferable from the basis
type, all dynamic dispatches are eliminated.
[Moment based reffes] Merge master and minor Polynomials optimization
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