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

Remove legacy Solver API #2285

Merged
merged 18 commits into from
May 13, 2021
Merged

Remove legacy Solver API #2285

merged 18 commits into from
May 13, 2021

Conversation

ZedThree
Copy link
Member

Remove the following Solver methods:

  • Solver::setRHS
  • Solver::setPrecon
  • Solver::setJacobian
  • Solver::setSplitOperator

and the following free functions:

  • bout_solve
  • bout_run
  • bout_constrain
  • physics_run
  • physics_init

bin/bout-v5-physics-model-upgrader.py can now fix all of the above.

Do we also want to remove Physics::bout_solve/constrain? Currently this just calls Solver::add/constrain. One could imagine removing or hiding the PhysicsModel::solver member, which would make keeping the bout_solve/constrain methods appealing.

(includes the bug fix in #2283)

@ZedThree ZedThree added this to the BOUT-5.0 milestone Apr 15, 2021
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

examples/constraints/laplace-dae/laplace_dae.cxx Outdated Show resolved Hide resolved
src/solver/impls/arkode/arkode.cxx Outdated Show resolved Hide resolved
src/solver/impls/cvode/cvode.cxx Outdated Show resolved Hide resolved
status = model->runConvective(t);
}else
status = (*phys_conv)(t);
status = model->runConvective(t);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: Value stored to status is never read [clang-analyzer-deadcode.DeadStores]

status = model->runConvective(t);
    ^
src/solver/solver.cxx:1239:5: note: Value stored to 'status' is never read

src/solver/solver.cxx Show resolved Hide resolved
src/solver/solver.cxx Show resolved Hide resolved
@johnomotani
Copy link
Contributor

I've never used the PhysicsModel::bout_solve() methods. I do think it'd be nicer to have only one interface for doing a thing (unless there's a good reason to have more), i.e. either remove PhysicsModel::bout_solve(), etc., or make the solver object private and require using PhysicsModel methods. The second option seems nice in many ways, but would require copying quite a lot of the Solver API into PhysicsModel methods, which seems like a maintenance headache so at the moment I think my vote is to keep solver accessible directly and remove PhysicsModel::bout_solve(), etc.

Copy link
Contributor

@johnomotani johnomotani left a comment

Choose a reason for hiding this comment

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

bout-v5-physics-model-upgrader.py was too much for me to get my head around, so I skipped that, but everything else looks good to me.

examples/constraints/laplace-dae/laplace_dae.cxx Outdated Show resolved Hide resolved
@ZedThree
Copy link
Member Author

Grepping the models in examples, it looks like the Solver methods used are:

  • solver->add
  • solver->addMonitor
  • solver->addTimestepMonitor
  • solver->constraint
  • solver->constraints

which is not terribly many. bout_solve and bout_constrain already cover add and constraint.

I think I will them for now, maybe we can have a bit of a discussion about the direction to go in at the BUG meeting.

@bendudson
Copy link
Contributor

I agree this is a good idea, and having one way to do things is definitely a good idea. I would like to think about what changes we might like to make in future, so that we don't have to change interface again soon.
I would like to see a solver interface which didn't have Solver holding pointers to PhysicsModel fields. Eventually Solver could pass fields to the physics model as some kind of set/vector/map of fields; maybe an Options tree. Would the interface we chose now be compatible with this?

@ZedThree
Copy link
Member Author

I think either interface, via Solver methods or PhysicsModel methods, would work with that. If we went with a PhysicsModel we could hide the solver instance which is appealing.

Picking an interface can wait for another PR when we've thought about it a bit more.

@ZedThree ZedThree mentioned this pull request May 4, 2021
@ZedThree ZedThree merged commit f33764d into next May 13, 2021
@ZedThree ZedThree deleted the remove-legacy-solver-api branch May 13, 2021 08:50
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.

None yet

3 participants