Allow well operators with FlexibleSolver.

This commit is contained in:
Atgeirr Flø Rasmussen
2020-06-19 16:45:34 +02:00
parent 6d644da88e
commit c94eec872f
6 changed files with 225 additions and 146 deletions

View File

@@ -43,54 +43,56 @@ public:
using MatrixType = MatrixTypeT;
using VectorType = VectorTypeT;
/// Base class type of the operator passed to the solver.
using AbstractOperatorType = Dune::AssembledLinearOperator<MatrixType, VectorType, VectorType>;
/// Base class type of the contained preconditioner.
using AbstractPrecondType = Dune::PreconditionerWithUpdate<VectorType, VectorType>;
/// Create a sequential solver.
FlexibleSolver(const MatrixType& matrix,
FlexibleSolver(AbstractOperatorType& op,
const boost::property_tree::ptree& prm,
const std::function<VectorTypeT()>& weightsCalculator = std::function<VectorTypeT()>());
const std::function<VectorType()>& weightsCalculator = std::function<VectorType()>());
/// Create a parallel solver (if Comm is e.g. OwnerOverlapCommunication).
template <class Comm>
FlexibleSolver(const MatrixType& matrix,
FlexibleSolver(AbstractOperatorType& op,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<VectorTypeT()>& weightsCalculator = std::function<VectorTypeT()>());
const std::function<VectorType()>& weightsCalculator = std::function<VectorType()>());
virtual void apply(VectorType& x, VectorType& rhs, Dune::InverseOperatorResult& res) override;
virtual void apply(VectorType& x, VectorType& rhs, double reduction, Dune::InverseOperatorResult& res) override;
/// Type of the contained preconditioner.
using AbstractPrecondType = Dune::PreconditionerWithUpdate<VectorType, VectorType>;
/// Access the contained preconditioner.
AbstractPrecondType& preconditioner();
virtual Dune::SolverCategory::Category category() const override;
private:
using AbstractOperatorType = Dune::AssembledLinearOperator<MatrixType, VectorType, VectorType>;
using AbstractScalarProductType = Dune::ScalarProduct<VectorType>;
using AbstractSolverType = Dune::InverseOperator<VectorType, VectorType>;
// Machinery for making sequential or parallel operators/preconditioners/scalar products.
template <class Comm>
void initOpPrecSp(const MatrixType& matrix, const boost::property_tree::ptree& prm,
const std::function<VectorTypeT()> weightsCalculator, const Comm& comm);
void initOpPrecSp(AbstractOperatorType& op, const boost::property_tree::ptree& prm,
const std::function<VectorType()> weightsCalculator, const Comm& comm);
void initOpPrecSp(const MatrixType& matrix, const boost::property_tree::ptree& prm,
const std::function<VectorTypeT()> weightsCalculator, const Dune::Amg::SequentialInformation&);
void initOpPrecSp(AbstractOperatorType& op, const boost::property_tree::ptree& prm,
const std::function<VectorType()> weightsCalculator, const Dune::Amg::SequentialInformation&);
void initSolver(const boost::property_tree::ptree& prm, bool isMaster);
void initSolver(const boost::property_tree::ptree& prm, const bool is_iorank);
// Main initialization routine.
// Call with Comm == Dune::Amg::SequentialInformation to get a serial solver.
template <class Comm>
void init(const MatrixType& matrix,
void init(AbstractOperatorType& op,
const Comm& comm,
const boost::property_tree::ptree& prm,
const std::function<VectorTypeT()> weightsCalculator);
const std::function<VectorType()> weightsCalculator);
std::shared_ptr<AbstractOperatorType> linearoperator_;
AbstractOperatorType* linearoperator_for_solver_;
std::shared_ptr<AbstractOperatorType> linearoperator_for_precond_;
std::shared_ptr<AbstractPrecondType> preconditioner_;
std::shared_ptr<AbstractScalarProductType> scalarproduct_;
std::shared_ptr<AbstractSolverType> linsolver_;