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

Detailed Description

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

See also
ODESystemTag::FirstOrderImplicitQuasilinear

Definition at line 170 of file TimeDiscretizedODESystem.h.

#include <TimeDiscretizedODESystem.h>

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

Public Types

using ODE = ODESystem<ODETag, NonlinearSolverTag::Picard>
 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)
 Constructs a new instance.
 
 ~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 getA (GlobalMatrix &A) const override
 
void getRhs (GlobalVector const &x_prev, GlobalVector &rhs) const override
 
void getAandRhsNormalized (GlobalMatrix &A, GlobalVector &rhs) const override
 
void computeKnownSolutions (GlobalVector const &x, int const process_id) override
 
void applyKnownSolutions (GlobalVector &x) const override
 
void applyKnownSolutionsPicard (GlobalMatrix &A, GlobalVector &rhs, GlobalVector &x) const 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
 
MathLib::LinearSolverBehaviour linearSolverNeedsToCompute () const override
 
- Public Member Functions inherited from NumLib::TimeDiscretizedODESystemBase< NonlinearSolverTag::Picard >

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_M
 Matrix \( M \).
 
GlobalMatrix_K
 Matrix \( K \).
 
GlobalVector_b
 Matrix \( b \).
 
std::size_t _M_id = 0u
 ID of the _M matrix.
 
std::size_t _K_id = 0u
 ID of the _K 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 183 of file TimeDiscretizedODESystem.h.

◆ ODE

◆ TimeDisc

A shortcut for a general time discretization scheme.

Definition at line 185 of file TimeDiscretizedODESystem.h.

Constructor & Destructor Documentation

◆ TimeDiscretizedODESystem()

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

Constructs a new instance.

Definition at line 190 of file TimeDiscretizedODESystem.cpp.

193 : _ode(ode),
194 _time_disc(time_discretization),
195 _mat_trans(createMatrixTranslator<ODETag>(time_discretization))
196{
198 ode.getMatrixSpecifications(process_id), _M_id);
200 ode.getMatrixSpecifications(process_id), _K_id);
202 ode.getMatrixSpecifications(process_id), _b_id);
203}
virtual GlobalMatrix & getMatrix(std::size_t &id)=0
Get an uninitialized matrix with the given id.
std::unique_ptr< MatTrans > _mat_trans
the object used to compute the matrix/vector for the nonlinear solver
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
std::unique_ptr< MatrixTranslator< ODETag > > createMatrixTranslator(TimeDiscretization const &timeDisc)
static NUMLIB_EXPORT MatrixProvider & provider
static NUMLIB_EXPORT VectorProvider & provider

References NumLib::MatrixProvider::getMatrix(), NumLib::VectorProvider::getVector(), NumLib::GlobalMatrixProvider::provider, and NumLib::GlobalVectorProvider::provider.

◆ ~TimeDiscretizedODESystem()

Member Function Documentation

◆ applyKnownSolutions()

Definition at line 249 of file TimeDiscretizedODESystem.cpp.

250{
252}
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 detail::applyKnownSolutions().

◆ applyKnownSolutionsPicard()

Definition at line 255 of file TimeDiscretizedODESystem.cpp.

259{
260 if (!_known_solutions)
261 {
262 return;
263 }
264
266 std::vector<IndexType> ids;
267 std::vector<double> values;
268 for (auto const& bc : *_known_solutions)
269 {
270 ids.insert(end(ids), begin(bc.ids), end(bc.ids));
271 values.insert(end(values), begin(bc.values), end(bc.values));
272 }
273 MathLib::applyKnownSolution(A, rhs, x, ids, values);
274}
void applyKnownSolution(EigenMatrix &A, EigenVector &b, EigenVector &, const std::vector< EigenMatrix::IndexType > &vec_knownX_id, const std::vector< double > &vec_knownX_x)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
Definition Mesh.h:227

References MathLib::applyKnownSolution().

◆ assemble()

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

Definition at line 215 of file TimeDiscretizedODESystem.cpp.

