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

Default to Lagrange{refdim,refshape,1}() for geometric mapping #695

Merged
merged 2 commits into from
May 8, 2023

Conversation

fredrikekre
Copy link
Member

@fredrikekre fredrikekre commented May 8, 2023

This patch changes the default value for the geometric mapping in
(Cell|Face)(Scalar|Vector)Values to linear Lagrange interpolation
instead of (re)using the function interpolation. This decouples these
two concepts further.

Some "real world" examples where I think this new default is more sane,
and the current default is just a stumbling block:

  1. Consider the following code with linear cells:

    grid = generate_grid(Triangle, ...)
    ip = Lagrange{2, RefTriangle, 1}()
    cv = CellVectorValues(qr, ip)

    To update this to use e.g. a quadratic approximation one currently
    have to change more than just the approximation order, i.e. one has
    to use

    grid = generate_grid(Triangle, ...)
    ip  = Lagrange{2, RefTriangle, 2}()
    ipg = Lagrange{2, RefTriangle, 1}()
    cv = CellVectorValues(qr, ip, ipg)

    instead of simply

    grid = generate_grid(Triangle, ...)
    ip = Lagrange{2, RefTriangle, 2}()
    cv = CellVectorValues(qr, ip)
  2. For the Taylor-Hood element one always have to worry about the
    geometric mapping, regardless if it is linear or quadratic:

    ip_g = Lagrange{2, RefTriangle, 1}()
    ip_u = Lagrange{2, RefTriangle, 2}()
    ip_p = Lagrange{2, RefTriangle, 1}()
    cv_u = CellVectorValues(qr, ip_u, ip_g)
    cv_p = CellVectorValues(qr, ip_p, ip_g)

    instead of just

    ip_u = Lagrange{2, RefTriangle, 2}()
    ip_p = Lagrange{2, RefTriangle, 1}()
    cv_u = CellVectorValues(qr, ip_u)
    cv_p = CellVectorValues(qr, ip_p)
  3. For more exotic elements, such as VectorizedInterpolation (Implement (Scalar|Vector)Interpolation and VectorizedInterpolation{<:ScalarInterpolation} #694),
    or RaviartThomas it is also a more useful default.

This patch changes the default value for the geometric mapping in
`(Cell|Face)(Scalar|Vector)Values` to linear Lagrange interpolation
instead of (re)using the function interpolation. This decouples these
two concepts further.

Some "real world" examples where I think this new default is more sane,
and the current default is just a stumbling block:

1. Consider the following code with linear cells:
   ```julia
   grid = generate_grid(Triangle, ...)
   ip = Lagrange{2, RefTriangle, 1}()
   cv = CellVectorValues(qr, ip)
   ```
   To update this to use e.g. a quadratic approximation one currently
   have to change more than just the approximation order, i.e. one has
   to use
   ```julia
   grid = generate_grid(Triangle, ...)
   ip  = Lagrange{2, RefTriangle, 2}()
   ipg = Lagrange{2, RefTriangle, 1}()
   cv = CellVectorValues(qr, ip, ipg)
   ```
   instead of simply
   ```julia
   grid = generate_grid(Triangle, ...)
   ip = Lagrange{2, RefTriangle, 2}()
   cv = CellVectorValues(qr, ip)
   ```

2. For the Taylor-Hood element one *always* have to worry about the
   geometric mapping, regardless if it is linear or quadratic:
   ```julia
   ip_g = Lagrange{2, RefTriangle, 1}()
   ip_u = Lagrange{2, RefTriangle, 2}()
   ip_p = Lagrange{2, RefTriangle, 1}()
   cv_u = CellVectorValues(qr, ip_u, ip_g)
   cv_p = CellVectorValues(qr, ip_p, ip_g)
   ```
   instead of just
   ```julia
   ip_u = Lagrange{2, RefTriangle, 2}()
   ip_p = Lagrange{2, RefTriangle, 1}()
   cv_u = CellVectorValues(qr, ip_u)
   cv_p = CellVectorValues(qr, ip_p)
   ```

3. For more exotic elements, such as `VectorizedInterpolation` (#694),
   or `RaviartThomas` it is also a more useful default.
@fredrikekre fredrikekre force-pushed the fe/default_geometric_interpolation branch from 72766d8 to c7e46b5 Compare May 8, 2023 14:44
@fredrikekre fredrikekre marked this pull request as ready for review May 8, 2023 14:44
@codecov-commenter
Copy link

codecov-commenter commented May 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (588f804) 92.92% compared to head (3c660c7) 92.93%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #695   +/-   ##
=======================================
  Coverage   92.92%   92.93%           
=======================================
  Files          30       30           
  Lines        4398     4400    +2     
=======================================
+ Hits         4087     4089    +2     
  Misses        311      311           
Impacted Files Coverage Δ
src/FEValues/cell_values.jl 100.00% <100.00%> (ø)
src/FEValues/face_values.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@termi-official termi-official left a comment

Choose a reason for hiding this comment

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

I think you forgot to update the topology optimization example.

@fredrikekre fredrikekre added this to the v0.4.0 milestone May 8, 2023
@fredrikekre fredrikekre merged commit 7b2430b into master May 8, 2023
@fredrikekre fredrikekre deleted the fe/default_geometric_interpolation branch May 8, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants