81 using MatrixType =
typename OperatorType::matrix_type;
83 using AbstractOperatorType = Dune::AssembledLinearOperator<MatrixType, VectorType, VectorType>;
86 const std::function<VectorType()> weightsCalculator,
87 std::size_t pressureIndex)
88 : linear_operator_(linearoperator)
92 std::function<VectorType()>(), pressureIndex))
94 , weightsCalculator_(weightsCalculator)
95 , weights_(weightsCalculator())
96 , levelTransferPolicy_(dummy_comm_, weights_, prm, pressureIndex)
98 , twolevel_method_(linearoperator,
100 levelTransferPolicy_,
102 prm.
get<
int>(
"pre_smooth", 0),
103 prm.
get<
int>(
"post_smooth", 1))
106 if (prm.
get<
int>(
"verbosity", 0) > 10) {
107 std::string filename = prm.
get<std::string>(
"weights_filename",
"impes_weights.txt");
108 std::ofstream outfile(filename);
110 OPM_THROW(std::ofstream::failure,
111 "Could not write weights to file " + filename +
".");
113 Dune::writeMatrixMarket(weights_, outfile);
118 const std::function<VectorType()> weightsCalculator,
119 std::size_t pressureIndex,
const Communication& comm)
120 : linear_operator_(linearoperator)
124 std::function<VectorType()>(),
125 comm, pressureIndex))
127 , weightsCalculator_(weightsCalculator)
128 , weights_(weightsCalculator())
129 , levelTransferPolicy_(*comm_, weights_, prm, pressureIndex)
131 , twolevel_method_(linearoperator,
133 levelTransferPolicy_,
135 prm.
get<
int>(
"pre_smooth", 0),
136 prm.
get<
int>(
"post_smooth", 1))
139 if (prm.
get<
int>(
"verbosity", 0) > 10 && comm.communicator().rank() == 0) {
140 auto filename = prm.
get<std::string>(
"weights_filename",
"impes_weights.txt");
141 std::ofstream outfile(filename);
143 OPM_THROW(std::ofstream::failure,
144 "Could not write weights to file " + filename +
".");
146 Dune::writeMatrixMarket(weights_, outfile);
150 virtual void pre(VectorType& x, VectorType& b)
override
152 twolevel_method_.pre(x, b);
155 virtual void apply(VectorType& v,
const VectorType& d)
override
157 twolevel_method_.apply(v, d);
160 virtual void post(VectorType& x)
override
162 twolevel_method_.post(x);
165 virtual void update()
override
167 weights_ = weightsCalculator_();
171 virtual Dune::SolverCategory::Category category()
const override
173 return linear_operator_.category();
176 virtual bool hasPerfectUpdate()
const override {
177 return twolevel_method_.hasPerfectUpdate();
181 using CoarseOperator =
typename LevelTransferPolicy::CoarseOperator;
184 LevelTransferPolicy>;
189 template <
class Comm>
190 void updateImpl(
const Comm*)
193 twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
196 void updateImpl(
const Dune::Amg::SequentialInformation*)
199 twolevel_method_.updatePreconditioner(finesmoother_, coarseSolverPolicy_);
202 const OperatorType& linear_operator_;
203 std::shared_ptr<PreconditionerWithUpdate<VectorType, VectorType>> finesmoother_;
204 const Communication* comm_;
205 std::function<VectorType()> weightsCalculator_;
207 LevelTransferPolicy levelTransferPolicy_;
211 Communication dummy_comm_;
static PrecPtr create(const Operator &op, const PropertyTree &prm, const std::function< Vector()> &weightsCalculator={}, std::size_t pressureIndex=std::numeric_limits< std::size_t >::max())
Create a new serial preconditioner and return a pointer to it.
Definition PreconditionerFactory_impl.hpp:774