OGS
MatrixTranslator.cpp
Go to the documentation of this file.
1
11#include "MatrixTranslator.h"
12
14
15namespace NumLib
16{
18 computeA(GlobalMatrix const& M, GlobalMatrix const& K,
19 GlobalMatrix& A) const
20{
21 namespace LinAlg = MathLib::LinAlg;
22
23 double const dt = _time_disc.getCurrentTimeIncrement();
24
25 // A = M * 1/dt + K
26 LinAlg::copy(K, A);
27 LinAlg::axpy(A, 1. / dt, M);
28}
29
31 computeRhs(const GlobalMatrix& M, const GlobalMatrix& /*K*/,
32 const GlobalVector& b, const GlobalVector& x_prev,
33 GlobalVector& rhs) const
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}
45
48 GlobalVector const& b, GlobalVector const& x_curr,
49 GlobalVector const& xdot, GlobalVector& res) const
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}
59
61 computeJacobian(GlobalMatrix const& Jac_in, GlobalMatrix& Jac_out) const
62{
63 namespace LinAlg = MathLib::LinAlg;
64
65 LinAlg::copy(Jac_in, Jac_out);
66}
67
68} // namespace NumLib
Global vector based on Eigen vector.
Definition: EigenVector.h:28
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
virtual void releaseVector(GlobalVector const &x)=0
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
void matMult(PETScMatrix const &A, PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:142
void matMultAdd(PETScMatrix const &A, PETScVector const &v1, PETScVector const &v2, PETScVector &v3)
Definition: LinAlg.cpp:152
void axpy(PETScVector &y, PetscScalar const a, PETScVector const &x)
Definition: LinAlg.cpp:57
static NUMLIB_EXPORT VectorProvider & provider