OGS
PETScNonlinearSolver.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5#ifdef USE_PETSC
6
7#include <petscsnes.h>
8
10#include "NonlinearSolver.h"
12
13namespace NumLib
14{
18{
19public:
22
31 int maxiter,
32 std::string prefix);
33
35 void setEquationSystem(System& eq, ConvergenceCriterion& conv_crit);
36
37 void compensateNonEquilibriumInitialResiduum(bool const value);
38
40 std::vector<GlobalVector*> const& x,
41 std::vector<GlobalVector*> const& x_prev,
42 int const process_id) override;
43
45 std::vector<GlobalVector*>& x,
46 std::vector<GlobalVector*> const& x_prev,
47 std::function<void(int, bool, std::vector<GlobalVector*> const&)> const&
48 postIterationCallback,
49 int const process_id) override;
50
51private:
53
56
57 std::size_t _residual_id = 0u;
58 std::size_t _jacobian_id = 0u;
59
60 std::size_t _petsc_x_id = 0u;
61 std::size_t _petsc_jacobian_id = 0u;
62 std::size_t _petsc_residual_id = 0u;
63
64 // clang-format off
67 // clang-format on
68};
69
71
72} // namespace NumLib
73#endif // USE_PETSC
MathLib::EigenLisLinearSolver GlobalLinearSolver
NonlinearSolverStatus solve(std::vector< GlobalVector * > &x, std::vector< GlobalVector * > const &x_prev, std::function< void(int, bool, std::vector< GlobalVector * > const &)> const &postIterationCallback, int const process_id) override
ConvergenceCriterion * _convergence_criterion
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)
NonlinearSystem< NonlinearSolverTag::Newton > System
Type of the nonlinear equation system to be solved.
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.