Loading...
Searching...
No Matches
mortar_schur_precond.hpp
//==============================================================================
//==============================================================================
#ifndef SCHUR_PRECOND_HPP_
#define SCHUR_PRECOND_HPP_
#include <dune/istl/preconditioners.hh>
#include <dune/istl/matrixmatrix.hh>
#include <opm/elasticity/matrixops.hpp>
#include <opm/elasticity/mortar_utils.hpp>
#include <opm/elasticity/elasticity_preconditioners.hpp>
namespace Opm {
namespace Elasticity {
template<class PrecondElasticityBlock>
class MortarSchurPre : public Dune::Preconditioner<Vector,Vector> {
public:
MortarSchurPre(const Matrix& P_, const Matrix& B_,
PrecondElasticityBlock& Apre_, bool symmetric_ = false) :
Apre(Apre_), B(B_), N(B.N()), M(B.M()),
Lpre(P_, false, false), symmetric(symmetric_)
{
}
virtual ~MortarSchurPre()
{
}
void pre(Vector& x, Vector& b) override
{
// extract displacement DOFs
Vector tempx, tempb;
MortarUtils::extractBlock(tempx, x, N);
MortarUtils::extractBlock(tempb, b, N);
Apre.pre(tempx, tempb);
MortarUtils::injectBlock(x, tempx, N);
MortarUtils::injectBlock(b, tempb, N);
}
void apply(Vector& v, const Vector& d) override
{
// multiplier block (second row)
Vector temp;
MortarUtils::extractBlock(temp, d, M, N);
Dune::InverseOperatorResult r;
Vector temp2;
temp2.resize(temp.size());
Lpre.apply(temp2, temp, r);
MortarUtils::injectBlock(v, temp2, M, N);
// elasticity block (first row)
MortarUtils::extractBlock(temp, d, N);
if (!symmetric)
B.mmv(temp2, temp);
temp2.resize(N);
temp2 = 0;
Apre.apply(temp2, temp);
MortarUtils::injectBlock(v, temp2, N);
}
void post(Vector& x) override
{
Apre.post(x);
}
Dune::SolverCategory::Category category() const override
{
return Dune::SolverCategory::sequential;
}
protected:
PrecondElasticityBlock& Apre;
const Matrix& B;
int N;
int M;
LUSolver Lpre;
bool symmetric;
};
}
}
#endif
Opm::Elasticity::MortarSchurPre::post
void post(Vector &x) override
Dummy post-process function.
Definition mortar_schur_precond.hpp:94
Opm::Elasticity::MortarSchurPre::~MortarSchurPre
virtual ~MortarSchurPre()
Destructor.
Definition mortar_schur_precond.hpp:52
Opm::Elasticity::MortarSchurPre::Apre
PrecondElasticityBlock & Apre
The preconditioner for the elasticity operator.
Definition mortar_schur_precond.hpp:106
Opm::Elasticity::MortarSchurPre::M
int M
Number of multiplier DOFs.
Definition mortar_schur_precond.hpp:115
Opm::Elasticity::MortarSchurPre::pre
void pre(Vector &x, Vector &b) override
Preprocess preconditioner.
Definition mortar_schur_precond.hpp:57
Opm::Elasticity::MortarSchurPre::B
const Matrix & B
The mortar coupling matrix.
Definition mortar_schur_precond.hpp:109
Opm::Elasticity::MortarSchurPre::symmetric
bool symmetric
Whether or not to use a symmetric preconditioner.
Definition mortar_schur_precond.hpp:121
Opm::Elasticity::MortarSchurPre::Lpre
LUSolver Lpre
Linear solver for the multiplier block.
Definition mortar_schur_precond.hpp:118
Opm::Elasticity::MortarSchurPre::MortarSchurPre
MortarSchurPre(const Matrix &P_, const Matrix &B_, PrecondElasticityBlock &Apre_, bool symmetric_=false)
Constructor.
Definition mortar_schur_precond.hpp:44
Opm::Elasticity::MortarSchurPre::N
int N
Number of displacement DOFs.
Definition mortar_schur_precond.hpp:112
Opm::Elasticity::MortarSchurPre::apply
void apply(Vector &v, const Vector &d) override
Applies the preconditioner.
Definition mortar_schur_precond.hpp:71
Opm::Elasticity::MortarUtils::extractBlock
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:27
Opm::Elasticity::MortarUtils::injectBlock
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:38
elasticity_preconditioners.hpp
Preconditioners for elasticity upscaling.
matrixops.hpp
Helper class with some matrix operations.
Opm::Elasticity::Matrix
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition matrixops.hpp:27
Opm::Elasticity::Vector
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition matrixops.hpp:33
mortar_utils.hpp
Mortar helper class.
Opm
Inverting small matrices.
Definition ImplicitAssembly.hpp:43