-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow restart calculations from a p-refined solution #30052
base: next
Are you sure you want to change the base?
Conversation
ebb96a0
to
9027bde
Compare
Job Documentation, step Docs: sync website on 3c161ae wanted to post the following: View the site here This comment will be updated on new commits. |
Are the test failures related with my change? |
Well, they're definitely not a fluke. Most of these failures look the same to me: we're hitting a material's I don't see how they could be triggered by your changes here, though. Unless the changes from |
Me neither ;-( |
Eh, I saw one function |
Still cannot find any... One thing is that |
framework/src/mesh/MooseMesh.C
Outdated
@@ -614,6 +614,13 @@ MooseMesh::update() | |||
cacheInfo(); | |||
buildElemIDInfo(); | |||
|
|||
// this will make moose mesh aware of p-refinement added by mesh generators including | |||
// a file mesh generator loading a restart checkpoint file | |||
for (const auto & elem : *getActiveLocalElementRange()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something quite insane is happening here. If I replace this with
for (const auto & elem : getMesh().active_local_element_ptr_range())
the error is gone. While I admit I should directly use the libMesh element range, but this code is not affecting anything supposedly. I will push the change momentarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd admit that MOOSE has a lot of shims that are basically "add a second way to do a libMesh thing for no better reason than a preference for camelCase over snake_case", there generally aren't any shims that are "add a second way to do a libMesh thing, but make it broken this time".
... unless this is one, in this context? getActiveLocalElementRange()
doesn't just get two libMesh iterators defining a range, it copies the entire range into a new StoredRange
, and it caches that copy. This isn't insane (we use StoredRange
in our threading APIs, and the copy is too expensive to repeat for every threaded section), but: if anyone adds an element to the mesh or deletes an element from the mesh, then tries to use that cached range again before calling MooseMesh::meshChanged()
, the result is undefined behavior. A crash if you're lucky.
6297756
to
ed501fb
Compare
const auto families_enum = AddVariableAction::getNonlinearVariableFamilies(); | ||
MultiMooseEnum disable_p_refinement_for_families(families_enum.getRawNames()); | ||
params.addParam<MultiMooseEnum>("disable_p_refinement_for_families", | ||
disable_p_refinement_for_families, | ||
"What families we should disable p-refinement for."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels very strange to have algebraic information in a mesh action
@@ -22,71 +22,71 @@ | |||
input = test.i | |||
csvdiff = test_out.csv | |||
prereq = 'disable_p_refinement/lagrange_second_order_mesh' | |||
cli_args = 'Adaptivity/disable_p_refinement_for_families="hermite" AuxVariables/test/family=HERMITE AuxVariables/test/order=THIRD' | |||
cli_args = 'Mesh/disable_p_refinement_for_families="hermite" AuxVariables/test/family=HERMITE AuxVariables/test/order=THIRD' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I'm not a fan of this at all. What's the point of having an Adaptivity
block at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mesh could be p-refined by loading a checkpoint file. In such a case, we do not have [Adpativity]
but we still need to disable certain shape function families. I think this is the reason that we need to move this into [Mesh]
. We could move this into [Problem]
, but that is a syntax used for creating custom problems and may create implications. Having this parameter in [Mesh]
just mean that the created mesh will not support these shape functions. Most of times, users can just use the default I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be much better to save the information about what families to disable p-refinement for as restartable data in the problem/assembly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A mesh has absolutely no data about finite element families
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be possible to move the code directly in FEProblemBase::init
at its beginning. If so, disable_p_refinement_for_families
can be a parameter of [Problem]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is a restartable data, it won't be available before calling FEProblemBase::init
. We will have to call doingPRefinement
after data are restarted in FEProblemBase::initialSetup
. Will that be too late?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would be too late, but I am not 100% sure. It just needs to happen before a FE::reinit
occurs. I would like to at least try and see becuase I still think this parameter is a better fit in the Adaptivity
block as it is about adaptivity
ed501fb
to
aec4026
Compare
Job Modules parallel on aec4026 : invalidated by @YaqiWang Random failure? Cannot produce this on my mac. |
Job Coverage, step Generate coverage on 3c161ae wanted to post the following: Framework coverage
Modules coverageLevel set
Full coverage reportsReports
This comment will be updated on new commits. |
if (_displaced_mesh) | ||
_displaced_mesh->doingPRefinement(true); | ||
if (_displaced_problem) | ||
{ | ||
_displaced_problem->mesh().doingPRefinement(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two are the same
@@ -22,71 +22,71 @@ | |||
input = test.i | |||
csvdiff = test_out.csv | |||
prereq = 'disable_p_refinement/lagrange_second_order_mesh' | |||
cli_args = 'Adaptivity/disable_p_refinement_for_families="hermite" AuxVariables/test/family=HERMITE AuxVariables/test/order=THIRD' | |||
cli_args = 'Mesh/disable_p_refinement_for_families="hermite" AuxVariables/test/family=HERMITE AuxVariables/test/order=THIRD' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it would be too late, but I am not 100% sure. It just needs to happen before a FE::reinit
occurs. I would like to at least try and see becuase I still think this parameter is a better fit in the Adaptivity
block as it is about adaptivity
The issue is that this parameter |
Got a PETSc error with the new test I added if I move the
|
Let me take a look. Thanks for trying |
1 similar comment
Let me take a look. Thanks for trying |
Can you push a commit with the change to use restartable data so I can figure out why we are getting the PETSc error? |
The test in this PR can reproduce it. |
Did you not try declaring restartable data then? |
No. I stopped after seeing the error by moving the |
Per our discussion today, we want to have a parameter |
aec4026
to
acb8350
Compare
…a crash in tests/mesh/split_uniform_refine test
acb8350
to
3c161ae
Compare
@lindsayad this is ready again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite done, but I'll comment with what I have for now
framework/include/base/Assembly.h
Outdated
@@ -1923,7 +1923,7 @@ class Assembly | |||
* of quadrature points reflects the element p-level) | |||
* @param disable_p_refinement_for_families Families that we should disable p-refinement for | |||
*/ | |||
void havePRefinement(const std::vector<FEFamily> & disable_p_refinement_for_families); | |||
void havePRefinement(const std::set<FEFamily> & disable_p_refinement_for_families); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void havePRefinement(const std::set<FEFamily> & disable_p_refinement_for_families); | |
void havePRefinement(const std::unordered_set<FEFamily> & disable_p_refinement_for_families); |
@@ -1203,6 +1206,17 @@ class SubProblem : public Problem | |||
/// Whether p-refinement has been requested at any point during the simulation | |||
bool _have_p_refinement; | |||
|
|||
/// Indicate whether a family is disabled for p-refinement | |||
std::map<FEFamily, bool> _family_for_p_refinement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::map<FEFamily, bool> _family_for_p_refinement; | |
std::unordered_map<FEFamily, bool> _family_for_p_refinement; |
/// Indicate whether a family is disabled for p-refinement | ||
std::map<FEFamily, bool> _family_for_p_refinement; | ||
/// The set of variable families by default disable p-refinement | ||
std::set<FEFamily> _default_families_without_p_refinement = {libMesh::LAGRANGE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::set<FEFamily> _default_families_without_p_refinement = {libMesh::LAGRANGE, | |
std::unordered_set<FEFamily> _default_families_without_p_refinement = {libMesh::LAGRANGE, |
std::set<FEFamily> _default_families_without_p_refinement = {libMesh::LAGRANGE, | ||
libMesh::NEDELEC_ONE, | ||
libMesh::RAVIART_THOMAS, | ||
libMesh::LAGRANGE_VEC, | ||
libMesh::CLOUGH, | ||
libMesh::BERNSTEIN, | ||
libMesh::RATIONAL_BERNSTEIN}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Populate this in the constructor plz
3c161ae
to
fd3d5ba
Compare
This possibly will also enable p-refinement in mesh generators.
Closes #30048.