OGS  master
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 >:
[legend]
Collaboration diagram for NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >:
[legend]

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  }
TimeDiscretization const & _time_disc
the time discretization used.

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 17 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 }
virtual double getNewXWeight() const =0
Returns .
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
void aypx(PETScVector &y, double const a, PETScVector const &x)
Definition: LinAlg.cpp:50

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 60 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 46 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 }
void axpy(PETScVector &y, double const a, PETScVector const &x)
Definition: LinAlg.cpp:57
void matMult(PETScMatrix const &A, PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:141
void matMultAdd(PETScMatrix const &A, PETScVector const &v1, PETScVector const &v2, PETScVector &v3)
Definition: LinAlg.cpp:151

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 30 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 }
std::size_t _tmp_id
ID of the vector storing intermediate computations.
virtual void getWeightedOldX(GlobalVector &y, GlobalVector const &x_old) const =0
Returns .
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
virtual void releaseVector(GlobalVector const &x)=0
static NUMLIB_EXPORT VectorProvider & provider

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 120 of file MatrixTranslator.h.

◆ _tmp_id

ID of the vector storing intermediate computations.

Definition at line 123 of file MatrixTranslator.h.


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