Skip to content

Apply constraints via element nonlinear residuals#3519

Merged
roystgnr merged 9 commits intolibMesh:develfrom
roystgnr:residual_constrain_on_elements
Apr 18, 2023
Merged

Apply constraints via element nonlinear residuals#3519
roystgnr merged 9 commits intolibMesh:develfrom
roystgnr:residual_constrain_on_elements

Conversation

@roystgnr
Copy link
Copy Markdown
Member

This, combined with updates in app codes, ought to fix #3504.

I'm going to need to retest my corresponding MOOSE branch (it was working before, but I've done a lot of cleanup to the libMesh branch since then) before we merge this, but I'm confident - getting MOOSE problems to work was much easier than getting every combination of adjoints and heterogeneous constraints and NewtonSolver-vs-PetscDiffSolver to work in libMesh examples.

With backwards compatibility shims, of course.  We're not PETSc.
We want to be able to turn this off since the Jacobian edits end up
being so slow.
The one in DiffSolver was necessary, but this might be useful.
This should let us play with the option easily in FEMSystem codes, which
should be good for verification purposes.
This is a relatively clean way to handle drift away from constraints at
an elemental rather than a global level.

The distinction between how we want to do heterogeneous constraints in
linear vs in nonlinear systems gets a little tricky.
@moosebuild
Copy link
Copy Markdown

Job Coverage on 5d92fb0 wanted to post the following:

Coverage

57f47a #3519 5d92fb
Total Total +/- New
Rate 60.15% 60.17% +0.02% 73.72%
Hits 49097 49174 +77 101
Misses 32524 32549 +25 36

Diff coverage report

Full coverage report

Warnings

  • New new line coverage rate 73.72% is less than the suggested 90.0%

This comment will be updated on new commits.

@roystgnr
Copy link
Copy Markdown
Member Author

My moose branch seems to be working - and if I disable global constraint handling while not using element residual constraints, it fails, so I think the test coverage is good.

@roystgnr
Copy link
Copy Markdown
Member Author

No changes in a GRINS run either.

Copy link
Copy Markdown
Member

@jwpeterson jwpeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can go ahead and merge. As discussed over IM, I don't think this change will affect our internal testing because we don't use the PetscNonlinearSolver.

{
#ifdef LIBMESH_HAVE_PETSC
PetscDiffSolver *solver = new PetscDiffSolver(system);
system.time_solver->diff_solver().reset(solver);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I don't like using raw new here, but I see it's just continuing an existing pattern. Could I convince you to change those 2 lines to:

system.time_solver->diff_solver() = std::make_unique<PetscDiffSolver>(system);
auto solver = cast_ptr<PetscDiffSolver*>(system.time_solver->diff_solver().get());

?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there's a lot of these so I can just update all of them in a separate PR.

* \p residual_constrain_element_vector processing option in
* \p DofMap.
*/
virtual void set_exact_constraint_enforcement(bool enable) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open curly brace to next line.

_exact_constraint_enforcement = enable;
}

bool exact_constraint_enforcement() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment re: curly brace.

* \p residual_constrain_element_vector processing option in
* \p DofMap.
*/
virtual void set_exact_constraint_enforcement(bool enable) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
virtual void set_exact_constraint_enforcement(bool enable) {
virtual void set_exact_constraint_enforcement(bool enable)
{

_exact_constraint_enforcement = enable;
}

bool exact_constraint_enforcement() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool exact_constraint_enforcement() {
bool exact_constraint_enforcement()
{

@roystgnr
Copy link
Copy Markdown
Member Author

I'll put in two separate PRs for the braces and the new-s.

@roystgnr roystgnr merged commit b1f0d7f into libMesh:devel Apr 18, 2023
@lindsayad
Copy link
Copy Markdown
Member

Thanks @roystgnr !

@roystgnr roystgnr deleted the residual_constrain_on_elements branch April 18, 2023 15:47
@roystgnr
Copy link
Copy Markdown
Member Author

This was the last thing I really wanted to get in before the next libMesh submodule update ... except that it feels like we're getting really close to figuring out our sawtooth MPI troubles, so waiting to see if we can get a fix/workaround into TIMPI is tempting.

roystgnr added a commit to roystgnr/libmesh that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constraint application slow

4 participants