// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #include "config.h" #include #include #include #include // include direct solvers to see whether it compiles (should throw an exception if used) #include #include #include #include #include using namespace Dune; template class MatrixFreeLaplacian2D : public LinearOperator{ public: using domain_type = V; using range_type = V; using field_type = typename domain_type::field_type; MatrixFreeLaplacian2D() = default; void apply(const domain_type& x, range_type& y) const override{ assert(x.N() == y.N()); y[0] = 2*x[0] - x[1]; for(size_t i=1; i class MatrixFreeBlockJacobi : public Preconditioner{ public: using domain_type = V; using range_type = V; using field_type = typename V::field_type; MatrixFreeBlockJacobi() { dia_block_inv = 0.; for(size_t i=0;i dia_block_inv; }; using V = BlockVector; int main(int argc, char** argv){ ParameterTree config; config["type"] = "minressolver"; config["verbose"] = "2"; config["maxit"] = "10000"; config["reduction"] = "1e-8"; config.report(); initSolverFactories>(); std::shared_ptr> op = std::make_shared>(); using Prec = MatrixFreeBlockJacobi; std::shared_ptr prec = std::make_shared(); auto solver = getSolverFromFactory(op, config, prec); V b(1000); V x = b; x = 1.; b = 0.; InverseOperatorResult res; solver->apply(x,b,res); return 0; }