OGS
NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton > Class Referencefinal

Detailed Description

Time discretized first order implicit quasi-linear ODE; to be solved using the Newton-Raphson method for resolving nonlinearities.

See also
ODESystemTag::FirstOrderImplicitQuasilinear

Definition at line 57 of file TimeDiscretizedODESystem.h.

#include <TimeDiscretizedODESystem.h>

Inheritance diagram for NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >:
[legend]
Collaboration diagram for NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >:
[legend]

Public Types

using ODE = ODESystem<ODETag, NonlinearSolverTag::Newton>
 The type of ODE.
using MatTrans = MatrixTranslator<ODETag>
using TimeDisc = TimeDiscretization
 A shortcut for a general time discretization scheme.

Public Member Functions

 TimeDiscretizedODESystem (const int process_id, ODE &ode, TimeDisc &time_discretization)
 ~TimeDiscretizedODESystem () override
void assemble (std::vector< GlobalVector * > const &x_new_timestep, std::vector< GlobalVector * > const &x_prev, int const process_id) override
std::vector< GlobalIndexTypegetIndicesOfResiduumWithoutInitialCompensation () const override
void setReleaseNodalForces (GlobalVector const *r_neq, int const process_id) override
void getResidual (GlobalVector const &x_new_timestep, GlobalVector const &x_prev, GlobalVector &res) const override
void getJacobian (GlobalMatrix &Jac) const override
void computeKnownSolutions (GlobalVector const &x, int const process_id) override
void applyKnownSolutions (GlobalVector &x) const override
void applyKnownSolutionsNewton (GlobalMatrix &Jac, GlobalVector &res, GlobalVector const &x, GlobalVector &minus_delta_x) const override
void applyKnownSolutionsPETScSNES (GlobalMatrix &Jac, GlobalVector &res, GlobalVector &x) const override
void updateConstraints (GlobalVector &lower, GlobalVector &upper, int const process_id) override
bool isLinear () const override
bool requiresNormalization () const override
void preIteration (const unsigned iter, GlobalVector const &x) override
IterationResult postIteration (GlobalVector const &x) override
TimeDiscgetTimeDiscretization () override
 Exposes the used time discretization scheme.
MathLib::MatrixSpecifications getMatrixSpecifications (const int process_id) const override

Static Public Attributes

static const ODESystemTag ODETag
 A tag indicating the type of ODE.

Private Types

using Index = MathLib::MatrixVectorTraits<GlobalMatrix>::Index

Private Attributes

ODE_ode
 ode the ODE being wrapped
TimeDisc_time_disc
 the time discretization to being used
std::unique_ptr< MatTrans_mat_trans
 the object used to compute the matrix/vector for the nonlinear solver
std::vector< NumLib::IndexValueVector< Index > > const * _known_solutions
 stores precomputed values for known solutions
GlobalMatrix_Jac
 the Jacobian of the residual
GlobalVector_b
 Matrix \( b \).
std::size_t _Jac_id = 0u
 ID of the _Jac matrix.
std::size_t _b_id = 0u
 ID of the _b vector.

Member Typedef Documentation

◆ Index

◆ MatTrans

The auxiliary class that computes the matrix/vector used by the nonlinear solver.

Definition at line 70 of file TimeDiscretizedODESystem.h.

◆ ODE

◆ TimeDisc

A shortcut for a general time discretization scheme.

Definition at line 72 of file TimeDiscretizedODESystem.h.

Constructor & Destructor Documentation

◆ TimeDiscretizedODESystem()

NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::TimeDiscretizedODESystem ( const int process_id,
ODE & ode,
TimeDisc & time_discretization )
explicit

Constructs a new instance.

Parameters
process_idID of the ODE to be solved.
odethe ODE to be wrapped.
time_discretizationthe time discretization to be used.

Definition at line 49 of file TimeDiscretizedODESystem.cpp.

52 : _ode(ode),
55{
57 _ode.getMatrixSpecifications(process_id), _Jac_id);
59 _ode.getMatrixSpecifications(process_id), _b_id);
60}
std::unique_ptr< MatTrans > _mat_trans
the object used to compute the matrix/vector for the nonlinear solver

