My Project
mortar_evaluator.hpp
Go to the documentation of this file.
1 //==============================================================================
11 //==============================================================================
12 #ifndef MORTAR_EVALUATOR_HPP_
13 #define MORTAR_EVALUATOR_HPP_
14 
15 #include <dune/istl/matrixmatrix.hh>
16 #include <dune/istl/solvers.hh>
19 
20 namespace Opm {
21 namespace Elasticity {
22 
27 class MortarEvaluator : public Dune::LinearOperator<Vector, Vector> {
28  public:
33  const Matrix& B_) :
34  A(A_), B(B_)
35  {
36  }
37 
41  void apply(const Vector& x, Vector& y) const override
42  {
43  Vector lambda, l2;
44 
45  MortarUtils::extractBlock(lambda, x, B.M(), A.N());
46  A.mv(x, y);
47  B.umv(lambda, y);
48  l2.resize(lambda.size());
49  B.mtv(x, l2);
50  MortarUtils::injectBlock(y, l2, B.M(), A.N());
51  }
52 
57  void applyscaleadd(field_type alpha, const Vector& x, Vector& y) const override
58  {
59  Vector lambda, l2;
60 
61  A.usmv(alpha, x, y);
62  MortarUtils::extractBlock(lambda, x, B.M(), A.N());
63  B.umv(lambda, y);
64  l2.resize(lambda.size());
65  B.mtv(x, l2);
66  for (size_t i=A.N(); i < y.size(); ++i)
67  y[i] += alpha*l2[i-A.N()];
68  }
69 
70  Dune::SolverCategory::Category category() const override
71  {
72  return Dune::SolverCategory::sequential;
73  }
74 
75  protected:
76  const Matrix& A;
77  const Matrix& B;
78 };
79 
80 }
81 }
82 
83 #endif
This implements a operator evaluation for the schur mortar-block S = B^T*A^-1*B !
Definition: mortar_evaluator.hpp:27
const Matrix & B
Reference to the mortar coupling matrix.
Definition: mortar_evaluator.hpp:77
void apply(const Vector &x, Vector &y) const override
Apply the multiplier block.
Definition: mortar_evaluator.hpp:41
void applyscaleadd(field_type alpha, const Vector &x, Vector &y) const override
Apply the multiplier block with an embedded axpy.
Definition: mortar_evaluator.hpp:57
MortarEvaluator(const Matrix &A_, const Matrix &B_)
Constructor.
Definition: mortar_evaluator.hpp:32
const Matrix & A
Reference to A matrix.
Definition: mortar_evaluator.hpp:76
static void extractBlock(Vector &x, const Vector &y, int len, int start=0)
Extract a range of indices from a vector.
Definition: mortar_utils.hpp:25
static void injectBlock(Vector &x, const Vector &y, int len, int start=0)
Inject a range of indices into a vector.
Definition: mortar_utils.hpp:40
Helper class with some matrix operations.
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition: matrixops.hpp:27
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
Mortar helper class.
Inverting small matrices.
Definition: ImplicitAssembly.hpp:43