-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNonlinearSystem.h
99 lines (82 loc) · 3.13 KB
/
NonlinearSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef NUMLIB_NONLINEARSYSTEM_H
#define NUMLIB_NONLINEARSYSTEM_H
#include "EquationSystem.h"
#include "Types.h"
namespace NumLib
{
//! \addtogroup ODESolver
//! @{
/*! A System of nonlinear equations.
*
* \tparam NLTag a tag indicating the method used for solving the equation.
*/
template <NonlinearSolverTag NLTag>
class NonlinearSystem;
/*! A System of nonlinear equations to be solved with the Newton-Raphson method.
*
* The Newton-Raphson method will iterate the linearized equation
* \f$ \mathtt{Jac} \cdot (-\Delta x_i) = \mathtt{res} \f$.
*/
template <>
class NonlinearSystem<NonlinearSolverTag::Newton> : public EquationSystem
{
public:
//! Assembles the residual at the point \c x.
virtual void assembleResidualNewton(GlobalVector const& x) = 0;
//! Assembles the Jacobian of the residual at the point \c x.
virtual void assembleJacobian(GlobalVector const& x) = 0;
/*! Writes the residual at point \c x to \c res.
*
* \pre assembleResidualNewton() must have been called before
* with the same argument \c x.
*
* \todo Remove argument \c x.
*/
virtual void getResidual(GlobalVector const& x,
GlobalVector& res) const = 0;
/*! Writes the Jacobian of the residual to \c Jac.
*
* \pre assembleJacobian() must have been called before.
*/
virtual void getJacobian(GlobalMatrix& Jac) const = 0;
//! Apply known solutions to the solution vector \c x.
virtual void applyKnownSolutions(GlobalVector& x) const = 0;
//! Apply known solutions to the linearized equation system
//! \f$ \mathit{Jac} \cdot (-\Delta x) = \mathit{res} \f$.
virtual void applyKnownSolutionsNewton(GlobalMatrix& Jac, GlobalVector& res,
GlobalVector& minus_delta_x) = 0;
};
/*! A System of nonlinear equations to be solved with the Picard fixpoint
* iteration method.
*
* The Picard method will iterate the linearized equation
* \f$ \mathtt{A} \cdot x_i = \mathtt{rhs} \f$.
*/
template <>
class NonlinearSystem<NonlinearSolverTag::Picard> : public EquationSystem
{
public:
//! Assembles the linearized equation at point \c x.
virtual void assembleMatricesPicard(GlobalVector const& x) = 0;
//! Writes the linearized equation system matrix to \c A.
virtual void getA(GlobalMatrix& A) const = 0;
//! Writes the linearized equation system right-hand side to \c rhs.
virtual void getRhs(GlobalVector& rhs) const = 0;
//! Apply known solutions to the solution vector \c x.
virtual void applyKnownSolutions(GlobalVector& x) const = 0;
//! Apply known solutions to the linearized equation system
//! \f$ A \cdot x = \mathit{rhs} \f$.
virtual void applyKnownSolutionsPicard(GlobalMatrix& A, GlobalVector& rhs,
GlobalVector& x) = 0;
};
//! @}
}
#endif // NUMLIB_NONLINEARSYSTEM_H