References _b, _b_id, _Jac, _Jac_id, _mat_trans, _ode, _time_disc, NumLib::createMatrixTranslator(), NumLib::Newton, ODETag, NumLib::GlobalMatrixProvider::provider, and NumLib::GlobalVectorProvider::provider.

◆ ~TimeDiscretizedODESystem()

Member Function Documentation

◆ applyKnownSolutions()

Definition at line 126 of file TimeDiscretizedODESystem.cpp.

127{
129}
std::vector< NumLib::IndexValueVector< Index > > const * _known_solutions
stores precomputed values for known solutions
void applyKnownSolutions(std::vector< Solutions > const *const known_solutions, Vector &x)
Applies known solutions to the solution vector x.

References _known_solutions, detail::applyKnownSolutions(), applyKnownSolutions(), and NumLib::Newton.

Referenced by applyKnownSolutions().

◆ applyKnownSolutionsNewton()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::applyKnownSolutionsNewton ( GlobalMatrix & Jac,
GlobalVector & res,
GlobalVector const & x,
GlobalVector & minus_delta_x ) const
override

Definition at line 132 of file TimeDiscretizedODESystem.cpp.

136{
137 if (!_known_solutions)
138 {
139 return;
140 }
141
145 { return bc.ids.size(); }),
146 0);
148 ids.reserve(size);
150 values.reserve(size);
151
152 for (auto const& bc : *_known_solutions)
153 {
154 for (std::size_t i = 0; i < bc.ids.size(); ++i)
155 {
156 auto const id = bc.ids[i];
157 ids.push_back(id);
158 // minus_delta_x will be set to the difference between the current
159 // value and the Dirichlet BC value.
160 values.push_back(x[id] - bc.values[i]);
161 }
162 }
163
167}
void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &, const std::vector< EigenMatrix::IndexType > &vec_knownX_id, const std::vector< double > &vec_knownX_x, DirichletBCApplicationMode const mode)

References _known_solutions, MathLib::applyKnownSolution(), MathLib::COMPLETE_MATRIX_UPDATE, and NumLib::Newton.

◆ applyKnownSolutionsPETScSNES()

Definition at line 170 of file TimeDiscretizedODESystem.cpp.

173{
174 if (!_known_solutions)
175 {
176 return;
177 }
178
181 for (auto const& bc : *_known_solutions)
182 {
183 ids.insert(end(ids), begin(bc.ids), end(bc.ids));
184 }
185
186 // For the Newton method the values must be zero
187 std::vector<double> values(ids.size(), 0);
189 Jac, res, x, ids, values,
191}

References _known_solutions, MathLib::applyKnownSolution(), MathLib::COMPLETE_MATRIX_UPDATE, and NumLib::Newton.

◆ assemble()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::assemble ( std::vector< GlobalVector * > const & x_new_timestep,
std::vector< GlobalVector * > const & x_prev,
int const process_id )
override

Definition at line 71 of file TimeDiscretizedODESystem.cpp.

75{
76 auto const t = _time_disc.getCurrentTime();
77 auto const dt = _time_disc.getCurrentTimeIncrement();
78 auto const& x_curr = *x_new_timestep[process_id];
79
80 _b->setZero();
81 _Jac->setZero();
82 try
83 {
84 _ode.preAssemble(t, dt, x_curr);
85 _ode.assembleWithJacobian(t, dt, x_new_timestep, x_prev, process_id,
86 *_b, *_Jac);
87 }
88 catch (AssemblyException const&)
89 {
92 throw;
93 }
96}
void finalizeAssembly(PETScMatrix &A)
Definition LinAlg.cpp:198

References _b, _Jac, _ode, _time_disc, MathLib::LinAlg::finalizeAssembly(), and NumLib::Newton.

◆ computeKnownSolutions()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::computeKnownSolutions ( GlobalVector const & x,
int const process_id )
override

Definition at line 117 of file TimeDiscretizedODESystem.cpp.

119{
121 _ode.getKnownSolutions(_time_disc.getCurrentTime(), x, process_id);
122}

References _known_solutions, _ode, _time_disc, computeKnownSolutions(), and NumLib::Newton.

Referenced by computeKnownSolutions().

◆ getIndicesOfResiduumWithoutInitialCompensation()

