Skip to content
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

CG: distribute periodicity and hanging node constraints #651

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/exadg/poisson/spatial_discretization/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ Operator<dim, n_components, Number>::solve(VectorType & sol,
{
laplace_operator.set_time(time);
laplace_operator.set_inhomogeneous_boundary_values(sol);
affine_constraints_periodicity_and_hanging_nodes.distribute(sol);
}

return n_iterations;
Expand Down
3 changes: 3 additions & 0 deletions include/exadg/structure/spatial_discretization/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ Operator<dim, Number>::compute_initial_acceleration(VectorType & initial_a
// Set initial acceleration for the Dirichlet degrees of freedom so that the initial
// acceleration is also correct on the Dirichlet boundary
mass_operator.set_inhomogeneous_boundary_values(initial_acceleration);
affine_constraints_periodicity_and_hanging_nodes.distribute(initial_acceleration);
}
}

Expand Down Expand Up @@ -935,6 +936,7 @@ Operator<dim, Number>::solve_nonlinear(VectorType & sol,
// set inhomogeneous Dirichlet values in order to evaluate the nonlinear residual correctly
elasticity_operator_nonlinear.set_time(time);
elasticity_operator_nonlinear.set_inhomogeneous_boundary_values(sol);
affine_constraints_periodicity_and_hanging_nodes.distribute(sol);
Copy link
Member

Choose a reason for hiding this comment

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

Most changes are made after solving. This change is made before solving. Why?

Copy link
Member

Choose a reason for hiding this comment

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

Did you see the TODO a few lines below? This code that is currently commented, but code that we might want to take care of as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most changes are made after solving. This change is made before solving. Why?

see #651 (comment)
Here, the sol is then used in the Newton solver to update the linearization vector
https://github.com/richardschu/exadg/blob/c5f489f1085b78f951d53cc62f510028c74c38be/include/exadg/solvers_and_preconditioners/newton/newton_solver.h#L79
and evaluate the residual
https://github.com/richardschu/exadg/blob/c5f489f1085b78f951d53cc62f510028c74c38be/include/exadg/solvers_and_preconditioners/newton/newton_solver.h#L104

Otherwise we have the zero hanging node values in the linearization vector.
I was surprised to not see an impact on the nonlinear iteration count, but maybe the solution we are searching for (with zero values at hanging nodes) is still close enough to the "real" one with correct hanging node values.

Copy link
Member

Choose a reason for hiding this comment

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

I agree that we need this vector for the evaluation of the residual/linearized operator. And it is also clear to me that we need to take these constraints into account correctly when evaluating the integrals. However, from a software design perspective, the problem is in my opinion that responsibilities are beginning to blur if we add these lines here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Operator has all affine_constraints objects, so I think it should also enforce the constraints.

I would not put it in the postprocessor, since the idea (up to now) for the postprocessor was, that it is entirely optional (see throughput applications, where it is not even set up). If we move the lines, I think they have to go together with the
elasticity_operator_nonlinear.set_inhomogeneous_boundary_values(sol);
otherwise we split things up unintuitively(?).

Where is in your opinion the right place to enforce constraints on a vector?
The Operator has the affine_constraints, so it should do it, right?
The sol could already have the right BCs enforced when calling solve_nonlinear(sol).
So should we add a operator->enforce_constraints(), which is called before solve_nonlinear and solve_linear(sol) from the driver(s)? But that is also not really intuitive from the driver side: How would I expect that I have to update the vectors constraints due to internals of how the operator works? For the postprocessor, we could think about it, but then it would be different for linear and nonlinear solvers, which is also kinda confusing. So I would rather say, maybe introduce a operator->enforce_constraints() to bundle the constraints, but when calling operator->solve_nonlinear(sol) or operator->solve_linear(sol), this should be done in the operator side automatically where needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you see the TODO a few lines below? This code that is currently commented, but code that we might want to take care of as well.

I think we should remove it, when coming up with something new here.


// call Newton solver
Newton::UpdateData update;
Expand Down Expand Up @@ -1002,6 +1004,7 @@ Operator<dim, Number>::solve_linear(VectorType & sol,
// Set Dirichlet degrees of freedom according to Dirichlet boundary condition.
elasticity_operator_linear.set_time(time);
elasticity_operator_linear.set_inhomogeneous_boundary_values(sol);
affine_constraints_periodicity_and_hanging_nodes.distribute(sol);

return iterations;
}
Expand Down
Loading