-
Notifications
You must be signed in to change notification settings - Fork 35
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
base: master
Are you sure you want to change the base?
Conversation
…bute the hanging node and periodic constraints as well
Can you explain why iteration counts are changing, because issue #650 mostly talks about the impact in terms of postprocessing/visualization? |
I think we should discuss again the design. When looking at the code changes, it might be that we have forgotten it somewhere. I think this originates from the fact that the new line of code is added at many places in the |
Because of your comment "Until then, this is on do not merge.", I converted this PR to a draft. |
Yes, this is not unlikely. I wonder right now what periodic BCs would mean for structure problems? Wouldn't the system matrix be singular in this case so that the problem is not solvable? (edit: in a single direction it would work I guess, if the remaining BCs are consistent with the periodicity constraints) |
Isn't it the same as with the other singular systems we deal with (e.g. Poisson problem with pure periodic/Neumann conditions)? That means we have to make sure the system/rhs are compatible with the null space and in case of multigrid preserve the null space during the whole hierarchy and coarse solver? |
@@ -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); |
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.
Most changes are made after solving. This change is made before solving. Why?
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.
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.
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.
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.
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 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.
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 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.
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.
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.
Ok so I repeated the tests with the linear elasticity solver (due to #652 I cannot use the steady solver currently).
|
I would agree on that, but I have not tested it myself! |
My logic was to add it at places, where we call |
@kronbichler agree. I should make my statement more precise. I do not want to argue that one could not deal with this technically, but wondered whether we could expect the problem for such a setup to be solvable with the present implementation apart from |
No I have no application in mind that needs that. It is simply because that is the name of the object |
@richardschu thanks for your explanations. What I do not understand is why the operator evaluation is affected by this. During initialization, I thought that MatrixFree receives both AffineConstraints objects and then evaluates the constraints correctly in |
In general, the design internally is such that I made a small search
which shows all appearances of the exadg/include/exadg/operators/operator_base.cpp Lines 2174 to 2180 in 0075db2
AffineConstraints object of the right type or in the postprocessor.
The question I have here is at which level we would like the interpolation of constraints to happen. As I elaborated previously, one concern with |
I think one solution would be to introduce
What do you think @nfehn? |
fixes #650
For the structure module, similar problems might appear. Maybe no one solved structure problems with hanging nodes or periodic constraints yet? There, it would actually impact the performance of the nonlinear solver I believe, as we distribute constraints on the linearization vector. I did not test the changes in the structure module yet, but I doubt any of these consider hanging nodes anyways. Will test manually and then update here. Until then, this is on
do not merge
.