std::vector< GlobalIndexType > NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::getIndicesOfResiduumWithoutInitialCompensation ( ) const
inlineoverride
Returns
The global indices for the entries of the global residuum vector that do not need initial non-equilibrium compensation.

Definition at line 92 of file TimeDiscretizedODESystem.h.

93 {
94 return _ode.getIndicesOfResiduumWithoutInitialCompensation();
95 }

References _ode.

◆ getJacobian()

Definition at line 110 of file TimeDiscretizedODESystem.cpp.

111{
112 _mat_trans->computeJacobian(*_Jac, Jac);
113}

References _Jac, _mat_trans, getJacobian(), and NumLib::Newton.

Referenced by getJacobian().

◆ getMatrixSpecifications()

Definition at line 145 of file TimeDiscretizedODESystem.h.

147 {
148 return _ode.getMatrixSpecifications(process_id);
149 }

References _ode.

◆ getResidual()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::getResidual ( GlobalVector const & x_new_timestep,
GlobalVector const & x_prev,
GlobalVector & res ) const
override

Definition at line 99 of file TimeDiscretizedODESystem.cpp.

103{
104 MathLib::LinAlg::copy(*_b, res); // res = b
105 MathLib::LinAlg::scale(res, -1.); // res = -b
106}
void copy(PETScVector const &x, PETScVector &y)
Definition LinAlg.cpp:37
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:44

References _b, MathLib::LinAlg::copy(), NumLib::Newton, and MathLib::LinAlg::scale().

◆ getTimeDiscretization()

Exposes the used time discretization scheme.

Implements NumLib::TimeDiscretizedODESystemBase< NonlinearSolverTag::Newton >.

Definition at line 144 of file TimeDiscretizedODESystem.h.

144{ return _time_disc; }

References _time_disc.

◆ isLinear()

Definition at line 127 of file TimeDiscretizedODESystem.h.

127{ return _ode.isLinear(); }

References _ode.

◆ postIteration()

Definition at line 139 of file TimeDiscretizedODESystem.h.

140 {
141 return _ode.postIteration(x);
142 }

References _ode.

◆ preIteration()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::preIteration ( const unsigned iter,
GlobalVector const & x )
inlineoverride

Definition at line 134 of file TimeDiscretizedODESystem.h.

135 {
136 _ode.preIteration(iter, x);
137 }

References _ode.

◆ requiresNormalization()

Definition at line 129 of file TimeDiscretizedODESystem.h.

130 {
131 return _ode.requiresNormalization();
132 }

References _ode.

◆ setReleaseNodalForces()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::setReleaseNodalForces ( GlobalVector const * r_neq,
int const process_id )
inlineoverride

Definition at line 97 of file TimeDiscretizedODESystem.h.

99 {
100 _ode.setReleaseNodalForces(r_neq, process_id);
101 }

References _ode.

◆ updateConstraints()

void NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Newton >::updateConstraints ( GlobalVector & lower,
GlobalVector & upper,
int const process_id )
inlineoverride

Definition at line 121 of file TimeDiscretizedODESystem.h.

123 {
124 _ode.updateConstraints(lower, upper, process_id);
125 }

References _ode.

Member Data Documentation

◆ _b

◆ _b_id

ID of the _b vector.

Definition at line 166 of file TimeDiscretizedODESystem.h.

Referenced by TimeDiscretizedODESystem().

◆ _Jac

◆ _Jac_id

ID of the _Jac matrix.

Definition at line 165 of file TimeDiscretizedODESystem.h.

Referenced by TimeDiscretizedODESystem().

◆ _known_solutions

Initial value:
=
nullptr

stores precomputed values for known solutions

Definition at line 159 of file TimeDiscretizedODESystem.h.

Referenced by applyKnownSolutions(), applyKnownSolutionsNewton(), applyKnownSolutionsPETScSNES(), and computeKnownSolutions().

◆ _mat_trans

the object used to compute the matrix/vector for the nonlinear solver

Definition at line 156 of file TimeDiscretizedODESystem.h.

Referenced by TimeDiscretizedODESystem(), and getJacobian().

◆ _ode

◆ _time_disc

◆ ODETag


The documentation for this class was generated from the following files: