OGS
PETScNonlinearSolver.h
Go to the documentation of this file.
1
11#pragma once
12#ifdef USE_PETSC
13
14#include <petscsnes.h>
15
17#include "NonlinearSolver.h"
19
20namespace NumLib
21{
25{
26public:
29
38 int maxiter,
39 std::string prefix);
40
42 void setEquationSystem(System& eq, ConvergenceCriterion& conv_crit);
43
44 void compensateNonEquilibriumInitialResiduum(bool const value);
45
47 std::vector<GlobalVector*> const& x,
48 std::vector<GlobalVector*> const& x_prev,
49 int const process_id) override;
50
52 std::vector<GlobalVector*>& x,
53 std::vector<GlobalVector*> const& x_prev,
54 std::function<void(int, std::vector<GlobalVector*> const&)> const&
55 postIterationCallback,
56 int const process_id) override;
57
58private:
60
63
64 std::size_t _residual_id = 0u;
65 std::size_t _jacobian_id = 0u;
66
67 std::size_t _petsc_x_id = 0u;
68 std::size_t _petsc_jacobian_id = 0u;
69 std::size_t _petsc_residual_id = 0u;
70
71 // clang-format off
74 // clang-format on
75};
76
78
79} // namespace NumLib
80#endif // USE_PETSC
ConvergenceCriterion * _convergence_criterion
NonlinearSolverStatus solve(std::vector< GlobalVector * > &x, std::vector< GlobalVector * > const &x_prev, std::function< void(int, std::vector< GlobalVector * > const &)> const &postIterationCallback, int const process_id) override
void setEquationSystem(System &eq, ConvergenceCriterion &conv_crit)
Set the nonlinear equation system that will be solved.
PETScNonlinearSolver(GlobalLinearSolver &linear_solver, int maxiter, std::string prefix)
std::size_t _jacobian_id
ID of the Jacobian matrix.
void compensateNonEquilibriumInitialResiduum(bool const value)
std::size_t _residual_id
ID of the residual vector.
void calculateNonEquilibriumInitialResiduum(std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id) override
Status of the non-linear solver.