OGS
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear > Class Reference

Detailed Description

General matrix translator for first order implicit quasi-linear ODEs, used with time discretization schemes that have no special needs.

See also
ODESystemTag::FirstOrderImplicitQuasilinear
Remarks
You might also want read the remarks on time discretization.

Definition at line 86 of file MatrixTranslator.h.

#include <MatrixTranslator.h>

Inheritance diagram for NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >:
Collaboration diagram for NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >:

Public Member Functions

 MatrixTranslatorGeneral (TimeDiscretization const &timeDisc)
 
void computeA (GlobalMatrix const &M, GlobalMatrix const &K, GlobalMatrix &A) const override
 Computes \( A = M \cdot \alpha + K \). More...
 
void computeRhs (const GlobalMatrix &M, const GlobalMatrix &, const GlobalVector &b, const GlobalVector &x_prev, GlobalVector &rhs) const override
 Computes \( \mathtt{rhs} = M \cdot x_O + b \). More...
 
void computeResidual (GlobalMatrix const &M, GlobalMatrix const &K, GlobalVector const &b, GlobalVector const &x_curr, GlobalVector const &xdot, GlobalVector &res) const override
 Computes \( r = M \cdot \hat x + K \cdot x_C - b \). More...
 
void computeJacobian (GlobalMatrix const &Jac_in, GlobalMatrix &Jac_out) const override
 
- Public Member Functions inherited from NumLib::MatrixTranslator< ODESystemTag::FirstOrderImplicitQuasilinear >
virtual ~MatrixTranslator ()=default
 

Private Attributes

TimeDiscretization const & _time_disc
 the time discretization used. More...
 
std::size_t _tmp_id = 0u
 ID of the vector storing intermediate computations. More...
 

Constructor & Destructor Documentation

◆ MatrixTranslatorGeneral()

Constructs a new instance.

Parameters
timeDiscthe time discretization scheme to be used.

Definition at line 94 of file MatrixTranslator.h.

95  : _time_disc(timeDisc)
96  {
97  }

Member Function Documentation

◆ computeA()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeA ( GlobalMatrix const &  M,
GlobalMatrix const &  K,
GlobalMatrix &  A 
) const
overridevirtual

Computes \( A = M \cdot \alpha + K \).

Implements NumLib::MatrixTranslator< ODESystemTag::FirstOrderImplicitQuasilinear >.

Definition at line 18 of file MatrixTranslator.cpp.

20 {
21  namespace LinAlg = MathLib::LinAlg;
22 
23  auto const dxdot_dx = _time_disc.getNewXWeight();
24 
25  // A = M * dxdot_dx + K
26  LinAlg::copy(M, A);
27  LinAlg::aypx(A, dxdot_dx, K);
28 }

References MathLib::LinAlg::aypx(), and MathLib::LinAlg::copy().

◆ computeJacobian()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeJacobian ( GlobalMatrix const &  Jac_in,
GlobalMatrix &  Jac_out 
) const
overridevirtual

Writes Jac_in to Jac_out.

Todo:
Do not copy.

Implements NumLib::MatrixTranslator< ODESystemTag::FirstOrderImplicitQuasilinear >.

Definition at line 61 of file MatrixTranslator.cpp.

62 {
63  namespace LinAlg = MathLib::LinAlg;
64 
65  LinAlg::copy(Jac_in, Jac_out);
66 }

References MathLib::LinAlg::copy().

◆ computeResidual()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeResidual ( GlobalMatrix const &  M,
GlobalMatrix const &  K,
GlobalVector const &  b,
GlobalVector const &  x_curr,
GlobalVector const &  xdot,
GlobalVector &  res 
) const
overridevirtual

Computes \( r = M \cdot \hat x + K \cdot x_C - b \).

Implements NumLib::MatrixTranslator< ODESystemTag::FirstOrderImplicitQuasilinear >.

Definition at line 47 of file MatrixTranslator.cpp.

50 {
51  namespace LinAlg = MathLib::LinAlg;
52 
53  // res = M * x_dot + K * x_curr - b
54  LinAlg::matMult(M, xdot, res); // the local vector x_dot seems to be
55  // necessary because of this multiplication
56  LinAlg::matMultAdd(K, x_curr, res, res);
57  LinAlg::axpy(res, -1.0, b);
58 }

References MathLib::LinAlg::axpy(), MathLib::LinAlg::matMult(), and MathLib::LinAlg::matMultAdd().

◆ computeRhs()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeRhs ( const GlobalMatrix &  M,
const GlobalMatrix &  ,
const GlobalVector &  b,
const GlobalVector &  x_prev,
GlobalVector &  rhs 
) const
overridevirtual

Computes \( \mathtt{rhs} = M \cdot x_O + b \).

Implements NumLib::MatrixTranslator< ODESystemTag::FirstOrderImplicitQuasilinear >.

Definition at line 31 of file MatrixTranslator.cpp.

34 {
35  namespace LinAlg = MathLib::LinAlg;
36 
38  _time_disc.getWeightedOldX(tmp, x_prev);
39 
40  // rhs = M * weighted_old_x + b
41  LinAlg::matMultAdd(M, tmp, b, rhs);
42 
44 }

References NumLib::VectorProvider::getVector(), MathLib::LinAlg::matMultAdd(), NumLib::GlobalVectorProvider::provider, and NumLib::VectorProvider::releaseVector().

Member Data Documentation

◆ _time_disc

the time discretization used.

Definition at line 122 of file MatrixTranslator.h.

◆ _tmp_id

ID of the vector storing intermediate computations.

Definition at line 125 of file MatrixTranslator.h.


The documentation for this class was generated from the following files:
NumLib::VectorProvider::getVector
virtual GlobalVector & getVector()=0
Get an uninitialized vector.
MathLib::LinAlg::aypx
void aypx(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:51
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::_time_disc
TimeDiscretization const & _time_disc
the time discretization used.
Definition: MatrixTranslator.h:122
NumLib::VectorProvider::releaseVector
virtual void releaseVector(GlobalVector const &x)=0
NumLib::TimeDiscretization::getWeightedOldX
virtual void getWeightedOldX(GlobalVector &y, GlobalVector const &x_old) const =0
Returns .
NumLib::GlobalVectorProvider::provider
static NUMLIB_EXPORT VectorProvider & provider
Definition: GlobalMatrixProviders.h:21
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::_tmp_id
std::size_t _tmp_id
ID of the vector storing intermediate computations.
Definition: MatrixTranslator.h:125
MathLib::LinAlg::copy
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:37
MathLib::LinAlg::axpy
void axpy(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:58
MathLib::LinAlg::matMult
void matMult(Matrix const &A, Vector const &x, Vector &y)
Definition: LinAlg.h:114
MathLib::LinAlg
NumLib::TimeDiscretization::getNewXWeight
virtual double getNewXWeight() const =0
Returns .
MathLib::LinAlg::matMultAdd
void matMultAdd(Matrix const &A, Vector const &v1, Vector const &v2, Vector &v3)
Definition: LinAlg.h:127