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

[CORE] Move initial residual assignment #12604

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

juancamarotti
Copy link

This PR addresses #12394 [Incorrect initial residuals for convergence criteria in CoSim]

Changes

We moved the initial residual assignment from InitializeSolutionStep to PostCriteriawith the condition that the NL_ITERATION_NUMBER must be 1. This ensures that the initial residual is updated between coupling iterations.

Drawback

The initial residual is computed after the first non-linear iteration, since we do not have access to the residual before the first one.

Outlook

Properly solving this problem would mean adding new virtual functions for the initialization and finalization of the non linear solvers and related objects. This would be an extensive change what we are planning to implement in the future,. However, for now, this solution is less inaccurate than the current state.

FYI @philbucher @matekelemen @sunethwarna @Igarizza

Copy link
Member

@rubenzorrilla rubenzorrilla left a comment

Choose a reason for hiding this comment

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

This means that you're always doing a non-linear iteration (with the corresponding call to the linear solver) even though the residual criteria are fulfilled. If so, this is in my opinion a delicate change that requires careful discussion.

@juancamarotti
Copy link
Author

With this new implementation, convergence could be achieved in the first iteration in an absolute sense. Is that what you mean? @rubenzorrilla

@rubenzorrilla
Copy link
Member

With this new implementation, convergence could be achieved in the first iteration in an absolute sense. Is that what you mean? @rubenzorrilla

I mean in zero iteration (if provided guess already accomplishes with the convergence criteria)

@matekelemen
Copy link
Contributor

matekelemen commented Aug 3, 2024

I mean in zero iteration (if provided guess already accomplishes with the convergence criteria)

Ok, having a closer look at the implementation of ResidualBasedNewtonRaphsonStrategy it looks like with this PR, we're actually computing the initial residual before the first nonlinear iteration, which is exactly what we want so there's no drawback.

The confusion comes from NL_ITERATION_NUMBER being set to 1 before the first iteration. At the very beginning of the first nonlinear iteration, NL_ITERATION_NUMBER is incremented, so the first iteration actually runs with iteration number 2 ...

@juancamarotti
Copy link
Author

I mean in zero iteration (if provided guess already accomplishes with the convergence criteria)

Ok, having a closer look at the implementation of ResidualBasedNewtonRaphsonStrategy it looks like with this PR, we're actually computing the initial residual before the first nonlinear iteration, which is exactly what we want so there's no drawback.

The confusion comes from NL_ITERATION_NUMBER being set to 1 before the first iteration. At the very beginning of the first nonlinear iteration, NL_ITERATION_NUMBER is incremented, so the first iteration actually runs with iteration number 2 ...

I agree with @matekelemen on this point. What do you think @rubenzorrilla?

@rubenzorrilla
Copy link
Member

I mean in zero iteration (if provided guess already accomplishes with the convergence criteria)

Ok, having a closer look at the implementation of ResidualBasedNewtonRaphsonStrategy it looks like with this PR, we're actually computing the initial residual before the first nonlinear iteration, which is exactly what we want so there's no drawback.
The confusion comes from NL_ITERATION_NUMBER being set to 1 before the first iteration. At the very beginning of the first nonlinear iteration, NL_ITERATION_NUMBER is incremented, so the first iteration actually runs with iteration number 2 ...

I agree with @matekelemen on this point. What do you think @rubenzorrilla?

  • There are more stategies than the NR that might be using this
  • Tests from several applications are failing so I'm still a bit hesitant about saying that the behavior is exactly the same...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants