beuler solver timestep and Jacobian calculation#3107
Merged
Conversation
The preconditioner depends on the timestep, so avoid changing timestep unless necessary. Allow timesteps to go past output time, then interpolate. If timesteps are adjusted then recalculate the Jacobian. This could be optimised to update the Jacobian and recalculate the preconditioner, without finite differencing the RHS.
New tunable inputs for adjustment when timestep fails, and when number of iterations is either too high or too low.
| int loop_count = 0; | ||
| do { | ||
| if (simtime >= target) | ||
| break; // Could happen if step over multiple outputs |
Contributor
There was a problem hiding this comment.
warning: statement should be inside braces [readability-braces-around-statements]
Suggested change
| break; // Could happen if step over multiple outputs | |
| if (simtime >= target) { | |
| break; // Could happen if step over multiple outputs | |
| } |
|
|
||
| // Note: If simtime = target then alpha = 0 | ||
| // and output_x = snes_x | ||
| BoutReal alpha = (simtime - target) / dt; |
Contributor
There was a problem hiding this comment.
warning: variable 'alpha' of type 'BoutReal' (aka 'double') can be declared 'const' [misc-const-correctness]
Suggested change
| BoutReal alpha = (simtime - target) / dt; | |
| xconst |
Member
|
This looks reasonable to me, but I thought PETSc could do this sort of interpolate automatically? Is it just easier to do this interpolation ourselves? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Jacobian that SNES uses for preconditioning depends on the timestep, so when the timestep is changed the preconditioner becomes less effective unless it is recalculated.
Adding more tuning parameters, will need to optimise for problems of interest.