OGS
MatrixTranslator.cpp
Go to the documentation of this file.
1 
11 #include "MatrixTranslator.h"
12 
13 #include "MathLib/LinAlg/LinAlg.h"
14 
15 namespace NumLib
16 {
18  computeA(GlobalMatrix const& M, GlobalMatrix const& K,
19  GlobalMatrix& A) const
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 }
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 
47  computeResidual(GlobalMatrix const& M, GlobalMatrix const& K,
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:26
virtual GlobalVector & getVector(std::size_t &id)=0
Get an uninitialized vector with the given id.
virtual void releaseVector(GlobalVector const &x)=0
void axpy(PETScVector &y, double const a, PETScVector const &x)
Definition: LinAlg.cpp:57
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
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
void aypx(PETScVector &y, double const a, PETScVector const &x)
Definition: LinAlg.cpp:50
static NUMLIB_EXPORT VectorProvider & provider