OGS
ComputeResiduum.cpp
Go to the documentation of this file.
1
9
10#include "ComputeResiduum.h"
11
13
14namespace ProcessLib
15{
16GlobalVector computeResiduum(double const dt, GlobalVector const& x,
17 GlobalVector const& x_prev, GlobalMatrix const& M,
18 GlobalMatrix const& K, GlobalVector const& b)
19{
20 using namespace MathLib::LinAlg;
21 GlobalVector residuum;
22 GlobalVector x_dot;
23 copy(x, x_dot); // tmp = x
24 axpy(x_dot, -1., x_prev); // tmp = x - x_prev
25 scale(x_dot, 1. / dt); // tmp = (x - x_prev)/dt
26 matMult(M, x_dot, residuum); // r = M*x_dot
27 matMultAdd(K, x, residuum, residuum); // r = M*x_dot + K*x
28 axpy(residuum, -1., b); // r = M*x_dot + K*x - b
29 scale(residuum, -1.); // r = -r
30 return residuum;
31}
32} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
void copy(PETScVector const &x, PETScVector &y)
Definition LinAlg.cpp:37
void matMult(PETScMatrix const &A, PETScVector const &x, PETScVector &y)
Definition LinAlg.cpp:149
void matMultAdd(PETScMatrix const &A, PETScVector const &v1, PETScVector const &v2, PETScVector &v3)
Definition LinAlg.cpp:159
void scale(PETScVector &x, PetscScalar const a)
Definition LinAlg.cpp:44
void axpy(PETScVector &y, PetscScalar const a, PETScVector const &x)
Definition LinAlg.cpp:57
GlobalVector computeResiduum(double const dt, GlobalVector const &x, GlobalVector const &x_prev, GlobalMatrix const &M, GlobalMatrix const &K, GlobalVector const &b)