Translate from libMesh meshes to MFEM meshes#32566
Translate from libMesh meshes to MFEM meshes#32566cmacmackin wants to merge 27 commits intoidaholab:nextfrom
Conversation
|
This is largely done. There are a few things that maybe could be tidied up in the code. I'm also not totally satisfied with how the integration tests have been written. Ideally what I would like to do is run the same simulation twice: once with the mesh read directly in by MFEM and once with it first read by MOOSE/LibMesh and then converted to MFEM. The output Exodus output of those two simulations should be the same. Unfortunately, there didn't appear to be an easy way to do that. I've compromised by running one of these simulations as a parent app and the other in a sub-app and then finding the L2 error between the results. The problem with this is that, while it confirms the solutions are the same, it doesn't check that the meshes are. An alternative would be to save the result of loading the mesh directly into MFEM as a "gold" result, against which to compare the results when the meshes are converted. This is slightly more fragile however. |
21d213f to
ea13755
Compare
|
I don't understand the nature of the current error when compiling in CI: There seems to be a missing header file, but this is found just fine when compiling on my machine. I'm using the version of MFEM in Edit: I was forgetting to wrap some files in |
|
Job Documentation, step Docs: sync website on 8ea808d wanted to post the following: View the site here This comment will be updated on new commits. |
|
There were a few different types of failure in the last CI
Edited 7 April to reflect which problems have now been fixed. |
d937062 to
e23aa8e
Compare
|
On your local machine are you using 64 bit or 32 bit dof indices? And what is the size of unsigned long? |
|
I have pushed your branch to my fork after rebasing. It has a commit on top of it by codex which I haven't personally reviewed yet which at least removes the reported leaks from unit testing. I haven't attempted to verify whether this fixes the failing tests across all architectures yet either |
|
Ok I reviewed the codex commit (lindsayad/moose@a8401461aae) and I think it's good. Main points
|
|
Ok I just pushed one more commit to my fork that was probably the root of the CI problem ... If |
Wouldn't it just be simpler to split these into separate tests, so we can let the existing fixture handle this work? |
Huh. Very strange that this wasn't happening on my system, even when I ran the full test suite. I guess there must have been some part of the code I wasn't building that did this. |
Separate tests or just enclose them in different scope within the same test. Either is fine |
This will eventually allow MFEMProblem to use mesh types other than MFEMMesh. It would do this by constructing and storing a ParMesh corresponding to the libmesh object.
There was strange behaviour depending on what combination of parallel and distributed were used. Different combinations of tests failed in different ways. Most bizarrely, if you ran in serial but with the distributed flag (admittedly, a very odd thing to do) some of the tests failed. |
I'm not sure if this is actually the behaviour we want though. One of the reasons for this PR is so that we can implement efficient transfers between MFEM and libMesh meshes, therefore allowing a high level of interoperability between MFEM and libMesh based apps. Therefore, we were deliberately choosing to set up the MFEM mesh with the same partitioning as the libMesh one. Won't the changes in this PR mean that we can no longer guarantee the same nodes will be on the same ranks for both libMesh and MFEM meshes? |
|
I think the premise of those multiapp copy transfer tests is fragile and worked even in the serial case by happy coincidence. They essentially rely on both libmesh and MFEM reading an exodus mesh and deciding on an internal element numbering representation that are the same. But libmesh or MFEM could have decided to take the exodus numbering and then reversed the numbering or done a totally random re-ordering and then there would be no chance of matching for copy transfers by just doing vector assignments |
|
Given the test requirements, I don't understand why multiapps are involved at all |
|
If we're going to do multiapp copy transfers the preparation process on parent and sub should be identical. Same initial Mesh |
I'd be willing to finish up this PR if you want to pass it along |
The only way in my opinion for you to generate a transfer as efficient as a copy transfer is if the meshes are indeed copies. And one app having |
I agree with this (it's only because the MFEM exodus reader grew out of the Apollo version anyway that this happy coincidence exists...) For any future MFEM<->libMesh CopyTransfer, we would need consistent partitioning between source and target; setting the MFEM partitioning to be the same as the libMesh partitioning of the mesh its built from seems cleaner to me than 99072c2 . But these CopyTransfers are beyond the scope of this PR; we fundamentally just want to test that the mesh as-built from MFEM directly or from an MFEM mesh built from a libMesh mesh are the same in the sense that they represent the same geometry/elements/order etc. The two options for this PR that I can see are:
From discussions with @cmacmackin , I'm in favour of option 2 (the idea for rewriting these tests alluded to above). This could be done using |
It's even more fundamental of an issue than partitioning. There is no partitioning in serial. The internal element numbering can be completely different in theory between a libmesh mesh built from exodus vs. an mfem mesh built from exodus. You'd have to go through and do some geometric matching and then element renumbering to be able to trust that you have consistency between the two. I haven't actually checked to see whether that's done in the current code |
I didn't see this when responding originally. This is definitely an elegant solution! I support option 2 leveraging that MFEM API. It seems like in that case we only need plumbing for telling the libmesh-based mesh to reorder since we already have the parameter |
I'm most of the way done implementing this. Unfortunately, it's uncovered a couple of underlying problems with MFEM and/or libMesh.
I'm going to write my comparison script to filter out the parts of the mesh which we expect to differ due to these issues. It's not ideal but it's probably the best we can do at the moment. |
This feels like something that should be an MFEM issue
EDGE4 is libMesh's only third order geometric element and I don't think anyone uses it, although I guess MFEM users are just the kind of people who would use it and consequently create EDGE4 elements in their libmesh mesh generators before converting to an MFEM mesh. This feels like a fixable issue. You could create a MOOSE issue and just error for now? This is an issue I'd be happy to tackle in a follow-on |
Agreed. For now we're just planning to ignore that section of the mesh file when making comparisons.
The bigger issue with this is we need to work out which set of quadrature points is actually the correct one to use. Does the Exodus documentation specify anywhere? |
|
The nodes in the exodus mesh define the mesh geometry for both libMesh and MFEM. If you are using a Lagrange basis in libMesh, then that is fundamentally tied to the mesh nodes. For MFEM there is no link (I believe) between the interpolation nodes used to define solution variable finite element bases and the mesh geometry nodes. If you wanted to make the interpolation nodes for a variable evaluation match on an EDGE4 element with a third order Lagrange FE in libMesh, then I think you'd need to set a |
|
quadrature points are generally separate concepts from interpolation points/nodes both in MFEM and libMesh. You can choose to collocate them if you want if you want things like diagonal mass matrices |
|
Job Precheck, step Clang format on 6dde692 wanted to post the following: Your code requires style changes. A patch was auto generated and copied here
Alternatively, with your repository up to date and in the top level of your repository:
|
|
I've rewritten the tests to do a direct comparison of meshes. Most of them work, but not those for tets and (when running in parallel) pyramids. |
loganharbour
left a comment
There was a problem hiding this comment.
Pedantic request: the test names are long. the test already has libmesh_mfem_conversation in the name from the folder. We don’t need libmesh_mfem_conversion/LibMeshToMFEMMeshQuad for example. libmesh_mfem_conversion/quad should be plenty. And if it’s not, the folder name can be corrected to give more context. We should limit all tests in a folder anyway to a single feature.
Second thing: I’m not a fan of check.sh. Git diff won’t work with installed applications.
| mfem::Mesh serial_mesh = _pmesh.GetSerialMesh(save_rank); | ||
|
|
There was a problem hiding this comment.
I've rewritten the tests to do a direct comparison of meshes. Most of them work, but not those for tets and (when running in parallel) pyramids.
I suspect this is related to the tet mesh orientation issues discussed in mfem/mfem#3847. I've found that
| mfem::Mesh serial_mesh = _pmesh.GetSerialMesh(save_rank); | |
| mfem::Mesh serial_mesh = _pmesh.GetSerialMesh(save_rank); | |
| serial_mesh.ReorientTetMesh(); |
appears to fix the failing tet mesh test failures. Unfortunately, this method has been deprecated for a while (since mfem/mfem#1046) - I haven't yet found a suitable alternative that gives the ordered serial mesh in this case as we require.
EDIT: Looks like this does get things working in serial, but the pyramid and tet tests in parallel are still failing
|
I've opened mfem/mfem#5302 for hopefully consistent boundary element ordering |
Get reordering working for tet meshes Co-authored-by: Alexander Blair <35571481+alexanderianblair@users.noreply.github.com>
Sorry, I misspoke. I meant the basis points. |
What do you mean by this? Would this be run somewhere without git? What would you recommend instead? Just plain-old |
That is what I've done when converting from libmesh to MFEM. However, if MFEM reads the same file it would not use |
|
Job Test, step Results summary on 8ea808d wanted to post the following: Framework test summaryCompared against fa12ff0 in job civet.inl.gov/job/3740302. Added tests
Modules test summaryCompared against fa12ff0 in job civet.inl.gov/job/3740302. No added testsRun time changes
|
It depends on whether the nodes, after transforming to reference space, are uniformly spaced or not. So in reality it's liked tied to the file writer. If libMesh wrote the file, then the nodes will certainly be uniformly spaced. If MFEM wrote the file, I'd expect them to correspond to the basis type of the FESpace used to define the MFEM mesh nodes. |
Closes #32520