OGS 6.2.1-710-gde5194452.dirty.20191209112531
NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear > Class Template Reference

Detailed Description

template<>
class NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >

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 98 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, 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_new_timestep, 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 void pushMatrices (GlobalMatrix const &, GlobalMatrix const &, GlobalVector const &)
 
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 106 of file MatrixTranslator.h.

107  : _time_disc(timeDisc)
108  {
109  }
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 18 of file MatrixTranslator.cpp.

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

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 }
TimeDiscretization const & _time_disc
the time discretization used.
void aypx(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:51
virtual double getNewXWeight() const =0
Returns .
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:37

◆ 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 62 of file MatrixTranslator.cpp.

References MathLib::LinAlg::copy().

63 {
64  namespace LinAlg = MathLib::LinAlg;
65 
66  LinAlg::copy(Jac_in, Jac_out);
67 }
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:37

◆ computeResidual()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeResidual ( GlobalMatrix const &  M,
GlobalMatrix const &  K,
GlobalVector const &  b,
GlobalVector const &  x_new_timestep,
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.

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

49 {
50  namespace LinAlg = MathLib::LinAlg;
51 
52  auto const& x_curr = _time_disc.getCurrentX(x_new_timestep);
53 
54  // res = M * x_dot + K * x_curr - b
55  LinAlg::matMult(M, xdot, res); // the local vector x_dot seems to be
56  // necessary because of this multiplication
57  LinAlg::matMultAdd(K, x_curr, res, res);
58  LinAlg::axpy(res, -1.0, b);
59 }
TimeDiscretization const & _time_disc
the time discretization used.
void matMult(Matrix const &A, Vector const &x, Vector &y)
Definition: LinAlg.h:114
void axpy(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:58
virtual GlobalVector const & getCurrentX(GlobalVector const &x_at_new_timestep) const
void matMultAdd(Matrix const &A, Vector const &v1, Vector const &v2, Vector &v3)
Definition: LinAlg.h:127

◆ computeRhs()

void NumLib::MatrixTranslatorGeneral< ODESystemTag::FirstOrderImplicitQuasilinear >::computeRhs ( const GlobalMatrix &  M,
const GlobalMatrix &  ,
const GlobalVector &  b,
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.

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

33 {
34  namespace LinAlg = MathLib::LinAlg;
35 
38 
39  // rhs = M * weighted_old_x + b
40  LinAlg::matMultAdd(M, tmp, b, rhs);
41 
43 }
TimeDiscretization const & _time_disc
the time discretization used.
virtual void getWeightedOldX(GlobalVector &y) const =0
Returns .
virtual GlobalVector & getVector()=0
Get an uninitialized vector.
static NUMLIB_EXPORT VectorProvider & provider
std::size_t _tmp_id
ID of the vector storing intermediate computations.
virtual void releaseVector(GlobalVector const &x)=0
void matMultAdd(Matrix const &A, Vector const &v1, Vector const &v2, Vector &v3)
Definition: LinAlg.h:127

Member Data Documentation

◆ _time_disc

the time discretization used.

Definition at line 133 of file MatrixTranslator.h.

◆ _tmp_id

ID of the vector storing intermediate computations.

Definition at line 136 of file MatrixTranslator.h.


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