Loading...
Searching...
No Matches
elasticity_preconditioners.hpp
Go to the documentation of this file.
//==============================================================================
//==============================================================================
#ifndef ELASTICITY_PRECONDITIONERS_HPP_
#define ELASTICITY_PRECONDITIONERS_HPP_
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/matrixmatrix.hh>
#include <dune/istl/ilu.hh>
#include <dune/istl/solvers.hh>
#include <dune/istl/preconditioners.hh>
#include <dune/istl/superlu.hh>
#include <dune/istl/umfpack.hh>
#include <dune/istl/paamg/amg.hh>
#include <dune/istl/paamg/fastamg.hh>
#include <dune/istl/paamg/twolevelmethod.hh>
#include <dune/istl/overlappingschwarz.hh>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/grid/CpGrid.hpp>
#include <opm/elasticity/asmhandler.hpp>
#include <opm/elasticity/matrixops.hpp>
namespace Opm {
namespace Elasticity {
#if defined(HAVE_SUITESPARSE_UMFPACK)
typedef Dune::UMFPack<Matrix> LUSolver;
#elif defined(HAVE_SUPERLU)
typedef Dune::SuperLU<Matrix> LUSolver;
#else
static_assert(false, "Enable either SuperLU or UMFPACK");
#endif
typedef Dune::MatrixAdapter<Matrix,Vector,Vector> Operator;
typedef Dune::SeqSSOR<Matrix, Vector, Vector> SSORSmoother;
typedef Dune::SeqJac<Matrix, Vector, Vector> JACSmoother;
typedef Dune::SeqILU<Matrix, Vector, Vector> ILUSmoother;
typedef Dune::SeqOverlappingSchwarz<Matrix,Vector,
Dune::SymmetricMultiplicativeSchwarzMode, LUSolver> SchwarzSmoother;
struct Schwarz {
typedef Dune::SeqOverlappingSchwarz<Matrix, Vector,
Dune::SymmetricMultiplicativeSchwarzMode,
LUSolver> type;
static std::shared_ptr<type>
setup(int /* pre */, int /* post */, int /* target */, int /* zcells */,
std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
ASMHandler<Dune::CpGrid>& A, bool& copy)
{
return std::shared_ptr<type>(setup2(op, gv, A, copy));
}
static type* setup2(std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
ASMHandler<Dune::CpGrid>& A, bool& copy);
};
template<class Smoother>
struct AMG1 {
typedef Dune::Amg::FirstDiagonal CouplingMetric;
typedef Dune::Amg::SymmetricCriterion<Matrix, CouplingMetric> CritBase;
typedef Dune::Amg::CoarsenCriterion<CritBase> Criterion;
typedef Dune::Amg::AMG<Operator, Vector, Smoother> type;
static std::shared_ptr<type>
setup(int pre, int post, int target, int zcells,
std::shared_ptr<Operator>& op, const Dune::CpGrid& /* gv */,
ASMHandler<Dune::CpGrid>& /* A */, bool& copy)
{
Criterion crit;
typename AMG1<Smoother>::type::SmootherArgs args;
args.relaxationFactor = 1.0;
crit.setCoarsenTarget(target);
crit.setGamma(1);
crit.setNoPreSmoothSteps(pre);
crit.setNoPostSmoothSteps(post);
crit.setDefaultValuesIsotropic(3, zcells);
std::cout << "\t collapsing 2x2x" << zcells << " cells per level" << std::endl;
copy = true;
return std::shared_ptr<type>(new type(*op, crit, args));
}
};
struct FastAMG {
typedef Dune::Amg::FastAMG<Operator, Vector> type;
static std::shared_ptr<type>
setup(int pre, int post, int target, int zcells,
std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
ASMHandler<Dune::CpGrid>& A, bool& copy);
};
template<class Smoother>
struct AMG2Level {
typedef Dune::Amg::AggregationLevelTransferPolicy<Operator,
typename AMG1<Smoother>::Criterion> TransferPolicy;
typedef Dune::Amg::LevelTransferPolicy<Operator, Operator> LevelTransferPolicy;
typedef Dune::Amg::OneStepAMGCoarseSolverPolicy<Operator, Smoother,
typename AMG1<Smoother>::Criterion> CoarsePolicy;
typedef typename Dune::Amg::SmootherTraits<Smoother>::Arguments SmootherArgs;
typedef Dune::Amg::TwoLevelMethod<Operator, CoarsePolicy, Schwarz::type> type;
static std::shared_ptr<type>
setup(int pre, int post, int target, int zcells,
std::shared_ptr<Operator>& op, const Dune::CpGrid& gv,
ASMHandler<Dune::CpGrid>& A, bool& copy)
{
typename AMG1<Smoother>::Criterion crit;
SmootherArgs args;
args.relaxationFactor = 1.0;
crit.setCoarsenTarget(target);
crit.setGamma(1);
crit.setNoPreSmoothSteps(pre);
crit.setNoPostSmoothSteps(post);
crit.setDefaultValuesIsotropic(3, zcells);
CoarsePolicy coarsePolicy(args, crit);
TransferPolicy policy(crit);
std::shared_ptr<Schwarz::type> fsp(Schwarz::setup2(op, gv, A, copy));
copy = true;
return std::shared_ptr<type>(new type(*op, fsp, policy, coarsePolicy, pre, post));
}
};
}
}
#endif
asmhandler.hpp
Class handling finite element assembly.
Opm::Elasticity::ASMHandler
Class handling finite element assembly.
Definition asmhandler.hpp:35
Opm::Elasticity::Operator
Dune::MatrixAdapter< Matrix, Vector, Vector > Operator
A linear operator.
Definition elasticity_preconditioners.hpp:49
Opm::Elasticity::JACSmoother
Dune::SeqJac< Matrix, Vector, Vector > JACSmoother
GJ AMG smoother.
Definition elasticity_preconditioners.hpp:55
Opm::Elasticity::SchwarzSmoother
Dune::SeqOverlappingSchwarz< Matrix, Vector, Dune::SymmetricMultiplicativeSchwarzMode, LUSolver > SchwarzSmoother
Schwarz + ILU0 AMG smoother.
Definition elasticity_preconditioners.hpp:62
Opm::Elasticity::SSORSmoother
Dune::SeqSSOR< Matrix, Vector, Vector > SSORSmoother
SSOR AMG smoother.
Definition elasticity_preconditioners.hpp:52
Opm::Elasticity::ILUSmoother
Dune::SeqILU< Matrix, Vector, Vector > ILUSmoother
ILU0 AMG smoother.
Definition elasticity_preconditioners.hpp:58
Opm::Elasticity::Smoother
Smoother
Smoother used in the AMG.
Definition elasticity_upscale.hpp:75
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
Opm
Inverting small matrices.
Definition ImplicitAssembly.hpp:43
Opm::Elasticity::AMG1
An AMG.
Definition elasticity_preconditioners.hpp:97
Opm::Elasticity::AMG1::Criterion
Dune::Amg::CoarsenCriterion< CritBase > Criterion
The coarsening criterion used in the AMG.
Definition elasticity_preconditioners.hpp:105
Opm::Elasticity::AMG1::CouplingMetric
Dune::Amg::FirstDiagonal CouplingMetric
The coupling metric used in the AMG.
Definition elasticity_preconditioners.hpp:99
Opm::Elasticity::AMG1::setup
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &, ASMHandler< Dune::CpGrid > &, bool &copy)
Setup preconditioner.
Definition elasticity_preconditioners.hpp:118
Opm::Elasticity::AMG1::CritBase
Dune::Amg::SymmetricCriterion< Matrix, CouplingMetric > CritBase
The coupling criterion used in the AMG.
Definition elasticity_preconditioners.hpp:102
Opm::Elasticity::AMG2Level
A two-level method with a coarse AMG solver.
Definition elasticity_preconditioners.hpp:159
Opm::Elasticity::AMG2Level::TransferPolicy
Dune::Amg::AggregationLevelTransferPolicy< Operator, typename AMG1< Smoother >::Criterion > TransferPolicy
AMG transfer policy.
Definition elasticity_preconditioners.hpp:162
Opm::Elasticity::AMG2Level::setup
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition elasticity_preconditioners.hpp:183
Opm::Elasticity::FastAMG
A FastAMG.
Definition elasticity_preconditioners.hpp:138
Opm::Elasticity::FastAMG::setup
static std::shared_ptr< type > setup(int pre, int post, int target, int zcells, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition elasticity_preconditioners.cpp:20
Opm::Elasticity::Schwarz
Overlapping Schwarz preconditioner.
Definition elasticity_preconditioners.hpp:65
Opm::Elasticity::Schwarz::setup
static std::shared_ptr< type > setup(int, int, int, int, std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition elasticity_preconditioners.hpp:79
Opm::Elasticity::Schwarz::setup2
static type * setup2(std::shared_ptr< Operator > &op, const Dune::CpGrid &gv, ASMHandler< Dune::CpGrid > &A, bool &copy)
Setup preconditioner.
Definition elasticity_preconditioners.cpp:37