-
Notifications
You must be signed in to change notification settings - Fork 580
Description
Description
At present applications which wrap OpenMC and provide an adaptive mesh to a MeshFilter with a LibMesh unstructured mesh will receive incorrect tally results. The LibMesh class assumes that all elements can be tallied on, which is not the case when an adaptivity tree exists in the provided mesh. This results in bin indices being computed incorrectly (even though the libMesh::PointLocatorBase correctly finds active elements) as the ids of active elements aren't guaranteed to be sequential, yielding scrambled tally results.
In addition to the above, the libMesh::EquationSystems added to the mesh by the LibMesh class interacts poorly with the adaptivity process as it is unaware of any adaptivity taking place. This results in unexpected errors thrown by libMesh when refining / coarsening the mesh and generating exodus output.
The quickest path to getting adaptive meshes working in OpenMC is to define bins based on active elements and to add an indirection layer which maps from bins (over active elements) to the full element array. A flag also needs to be added to the constructor of LibMesh meshes which disables the addition of a new libMesh::EquationSystems. This has the side effect of restricting libMesh unstructured mesh tally output to non-adaptive meshes. I'm working on this approach at the moment and should have a PR up for comment in the next day or two.
Alternatives
The workaround we've been using in Cardinal is to create a deep copy of the libMesh unstructured mesh specifically for tallying which removes all of the inactive elements and reorders the element ids such that they're contiguous in memory (see neams-th-coe/cardinal#964). This works, but results in an additional memory burden and removes information which may be useful for accelerating unstructured mesh tallying (the adaptivity hierarchy).
Compatibility
This change shouldn't modify any existing APIs, and will enable unstructured mesh tallies on libMesh adaptive meshes in applications that couple OpenMC (i.e. Cardinal).