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

Merge next into outerloop PR #2498

Merged
merged 104 commits into from
Feb 15, 2022
Merged

Conversation

ZedThree
Copy link
Member

Fixes a few conflicts between next and #2397

ZedThree and others added 30 commits September 7, 2021 17:54
Shared objects should be executable
Fix permission of shared objects
Solvers can pass a flag to say whether the function can be linearised
(e.g. inside inner linear solve, or Jacobian calculation).
Physics models don't have to use the argument: rhs functions with
a single (time) argument continue to work.
Should use const reference to avoid copying index
Deprecated, flagged as warning by Apple Clang
Enables large reductions in the number of iterations needed to
calculate the Jacobian elements. Having the Jacobian then enables
good preconditioning.

Simple conduction example, nout=5 and timestep=10:

PVODE:
```
1.000e+01        644       1.25e-01    74.9    0.0    0.7   13.4   10.9
2.000e+01        161       4.41e-02    50.9    0.0    0.4   29.4   19.2
```

beuler, SNESType = anderson
```
1.000e+01        962       2.13e-01    65.8    0.0    0.7    8.2   25.4
2.000e+01        347       8.20e-02    61.3    0.0    0.6   14.0   24.0
```

beuler, SNESType = newtonls, matrix free (no Jacobian)
```
1.000e+01       3389       5.68e-01    89.2    0.0    0.8    3.3    6.6
2.000e+01       2325       3.55e-01    89.1    0.0    0.8    3.3    6.8
```

beuler, SNESType = newtonls, with Jacobian, no coloring
```
1.000e+01        833       1.53e-01    78.8    0.0    0.7   12.1    8.4
2.000e+01        521       9.81e-02    76.6    0.0    0.8   12.3   10.4
```

beuler, SNESType = newtonls, with Jacobian coloring
```
1.000e+01         85       3.78e-02    33.3    0.0    0.3   46.5   19.9
2.000e+01         57       3.16e-02    26.4    0.0    0.2   48.9   24.6
```
Was destroying the iscoloring object before setup, and then
reverting to brute-force calculation of the Jacobian.
Describe all the options, and how to use newtonls with Jacobian
coloring.
- Defaults to using coloring to calculate a Jacobian
- Iterations and lag jacobian set to values that work for
  SD1D tests so far.
- Diagnostic outputs now include number of linear iterations
  and number of failures.
Reflect changes in defaults, and some notes on when these
are likely to fail.
Clang tidy suggestions
If timestep falls below this threshold, reset the Jacobian and
preconditioner, and try to take a large timestep.

The idea is that sometimes the solver gets stuck in a local
minimum, and the observation that sometimes stopping the
simulation and restarting can help.
- If resetting doesn't work once, quit rather than get stuck
  in an infinite loop
- Turn off the predictor when resetting. The predictor seems to
  make convergence slower when nearly in steady state.
Missing on for loops in imex-bdf2 code
Thanks to @dschworer suggestion.

[skip ci]
If a step which would have ended at an output time fails,
the looping variable should be reset to true so that the
retry occurs.

Thanks to Mike Kryjak for the report
Sets the linear solver and preconditioner to use
Enables much quicker calculation of steady-state solutions than
CVODE typically can.
beuler sometimes appears to reach a steady state, with timesteps
continuously increasing, and zero nonlinear iterations e.g.

```
Time: 2189781.780775979, timestep: 9781.780775979214, nl iter: 0, lin iter: 1
Time: 2190000.0, timestep: 10759.958853577136, nl iter: 0, lin iter: 1
2.190e+06         31       1.94e+00    94.9    0.0    0.0    3.0    2.0
Time: 2200000.0, timestep: 10759.958853577136, nl iter: 0, lin iter: 1
2.200e+06         16       1.05e+00    91.0    0.0    0.0    6.3    2.7
Time: 2210000.0, timestep: 10759.958853577136, nl iter: 0, lin iter: 1
2.210e+06         16       1.08e+00    91.9    0.0    0.0    5.5    2.6
Time: 2220000.0, timestep: 10759.958853577136, nl iter: 0, lin iter: 1
```

Restarting from this state however shows that it is not in steady
state and even doesn't converge.

To try to prevent this, force SNES to take at least one iteration, add
more checks and reporting.
Will sometimes hit a state where snes stops after zero iterations
(due to stol tolerance), and continues "converging" until the end
of the simulation. Taking a small Euler step seems to help.
Add ability to change line search type.