219{
220 namespace LinAlg = MathLib::LinAlg;
221
222 auto const t = _time_disc.getCurrentTime();
223 auto const dt = _time_disc.getCurrentTimeIncrement();
224 auto const& x_curr = *x_new_timestep[process_id];
225
226 _M->setZero();
227 _K->setZero();
228 _b->setZero();
229
230 _ode.preAssemble(t, dt, x_curr);
231 _ode.assemble(t, dt, x_new_timestep, x_prev, process_id, *_M, *_K, *_b);
232
236}
void setZero()
reset data entries to zero.
Definition EigenMatrix.h:65
virtual double getCurrentTimeIncrement() const =0
virtual double getCurrentTime() const =0
void finalizeAssembly(PETScMatrix &A)
Definition LinAlg.cpp:198

References MathLib::LinAlg::finalizeAssembly().

◆ computeKnownSolutions()

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

Definition at line 240 of file TimeDiscretizedODESystem.cpp.

242{
244 _ode.getKnownSolutions(_time_disc.getCurrentTime(), x, process_id);
245}

◆ getA()

Definition at line 205 of file TimeDiscretizedODESystem.h.

206 {
207 _mat_trans->computeA(*_M, *_K, A);
208 }

◆ getAandRhsNormalized()

Definition at line 215 of file TimeDiscretizedODESystem.h.

216 {
217 _mat_trans->normalizeAandRhs(A, rhs);
218 }

◆ getIndicesOfResiduumWithoutInitialCompensation()

std::vector< GlobalIndexType > NumLib::TimeDiscretizedODESystem< ODESystemTag::FirstOrderImplicitQuasilinear, NonlinearSolverTag::Picard >::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 200 of file TimeDiscretizedODESystem.h.

201 {
202 return _ode.getIndicesOfResiduumWithoutInitialCompensation();
203 }

◆ getMatrixSpecifications()

Definition at line 246 of file TimeDiscretizedODESystem.h.

248 {
249 return _ode.getMatrixSpecifications(process_id);
250 }

◆ getRhs()

Definition at line 210 of file TimeDiscretizedODESystem.h.

211 {
212 _mat_trans->computeRhs(*_M, *_K, *_b, x_prev, rhs);
213 }

◆ getTimeDiscretization()

Exposes the used time discretization scheme.

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

Definition at line 245 of file TimeDiscretizedODESystem.h.

245{ return _time_disc; }

◆ isLinear()

Definition at line 228 of file TimeDiscretizedODESystem.h.

228{ return _ode.isLinear(); }

◆ linearSolverNeedsToCompute()

Definition at line 252 of file TimeDiscretizedODESystem.h.

253 {
254 if (_ode.shouldLinearSolverComputeOnlyUponTimestepChange() &&
257 {
259 }
260 if (_ode.shouldLinearSolverComputeOnlyUponTimestepChange() &&
263 {
265 }
267 }
virtual double getPreviousTimeIncrement() const =0
Returns the value of from the previous time step.

References MathLib::RECOMPUTE, MathLib::RECOMPUTE_AND_STORE, and MathLib::REUSE.

◆ postIteration()

Definition at line 240 of file TimeDiscretizedODESystem.h.

241 {
242 return _ode.postIteration(x);
243 }

◆ preIteration()

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

Definition at line 235 of file TimeDiscretizedODESystem.h.

236 {
237 _ode.preIteration(iter, x);
238 }

◆ requiresNormalization()

Definition at line 230 of file TimeDiscretizedODESystem.h.

231 {
232 return _ode.requiresNormalization();
233 }

Member Data Documentation

◆ _b

◆ _b_id

ID of the _b vector.

Definition at line 286 of file TimeDiscretizedODESystem.h.

◆ _K

◆ _K_id

ID of the _K matrix.

Definition at line 285 of file TimeDiscretizedODESystem.h.

◆ _known_solutions

Initial value:
=
nullptr

stores precomputed values for known solutions

Definition at line 277 of file TimeDiscretizedODESystem.h.

◆ _M

◆ _M_id

ID of the _M matrix.

Definition at line 284 of file TimeDiscretizedODESystem.h.

◆ _mat_trans

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

Definition at line 274 of file TimeDiscretizedODESystem.h.

◆ _ode

◆ _time_disc

the time discretization to being used

Definition at line 271 of file TimeDiscretizedODESystem.h.

◆ ODETag


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