Pressure(Bhp)TransferPolicy: template Scalar type

This commit is contained in:
Arne Morten Kvarving 2024-04-13 15:18:32 +02:00
parent c240df73c4
commit b7bc7b7bf5
3 changed files with 99 additions and 93 deletions

View File

@ -69,10 +69,10 @@ struct AMGSmootherArgsHelper {
};
template <class M, class V, class C>
struct AMGSmootherArgsHelper<Opm::ParallelOverlappingILU0<M, V, V, C>> {
struct AMGSmootherArgsHelper<ParallelOverlappingILU0<M, V, V, C>> {
static auto args(const PropertyTree& prm)
{
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
using Smoother = ParallelOverlappingILU0<M, V, V, C>;
using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments;
SmootherArgs smootherArgs;
smootherArgs.iterations = prm.get<int>("iterations", 1);
@ -209,7 +209,7 @@ struct StandardPreconditioners {
const std::string smoother = prm.get<std::string>("smoother", "ParOverILU0");
// TODO: merge this with ILUn, and possibly simplify the factory to only work with ILU?
if (smoother == "ILU0" || smoother == "ParOverILU0") {
using Smoother = Opm::ParallelOverlappingILU0<M, V, V, C>;
using Smoother = ParallelOverlappingILU0<M, V, V, C>;
auto crit = AMGHelper<O, C, M, V>::criterion(prm);
auto sargs = AMGSmootherArgsHelper<Smoother>::args(prm);
PrecPtr prec = std::make_shared<Dune::Amg::AMGCPR<O, V, Smoother, C>>(op, crit, sargs, comm);
@ -279,7 +279,7 @@ struct StandardPreconditioners {
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, false>;
using LevelTransferPolicy = PressureTransferPolicy<O, Comm, double, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
@ -294,7 +294,7 @@ struct StandardPreconditioners {
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Comm, true>;
using LevelTransferPolicy = PressureTransferPolicy<O, Comm, double, true>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
@ -311,7 +311,7 @@ struct StandardPreconditioners {
OPM_THROW(std::logic_error,
"Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureBhpTransferPolicy<O, Comm, false>;
using LevelTransferPolicy = PressureBhpTransferPolicy<O, Comm, double, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy, Comm>>(
op, prm, weightsCalculator, pressureIndex, comm);
});
@ -321,12 +321,12 @@ struct StandardPreconditioners {
F::addCreator("CUILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
using CuILU0 = typename cuistl::
CuSeqILU0<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
auto cuILU0 = std::make_shared<CuILU0>(op.getmat(), w);
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(cuILU0);
auto wrapped = std::make_shared<Opm::cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
auto adapted = std::make_shared<cuistl::PreconditionerAdapter<V, V, CuILU0>>(cuILU0);
auto wrapped = std::make_shared<cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
return wrapped;
});
@ -334,21 +334,21 @@ struct StandardPreconditioners {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuJac =
typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
typename cuistl::CuJac<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
auto cuJac = std::make_shared<CuJac>(op.getmat(), w);
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
auto wrapped = std::make_shared<Opm::cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
auto adapted = std::make_shared<cuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
auto wrapped = std::make_shared<cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
return wrapped;
});
F::addCreator("CUDILU", [](const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t, const C& comm) {
using field_type = typename V::field_type;
using CuDILU = typename Opm::cuistl::CuDILU<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
using CuDILU = typename cuistl::CuDILU<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
auto cuDILU = std::make_shared<CuDILU>(op.getmat());
auto adapted = std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuDILU>>(cuDILU);
auto wrapped = std::make_shared<Opm::cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
auto adapted = std::make_shared<cuistl::PreconditionerAdapter<V, V, CuDILU>>(cuDILU);
auto wrapped = std::make_shared<cuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
return wrapped;
});
#endif
@ -368,11 +368,11 @@ struct StandardPreconditioners {
// Already a parallel preconditioner. Need to pass comm, but no need to wrap it in a BlockPreconditioner.
if (ilulevel == 0) {
const std::size_t num_interior = interiorIfGhostLast(comm);
return std::make_shared<Opm::ParallelOverlappingILU0<M, V, V, Comm>>(
op.getmat(), comm, w, Opm::MILU_VARIANT::ILU, num_interior, redblack, reorder_spheres);
return std::make_shared<ParallelOverlappingILU0<M, V, V, Comm>>(
op.getmat(), comm, w, MILU_VARIANT::ILU, num_interior, redblack, reorder_spheres);
} else {
return std::make_shared<Opm::ParallelOverlappingILU0<M, V, V, Comm>>(
op.getmat(), comm, ilulevel, w, Opm::MILU_VARIANT::ILU, redblack, reorder_spheres);
return std::make_shared<ParallelOverlappingILU0<M, V, V, Comm>>(
op.getmat(), comm, ilulevel, w, MILU_VARIANT::ILU, redblack, reorder_spheres);
}
}
@ -412,8 +412,8 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
using P = PropertyTree;
F::addCreator("ILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
return std::make_shared<Opm::ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), 0, w, Opm::MILU_VARIANT::ILU);
return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), 0, w, MILU_VARIANT::ILU);
});
F::addCreator("DuneILU", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
@ -424,14 +424,14 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
F::addCreator("ParOverILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
const int n = prm.get<int>("ilulevel", 0);
return std::make_shared<Opm::ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), n, w, Opm::MILU_VARIANT::ILU);
return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), n, w, MILU_VARIANT::ILU);
});
F::addCreator("ILUn", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const int n = prm.get<int>("ilulevel", 0);
const double w = prm.get<double>("relaxation", 1.0);
return std::make_shared<Opm::ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), n, w, Opm::MILU_VARIANT::ILU);
return std::make_shared<ParallelOverlappingILU0<M, V, V, C>>(
op.getmat(), n, w, MILU_VARIANT::ILU);
});
F::addCreator("DILU", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
DUNE_UNUSED_PARAMETER(prm);
@ -528,7 +528,7 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy
= Opm::PressureBhpTransferPolicy<O, Dune::Amg::SequentialInformation, false>;
= PressureBhpTransferPolicy<O, Dune::Amg::SequentialInformation, double, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
@ -540,7 +540,7 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Dune::Amg::SequentialInformation, false>;
using LevelTransferPolicy = PressureTransferPolicy<O, Dune::Amg::SequentialInformation, double, false>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
@ -550,7 +550,7 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
if (pressureIndex == std::numeric_limits<std::size_t>::max()) {
OPM_THROW(std::logic_error, "Pressure index out of bounds. It needs to specified for CPR");
}
using LevelTransferPolicy = Opm::PressureTransferPolicy<O, Dune::Amg::SequentialInformation, true>;
using LevelTransferPolicy = PressureTransferPolicy<O, Dune::Amg::SequentialInformation, double, true>;
return std::make_shared<OwningTwoLevelPreconditioner<O, V, LevelTransferPolicy>>(
op, prm, weightsCalculator, pressureIndex);
});
@ -559,9 +559,9 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
F::addCreator("CUILU0", [](const O& op, const P& prm, const std::function<V()>&, std::size_t) {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CuILU0>>(
using CuILU0 = typename cuistl::
CuSeqILU0<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
return std::make_shared<cuistl::PreconditionerAdapter<V, V, CuILU0>>(
std::make_shared<CuILU0>(op.getmat(), w));
});
@ -571,10 +571,10 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
using matrix_type_to =
typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
using CuILU0 = typename Opm::cuistl::
CuSeqILU0<matrix_type_to, Opm::cuistl::CuVector<float>, Opm::cuistl::CuVector<float>>;
using Adapter = typename Opm::cuistl::PreconditionerAdapter<VTo, VTo, CuILU0>;
using Converter = typename Opm::cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
using CuILU0 = typename cuistl::
CuSeqILU0<matrix_type_to, cuistl::CuVector<float>, cuistl::CuVector<float>>;
using Adapter = typename cuistl::PreconditionerAdapter<VTo, VTo, CuILU0>;
using Converter = typename cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
auto converted = std::make_shared<Converter>(op.getmat());
auto adapted = std::make_shared<Adapter>(std::make_shared<CuILU0>(converted->getConvertedMatrix(), w));
converted->setUnderlyingPreconditioner(adapted);
@ -585,24 +585,24 @@ struct StandardPreconditioners<Operator, Dune::Amg::SequentialInformation> {
const double w = prm.get<double>("relaxation", 1.0);
using field_type = typename V::field_type;
using CUJac =
typename Opm::cuistl::CuJac<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CUJac>>(
typename cuistl::CuJac<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
return std::make_shared<cuistl::PreconditionerAdapter<V, V, CUJac>>(
std::make_shared<CUJac>(op.getmat(), w));
});
F::addCreator("CUDILU", [](const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
using field_type = typename V::field_type;
using CUDILU = typename Opm::cuistl::CuDILU<M, Opm::cuistl::CuVector<field_type>, Opm::cuistl::CuVector<field_type>>;
return std::make_shared<Opm::cuistl::PreconditionerAdapter<V, V, CUDILU>>(std::make_shared<CUDILU>(op.getmat()));
using CUDILU = typename cuistl::CuDILU<M, cuistl::CuVector<field_type>, cuistl::CuVector<field_type>>;
return std::make_shared<cuistl::PreconditionerAdapter<V, V, CUDILU>>(std::make_shared<CUDILU>(op.getmat()));
});
F::addCreator("CUDILUFloat", [](const O& op, [[maybe_unused]] const P& prm, const std::function<V()>&, std::size_t) {
using block_type = typename V::block_type;
using VTo = Dune::BlockVector<Dune::FieldVector<float, block_type::dimension>>;
using matrix_type_to = typename Dune::BCRSMatrix<Dune::FieldMatrix<float, block_type::dimension, block_type::dimension>>;
using CuDILU = typename Opm::cuistl::CuDILU<matrix_type_to, Opm::cuistl::CuVector<float>, Opm::cuistl::CuVector<float>>;
using Adapter = typename Opm::cuistl::PreconditionerAdapter<VTo, VTo, CuDILU>;
using Converter = typename Opm::cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
using CuDILU = typename cuistl::CuDILU<matrix_type_to, cuistl::CuVector<float>, cuistl::CuVector<float>>;
using Adapter = typename cuistl::PreconditionerAdapter<VTo, VTo, CuDILU>;
using Converter = typename cuistl::PreconditionerConvertFieldTypeAdapter<Adapter, M, V, V>;
auto converted = std::make_shared<Converter>(op.getmat());
auto adapted = std::make_shared<Adapter>(std::make_shared<CuDILU>(converted->getConvertedMatrix()));
converted->setUnderlyingPreconditioner(adapted);
@ -744,7 +744,7 @@ using OpFSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Dune::FieldMatrix<double, Di
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;
template <int Dim>
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<Opm::MatrixBlock<double, Dim, Dim>>,
using OpBSeq = Dune::MatrixAdapter<Dune::BCRSMatrix<MatrixBlock<double, Dim, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>,
Dune::BlockVector<Dune::FieldVector<double, Dim>>>;

View File

@ -76,31 +76,36 @@ namespace Opm
namespace Details
{
using PressureMatrixType = Dune::BCRSMatrix<Opm::MatrixBlock<double, 1, 1>>;
using PressureVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>;
using SeqCoarseOperatorType = Dune::MatrixAdapter<PressureMatrixType, PressureVectorType, PressureVectorType>;
template <class Comm>
template<class Scalar> using PressureMatrixType = Dune::BCRSMatrix<MatrixBlock<Scalar, 1, 1>>;
template<class Scalar> using PressureVectorType = Dune::BlockVector<Dune::FieldVector<Scalar, 1>>;
template<class Scalar> using SeqCoarseOperatorType = Dune::MatrixAdapter<PressureMatrixType<Scalar>,
PressureVectorType<Scalar>,
PressureVectorType<Scalar>>;
template<class Scalar, class Comm>
using ParCoarseOperatorType
= Dune::OverlappingSchwarzOperator<PressureMatrixType, PressureVectorType, PressureVectorType, Comm>;
template <class Comm>
= Dune::OverlappingSchwarzOperator<PressureMatrixType<Scalar>,
PressureVectorType<Scalar>,
PressureVectorType<Scalar>,
Comm>;
template<class Scalar, class Comm>
using CoarseOperatorType = std::conditional_t<std::is_same<Comm, Dune::Amg::SequentialInformation>::value,
SeqCoarseOperatorType,
ParCoarseOperatorType<Comm>>;
SeqCoarseOperatorType<Scalar>,
ParCoarseOperatorType<Scalar,Comm>>;
} // namespace Details
template <class FineOperator, class Communication, bool transpose = false>
class PressureBhpTransferPolicy : public Dune::Amg::LevelTransferPolicyCpr<FineOperator, Details::CoarseOperatorType<Communication>>
template<class FineOperator, class Communication, class Scalar, bool transpose = false>
class PressureBhpTransferPolicy : public Dune::Amg::LevelTransferPolicyCpr<FineOperator, Details::CoarseOperatorType<Scalar,Communication>>
{
public:
typedef typename Details::CoarseOperatorType<Communication> CoarseOperator;
typedef Dune::Amg::LevelTransferPolicyCpr<FineOperator, CoarseOperator> ParentType;
typedef Communication ParallelInformation;
typedef typename FineOperator::domain_type FineVectorType;
using CoarseOperator = typename Details::CoarseOperatorType<Scalar,Communication>;
using ParentType = Dune::Amg::LevelTransferPolicyCpr<FineOperator, CoarseOperator>;
using ParallelInformation = Communication;
using FineVectorType= typename FineOperator::domain_type;
public:
PressureBhpTransferPolicy(const Communication& comm,
const FineVectorType& weights,
const Opm::PropertyTree& prm,
const PropertyTree& prm,
const std::size_t pressureIndex)
: communication_(&const_cast<Communication&>(comm))
, weights_(weights)
@ -109,7 +114,7 @@ namespace Opm
{
}
virtual void createCoarseLevelSystem(const FineOperator& fineOperator) override
void createCoarseLevelSystem(const FineOperator& fineOperator) override
{
OPM_TIMEBLOCK(createCoarseLevelSystem);
using CoarseMatrix = typename CoarseOperator::matrix_type;
@ -164,7 +169,7 @@ namespace Opm
this->operator_ = Dune::Amg::ConstructionTraits<CoarseOperator>::construct(oargs);
}
virtual void calculateCoarseEntries(const FineOperator& fineOperator) override
void calculateCoarseEntries(const FineOperator& fineOperator) override
{
OPM_TIMEBLOCK(calculateCoarseEntries);
const auto& fineMatrix = fineOperator.getmat();
@ -175,7 +180,7 @@ namespace Opm
auto entryCoarse = rowCoarse->begin();
for (auto entry = row->begin(), entryEnd = row->end(); entry != entryEnd; ++entry, ++entryCoarse) {
assert(entry.index() == entryCoarse.index());
double matrix_el = 0;
Scalar matrix_el = 0;
if (transpose) {
const auto& bw = weights_[entry.index()];
for (std::size_t i = 0; i < bw.size(); ++i) {
@ -203,7 +208,7 @@ namespace Opm
}
}
virtual void moveToCoarseLevel(const typename ParentType::FineRangeType& fine) override
void moveToCoarseLevel(const typename ParentType::FineRangeType& fine) override
{
OPM_TIMEBLOCK(moveToCoarseLevel);
//NB we iterate over fine assumming welldofs is at the end
@ -214,7 +219,7 @@ namespace Opm
for (auto block = begin; block != end; ++block) {
const auto& bw = weights_[block.index()];
double rhs_el = 0.0;
Scalar rhs_el = 0.0;
if (transpose) {
rhs_el = (*block)[pressure_var_index_];
} else {
@ -228,7 +233,7 @@ namespace Opm
this->lhs_ = 0;
}
virtual void moveToFineLevel(typename ParentType::FineDomainType& fine) override
void moveToFineLevel(typename ParentType::FineDomainType& fine) override
{
OPM_TIMEBLOCK(moveToFineLevel);
//NB we iterate over fine assumming welldofs is at the end
@ -246,7 +251,7 @@ namespace Opm
}
}
virtual PressureBhpTransferPolicy* clone() const override
PressureBhpTransferPolicy* clone() const override
{
return new PressureBhpTransferPolicy(*this);
}

View File

@ -28,39 +28,40 @@
#include <cstddef>
namespace Opm
{
namespace Details
{
using PressureMatrixType = Dune::BCRSMatrix<Opm::MatrixBlock<double, 1, 1>>;
using PressureVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>;
using SeqCoarseOperatorType = Dune::MatrixAdapter<PressureMatrixType, PressureVectorType, PressureVectorType>;
template <class Comm>
namespace Opm { namespace Details {
template<class Scalar> using PressureMatrixType = Dune::BCRSMatrix<MatrixBlock<Scalar, 1, 1>>;
template<class Scalar> using PressureVectorType = Dune::BlockVector<Dune::FieldVector<Scalar, 1>>;
template<class Scalar> using SeqCoarseOperatorType = Dune::MatrixAdapter<PressureMatrixType<Scalar>,
PressureVectorType<Scalar>,
PressureVectorType<Scalar>>;
template<class Scalar, class Comm>
using ParCoarseOperatorType
= Dune::OverlappingSchwarzOperator<PressureMatrixType, PressureVectorType, PressureVectorType, Comm>;
template <class Comm>
= Dune::OverlappingSchwarzOperator<PressureMatrixType<Scalar>,
PressureVectorType<Scalar>,
PressureVectorType<Scalar>,
Comm>;
template<class Scalar, class Comm>
using CoarseOperatorType = std::conditional_t<std::is_same<Comm, Dune::Amg::SequentialInformation>::value,
SeqCoarseOperatorType,
ParCoarseOperatorType<Comm>>;
SeqCoarseOperatorType<Scalar>,
ParCoarseOperatorType<Scalar,Comm>>;
} // namespace Details
template <class FineOperator, class Communication, bool transpose = false>
template <class FineOperator, class Communication, class Scalar, bool transpose = false>
class PressureTransferPolicy
: public Dune::Amg::LevelTransferPolicyCpr<FineOperator, Details::CoarseOperatorType<Communication>>
: public Dune::Amg::LevelTransferPolicyCpr<FineOperator, Details::CoarseOperatorType<Scalar,Communication>>
{
public:
typedef typename Details::CoarseOperatorType<Communication> CoarseOperator;
typedef Dune::Amg::LevelTransferPolicyCpr<FineOperator, CoarseOperator> ParentType;
typedef Communication ParallelInformation;
typedef typename FineOperator::domain_type FineVectorType;
using CoarseOperator = typename Details::CoarseOperatorType<Scalar,Communication>;
using ParentType = Dune::Amg::LevelTransferPolicyCpr<FineOperator, CoarseOperator>;
using ParallelInformation = Communication;
using FineVectorType = typename FineOperator::domain_type;
public:
PressureTransferPolicy(const Communication& comm,
const FineVectorType& weights,
const Opm::PropertyTree& /*prm*/,
const PropertyTree& /*prm*/,
int pressure_var_index)
: communication_(&const_cast<Communication&>(comm))
, weights_(weights)
@ -68,7 +69,7 @@ public:
{
}
virtual void createCoarseLevelSystem(const FineOperator& fineOperator) override
void createCoarseLevelSystem(const FineOperator& fineOperator) override
{
using CoarseMatrix = typename CoarseOperator::matrix_type;
const auto& fineLevelMatrix = fineOperator.getmat();
@ -92,7 +93,7 @@ public:
this->operator_ = Dune::Amg::ConstructionTraits<CoarseOperator>::construct(oargs);
}
virtual void calculateCoarseEntries(const FineOperator& fineOperator) override
void calculateCoarseEntries(const FineOperator& fineOperator) override
{
const auto& fineMatrix = fineOperator.getmat();
*coarseLevelMatrix_ = 0;
@ -102,7 +103,7 @@ public:
auto entryCoarse = rowCoarse->begin();
for (auto entry = row->begin(), entryEnd = row->end(); entry != entryEnd; ++entry, ++entryCoarse) {
assert(entry.index() == entryCoarse.index());
double matrix_el = 0;
Scalar matrix_el = 0;
if (transpose) {
const auto& bw = weights_[entry.index()];
for (std::size_t i = 0; i < bw.size(); ++i) {
@ -120,7 +121,7 @@ public:
assert(rowCoarse == coarseLevelMatrix_->end());
}
virtual void moveToCoarseLevel(const typename ParentType::FineRangeType& fine) override
void moveToCoarseLevel(const typename ParentType::FineRangeType& fine) override
{
// Set coarse vector to zero
this->rhs_ = 0;
@ -129,7 +130,7 @@ public:
for (auto block = begin; block != end; ++block) {
const auto& bw = weights_[block.index()];
double rhs_el = 0.0;
Scalar rhs_el = 0.0;
if (transpose) {
rhs_el = (*block)[pressure_var_index_];
} else {
@ -143,7 +144,7 @@ public:
this->lhs_ = 0;
}
virtual void moveToFineLevel(typename ParentType::FineDomainType& fine) override
void moveToFineLevel(typename ParentType::FineDomainType& fine) override
{
auto end = fine.end(), begin = fine.begin();
@ -159,7 +160,7 @@ public:
}
}
virtual PressureTransferPolicy* clone() const override
PressureTransferPolicy* clone() const override
{
return new PressureTransferPolicy(*this);
}