WIP: Save Jacobian to file - #3464
Open
bendudson wants to merge 1 commit into
Open
Conversation
- PetscPreconditioner saves Jacobian using PETSc binary or ASCII format. - Solver saves metadata: A Jacobian global index offset field to the dmp files, and a JSON file with the variable information. - SNES solver outputs Jacobian if `save_jacobian = true`. An option `jacobian_export_kind` select whether the Jacobian is calculated using the nonlinear system being solved (that depends on timestep and scaling), the scaled RHS function (that depends on variable scaling), or the raw `rhs` function is saved.
| .withDefault("jacobian")), | ||
| jacobian_export_format((*options)["jacobian_export_format"] | ||
| .doc("Format for saved Jacobian matrices: binary, ascii") | ||
| .withDefault(PetscMatrixExportFormat::binary)) {} |
Contributor
There was a problem hiding this comment.
warning: no header providing "PetscMatrixExportFormat" is directly included [misc-include-cleaner]
src/solver/impls/snes/snes.cxx:1:
+ #include "bout/petsc_preconditioner.hxx"|
|
||
| PetscErrorCode ComputeJacobianDefaultMaybeExport(SNES snes, Vec x1, Mat Jac, Mat Jac_new, | ||
| void* ctx) { | ||
| PetscErrorCode err = SNESComputeJacobianDefault(snes, x1, Jac, Jac_new, ctx); |
Contributor
There was a problem hiding this comment.
warning: variable 'err' of type 'PetscErrorCode' (aka 'int') can be declared 'const' [misc-const-correctness]
Suggested change
| PetscErrorCode err = SNESComputeJacobianDefault(snes, x1, Jac, Jac_new, ctx); | |
| ctx) {const |
|
|
||
| Field3D Solver::jacobianIndexBase(int localStart) { return globalIndex(localStart); } | ||
|
|
||
| std::vector<Solver::JacobianVariableMetadata> Solver::getJacobianMetadata2D() const { |
Contributor
There was a problem hiding this comment.
warning: no header providing "std::vector" is directly included [misc-include-cleaner]
src/solver/solver.cxx:59:
+ #include <vector>
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.
Work in progress on utilities for saving the solver Jacobian.
save_jacobian = true. An optionjacobian_export_kindselect whether the Jacobian is calculated using the nonlinear system being solved (that depends on timestep and scaling), the scaled RHS function (that depends on variable scaling), or the rawrhsfunction is saved.