From: Tim A. <tra...@bu...> - 2017-02-07 18:10:16
|
I have been looking into refactoring EquationSystem::reinit() with the original motivation of preserving refinement flags for apps (such as GRINS) that call refine_and_coarsen() and then es->reinit(). refine/coarsen_elements() end up getting called twice (once outside reinit, and then again inside), and the second calls clear out the JUST_REFINED and JUST_COARSENED flags, breaking some of my GRINS QoI code. I created 2 simple unit tests in libMesh to check refinement flags both when the user calls refine_and_coarsen_elements() and then es->reinit() (refine-then-reinit), as well as when the user just sets the refinement flags and calls es->reinit() to do the actual refinement (reinit-and-refine). These 2 tests can be found here <https://github.com/tradowsk/libmesh/commit/a3bdd55d24a4f7cad16efd0041caa9934fb6117f#diff-b37b7959e5e90cfb6e8e35e3cf832cd5R121> . However, I believe I have discovered an issue with the current implementation of ES::reinit(). In the reinit-and-refine case (my testReinitRefinePreserveFlags test), an assert gets tripped here <https://github.com/libMesh/libmesh/blob/master/include/base/dof_object.h#L807>. Additionally, I modified the GRINS AMR code to do reinit-and-refine and tripped the same assert on the first adaptive refinement of a QoI calculation. I was able to find a fix for the refine-then-reinit case, which will pass my testRefineThenReinitPreserveFlags libMesh test, as well as a few tests I have in GRINS. But I have been unable to find a fix for the reinit-and-refine case. I have tried: 1) testing for dof_constraints_created==true on equation_systems.C lines 246 & 270 (passed libMesh make check, but failed a GRINS regression and AMR test) 2) Using refine_and_coarsen_elements() instead of the current 2-step coarsen then refine (made no difference) 3) Moving the coarsen/refine_elements() calls to the beginning of reinit() before the new systems are added, and left distribute_dofs(), reinit_constraints(), and get_system(i)->reinit() to the very end (fails several libmesh tests: incorrect results on split_mesh and NULL_PTR error in another test) Does anyone else use the reinit-and-refine case, and if so, how did you get it working? I'm not very familiar with this part of the libMesh code, and I would appreciate any feedback as to whether I am missing something or any suggestions from more knowledgeable devs. Thanks! -- *~Tim Adowski* |