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

Assertion error in solve! for transient operators #81

Open
oriolcg opened this issue Apr 8, 2022 · 12 comments
Open

Assertion error in solve! for transient operators #81

oriolcg opened this issue Apr 8, 2022 · 12 comments
Assignees

Comments

@oriolcg
Copy link
Member

oriolcg commented Apr 8, 2022

Hi @amartinhuertas , @fverdugo . I'm getting an assertion error here:

@assert cache.op === op
when using PETScNonlinearSolver in transient problem. I get the error at the second time step, which makes me think that indeed op and cache.op are not the same. Should that be the case? If yes, what would be the best solution to this issue?

@hyun825
Copy link

hyun825 commented Oct 12, 2022

Hi! I am getting the same error at the second time step after convergence of nonlinear solver in the first time step.
ERROR: AssertionError: cache.op === op

@carlodev
Copy link

Using the theta method I found out that cache.op.tθ is not updated at the second time step, while op.tθ it is; and easy fix that seems to work is:
cache.op = op

@oriolcg
Copy link
Member Author

oriolcg commented Nov 14, 2022

I would say that cache.op shouldn't be the same as op . I believe this assert should be removed (or not applied) for time-dependent problems.

@carlodev
Copy link

I tested the PETScNonlinearSolver to solve the Poisson problem, precisely the one in the transient tutorial. I can't see any difference in comparing the solution with the Gridap internal NLSolver. I know it is a Linear Problem, but for testing purpose seems reasonable. Just commenting cache.op === op does not produce the same result, while adding also cache.op = op produce the same results as using the internal NLSolver. But honestly, the difference between op and cache.op is not really clear to me.

@oriolcg
Copy link
Member Author

oriolcg commented Nov 14, 2022

Where do you add this operation: cache.op = op ?

@oriolcg
Copy link
Member Author

oriolcg commented Nov 14, 2022

I see. The problem is that the only way PETScNonlinearSolver knows about the operator (i.e. residual) is through the cache. If this cache is not updated at each time step, the residual is computed taking into account outdated data. I think what you do here is a solution, but not sure if the most elegant/efficient. Any thoughts @amartinhuertas @fverdugo ?

@oriolcg
Copy link
Member Author

oriolcg commented Dec 21, 2022

Hi @amartinhuertas and @fverdugo, what is your view on this issue? should we replace cache.op by op in the solve! function?

@amartinhuertas
Copy link
Member

amartinhuertas commented Dec 21, 2022

Hi @oriolcg (and the others) ! Thanks for taking care of this.

I think that cache.op = op is working in your particular case because there is "compatibility" among the nonlinear operators being generated at each time step, e.g., the domain (trial FE space) and range (test FE space) of the operators, and how they are distributed among processors, match. This is certainly going to be the case in all transient simulations (as far as one does not have adaptive mesh refinement + mesh redistribution in a parallel context, we dont have this yet anyway).

However, the concern I have of just doing cache.op = op is that one opens the door to passing an op with domain/ranges not compatible with cache.op and this is for sure going to cause trouble if not further action is taken.

Ideally, what I think we should do is:

  1. If cache.op and op are the same, do nothing.
  2. If cache.op and op are different:
    2.1) If they have compatible domain/ranges, cache.op = op.
    2.2) If not, destroy the current cache and generate a new one.

@oriolcg
Copy link
Member Author

oriolcg commented Dec 22, 2022

Hi @amartinhuertas ,

I agree with this scheme, but I see one implementation issue. It is not clear to me how to check the domain/range size of op since the abstract type NonlinearOperator only has residual and jacobian as required methods. To check the size it would require to allocate the jacobian, which I think it's not a good solution. Any suggestion on this?

@oriolcg
Copy link
Member Author

oriolcg commented Jan 2, 2023

Hi @amartinhuertas ,

I agree with this scheme, but I see one implementation issue. It is not clear to me how to check the domain/range size of op since the abstract type NonlinearOperator only has residual and jacobian as required methods. To check the size it would require to allocate the jacobian, which I think it's not a good solution. Any suggestion on this?

@amartinhuertas @fverdugo , any view on this?

@amartinhuertas
Copy link
Member

@amartinhuertas @fverdugo , any view on this?

As far I can see, and you point out, there are expressivity limitations in the abstract concept of a NonLinearOperator as now conceived in Gridap. Thus, if we want to implement the algorithm in #81 (comment), I am afraid we should provide a richer abstract interface for NonLinearOperators, in the spirit, of e.g., https://www.sciencedirect.com/science/article/pii/S089812211630205X

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

No branches or pull requests

5 participants