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

Lumped Mass Matrix Implementations #1217

Open
jrwrigh opened this issue May 20, 2023 · 14 comments
Open

Lumped Mass Matrix Implementations #1217

jrwrigh opened this issue May 20, 2023 · 14 comments

Comments

@jrwrigh
Copy link
Collaborator

jrwrigh commented May 20, 2023

Currently, all the lumped mass matrix implementations (in the fluids code at least) utilize a row-sum technique, which will not work for higher-order tets.

Possible solution to this would be to use "special lumping", as described in this thread: #1147 (comment). Jed's comment sketches out a way to possibly implement that method at a global level rather than the element level presented in Hughes' FEM book.

Relevant existing threads:

@jedbrown
Copy link
Member

A related question here is which of these projections need to be lumped. The diagonal is a fine preconditioner for a consistent L^2 projection, and typically has some quality improvements. I concede it may be too expensive for the SNES residual for the diffusive fluxes, and I think John mentioned at some point that lumping is arguably better there since it's more local.

I think the intent was to reference this comment for an implementation strategy that could go into PCJacobi.

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 20, 2023

My general logic for whether lumped or consistent is whether the projection occurs every timestep, or is done less frequently. So the turbulent statistics is consistent (though that's also a very small problem to solve anyways since it's on a 2D slice), but the velocity gradient projection (needed for the data-driven SGS) is lumped since that's needed every non-linear iteration.

@jedbrown
Copy link
Member

Let's try adding this conservative lumping to PCJacobi. Is that something you can do or should we recruit someone else? Should be just a few lines of code (MatMult, VecSum, VecScale).

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 20, 2023

You mean as a built-in for PETSc, or building and setting the Pmat explicitly? I was originally thinking the latter, but I guess there's no reason that it can't be integrated into PETSc proper.

@jedbrown
Copy link
Member

I'd make it -pc_jacobi_type conservative" or some similar name, alongside the current options diagonal,rowmax,rowsum. See include/petscpctypes.handsrc/ksp/pc/impls/jacobi/jacobi.c(andsrc/ksp/f90-mod/petscpc.h` to make it available in Fortran).

@knepley
Copy link
Collaborator

knepley commented May 20, 2023

@jedbrown I cannot find a description of the lumping in that other PR. Is this something I can use for PyLith?

@jedbrown
Copy link
Member

I don't trust it (because I haven't used it), but this is the page from Hughes' book (in collapsed comment just above previously linked one).
image

Here's the description of the method and comparison table in Hinton et al 1976.
image

image

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 20, 2023

I have a functioning prototype that fails fluids regression tests by a "small", "acceptable" margin (at least for being a completely different method). Any specific tests you want to see?

@jedbrown
Copy link
Member

Cool. You had some tests in a profile comparing consistent and lumped for hex elements. Can you do that with quadratic tets and include consistent, diagonal, and this lumping?

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 20, 2023

You had some tests in a profile

Are you talking about the tests I did for the spanwise turbulent statistics collection? That should be easy to do for hexes, but the fluids code doesn't support tets right now.

@jedbrown
Copy link
Member

Hmm, src/dm/dt/fe/tests/ex3.c incorrectly claims to do an "L2 projection", but is really just sampling the dual basis functions. @knepley what's your most convenient test of accuracy of a consistent mass projection (with a KSP solve that we can control as -ksp_type preony -pc_type jacobi -pc_jacobi_type conservative)?

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 20, 2023

I tested an L2 projection on the blasius boundary layer for hexes. Q1 and Q2 have the same DoFs (so different element counts). I'm plotting the velocity profile normal to the wall, zoomed in to see the differences:

Q1, at wall (MeanVelocity_MeanVelocityX here is the conservative lumped mass matrix):
image

Q2, at wall:
image

Q2, mid boundary layer:
image

A few observations:

  1. The rowsum and conservative lumped mass matrix appear to give more-or-less the exact same answers. Not sure if this is expected or not.
  2. For Q2, the error at the wall goes away; we're able to recover the exact zero velocity at the wall for the lumped matrices.
  3. For Q2, the lumped mass matrices away from the wall appear to almost be using the linear-form of the mass matrix; the resulting projection appears to be completely linear within the element bounds.

@jrwrigh
Copy link
Collaborator Author

jrwrigh commented May 22, 2023

I've confirmed that the conservative and rowsum entries are not identical to each other, but are still pretty close (order 1e-4 maximum relative difference).

@jedbrown
Copy link
Member

Cool that they're that close. I don't a priori have an explanation for that. We could use the projection of diagnostic variables in Ratel as a test of interesting fields on tet meshes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants