OGS 6.2.0-405-gb717f6088
NumLib::MatrixTranslatorForwardEuler< ODESystemTag::FirstOrderImplicitQuasilinear > Class Template Reference

Detailed Description

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

GlobalMatrix translator for first order implicit quasi-linear ODEs, used with the ForwardEuler scheme.

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

Definition at line 154 of file MatrixTranslator.h.

#include <MatrixTranslator.h>

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

Public Member Functions

 MatrixTranslatorForwardEuler (ForwardEuler const &timeDisc)
 
void computeA (GlobalMatrix const &M, GlobalMatrix const &, GlobalMatrix &A) const override
 Computes $ A = M \cdot \alpha $. More...
 
void computeRhs (const GlobalMatrix &M, const GlobalMatrix &K, const GlobalVector &b, GlobalVector &rhs) const override
 Computes $ \mathtt{rhs} = M \cdot x_O - K \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

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

Constructor & Destructor Documentation

◆ MatrixTranslatorForwardEuler()

Constructs a new instance.

Parameters
timeDiscthe time discretization scheme to be used.

Definition at line 162 of file MatrixTranslator.h.

163  : _fwd_euler(timeDisc)
164  {
165  }

Member Function Documentation

◆ computeA()

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

Computes $ A = M \cdot \alpha $.

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

Definition at line 69 of file MatrixTranslator.cpp.

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

71 {
72  namespace LinAlg = MathLib::LinAlg;
73 
74  auto const dxdot_dx = _fwd_euler.getNewXWeight();
75 
76  // A = M * dxdot_dx
77  LinAlg::copy(M, A);
78  LinAlg::scale(A, dxdot_dx);
79 }
double getNewXWeight() const override
Returns .
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36
void scale(MatrixOrVector &x, double const a)
Scales x by a.
Definition: LinAlg.h:43

◆ computeJacobian()

void NumLib::MatrixTranslatorForwardEuler< 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 116 of file MatrixTranslator.cpp.

References MathLib::LinAlg::copy(), and NumLib::FirstOrderImplicitQuasilinear.

117 {
118  namespace LinAlg = MathLib::LinAlg;
119 
120  LinAlg::copy(Jac_in, Jac_out);
121 }
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

◆ computeResidual()

void NumLib::MatrixTranslatorForwardEuler< 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 101 of file MatrixTranslator.cpp.

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

104 {
105  namespace LinAlg = MathLib::LinAlg;
106 
107  auto const& x_curr = _fwd_euler.getCurrentX(x_new_timestep);
108 
109  // res = M * x_dot + K * x_curr - b
110  LinAlg::matMult(M, xdot, res);
111  LinAlg::matMultAdd(K, x_curr, res, res);
112  LinAlg::axpy(res, -1.0, b);
113 }
void matMult(Matrix const &A, Vector const &x, Vector &y)
Definition: LinAlg.h:113
GlobalVector const & getCurrentX(const GlobalVector &) const override
void axpy(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:57
void matMultAdd(Matrix const &A, Vector const &v1, Vector const &v2, Vector &v3)
Definition: LinAlg.h:126

◆ computeRhs()

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

Computes $ \mathtt{rhs} = M \cdot x_O - K \cdot x_O + b $.

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

Definition at line 82 of file MatrixTranslator.cpp.

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

84 {
85  namespace LinAlg = MathLib::LinAlg;
86 
89 
90  auto const& x_old = _fwd_euler.getXOld();
91 
92  // rhs = b + M * weighted_old_x - K * x_old
93  LinAlg::matMult(K, x_old, rhs); // rhs = K * x_old
94  LinAlg::aypx(rhs, -1.0, b); // rhs = b - K * x_old
95  LinAlg::matMultAdd(M, tmp, rhs, rhs); // rhs += M * weighted_old_x
96 
98 }
void aypx(MatrixOrVector &y, double const a, MatrixOrVector const &x)
Computes .
Definition: LinAlg.h:50
std::size_t _tmp_id
ID of the vector storing intermediate computations.
void matMult(Matrix const &A, Vector const &x, Vector &y)
Definition: LinAlg.h:113
virtual GlobalVector & getVector()=0
Get an uninitialized vector.
static NUMLIB_EXPORT VectorProvider & provider
GlobalVector const & getXOld() const
Returns the solution from the preceding timestep.
virtual void releaseVector(GlobalVector const &x)=0
void getWeightedOldX(GlobalVector &y) const override
Returns .
void matMultAdd(Matrix const &A, Vector const &v1, Vector const &v2, Vector &v3)
Definition: LinAlg.h:126

Member Data Documentation

◆ _fwd_euler

the time discretization used.

Definition at line 188 of file MatrixTranslator.h.

◆ _tmp_id

ID of the vector storing intermediate computations.

Definition at line 191 of file MatrixTranslator.h.


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