When SNES fails to converge, print diagnostic information on the
fields and their time derivatives.
Recent change in commit hash broke this

Fixes #2461
Ambiguous between mpark:: and std::visit when compiling with GCC
11.1 (Arch linux)
Before this change, setting an integer/BoutReal to, for example,
'true', would yield:

    Cannot find variable 'true'

With this change, now the error is:

    Couldn't get BoutReal from option conduction:chi = 'true': \
    Cannot find variable 'true'
ZedThree and others added 26 commits January 6, 2022 15:19
Simplify specifying factory creator arguments
Co-authored-by: johnomotani <john.omotani@ukaea.uk>
…imple-ctors

Command-line help for input options for factory created types
Co-authored-by: Peter Hill <zed.three@gmail.com>
Should use bout::utils::visit, rather than std::visit.
Without this fix an compiler error occurs with GCC 11.1.0
Back-port beuler/snes improvements to master
Limits how large the timestep can be made, to try and prevent
repeated increases and failures
…ssion

Cache `Coordinates::zlength()` result
* master: (27 commits)
  Fix contributor's name
  Update release date
  Update changelog
  Revert SONAME/SOVERSION to 4.4.0
  Fix test-bout-override-default-option for cmake
  Update DOI and release date for 4.4.1
  Update changelog for 4.4.1
  Update translation files for 4.4.1
  Bump version to 4.4.1
  Enable setting SNES solver PETSc options from input file
  Try to consolidate some loops/branches in SNESSolver
  Use `BOUT_ENUM_CLASS` for `SNESSolver::equation_form`
  Use `std::vector/array` instead of C style arrays
  Remove `__FUNCT__` macros for PETSc callbacks
  Update backport of beuler/snes solver
  Fix typo in docs
  Remove IDL section and recommend xBOUT for analysis
  Recommend using xBOUT for manipulating restart files
  Update log output in "running BOUT++" manual section
  Move "Initialising solver" message to top of `Solver::solve`
  ...
- Ensure that the linear boolean flag is passed through to the rhs
  function
- Formatting strings e.g. `%e` -> `{}`
API includes a `linear` flag, which is set to `true` when
a linearised rhs() function can be used.
* next: (37 commits)
  Merge in Solver and PhysicsModel changes from next
  SNES solver merges
  Fix contributor's name
  Update release date
  Update changelog
  Fix ambiguous visit call
  Revert SONAME/SOVERSION to 4.4.0
  Fix test-bout-override-default-option for cmake
  Update DOI and release date for 4.4.1
  Update changelog for 4.4.1
  Update translation files for 4.4.1
  Bump version to 4.4.1
  Enable setting SNES solver PETSc options from input file
  Try to consolidate some loops/branches in SNESSolver
  Use `BOUT_ENUM_CLASS` for `SNESSolver::equation_form`
  Use `std::vector/array` instead of C style arrays
  Remove `__FUNCT__` macros for PETSc callbacks
  Update backport of beuler/snes solver
  Fix typo in docs
  Remove IDL section and recommend xBOUT for analysis
  ...
Add matrix coloring to beuler solver (and fix imexbdf2)
* next: (78 commits)
  [skip ci] Apply black changes
  Merge in Solver and PhysicsModel changes from next
  SNES solver merges
  Add max_timestep option to beuler solver
  Fix contributor's name
  Update release date
  Update changelog
  Fix ambiguous visit call
  Update src/solver/impls/snes/snes.cxx
  Fix typo in help text
  Add command line options for printing help for types
  Ensure all factories can construct from name + options
  Bump fmt to 8.1.0; fix implicit cast of enum class to int
  Simplify specifying factory creator arguments
  Fix upper Y boundary too
  [skip ci] Apply black changes
  SNES/beuler solver: Fix out of bounds indices
  Revert SONAME/SOVERSION to 4.4.0
  Fix test-bout-override-default-option for cmake
  Update DOI and release date for 4.4.1
  ...
Copy link
Contributor

@bendudson bendudson left a comment

Choose a reason for hiding this comment

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

Thanks @ZedThree !

@bendudson bendudson merged commit 3e78ec7 into next-hypre-outerloop-cuda-merged Feb 15, 2022
@bendudson bendudson deleted the hypre-merge-next branch February 15, 2022 19:34
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