diff --git a/dumux/common/deprecated.hh b/dumux/common/deprecated.hh index b89d7ee8958fdd1db2f9fc1a3de1d4b82791fa55..4e272472a52c05130c9effbc2836b6779adcbf5c 100644 --- a/dumux/common/deprecated.hh +++ b/dumux/common/deprecated.hh @@ -40,24 +40,6 @@ namespace Deprecated { #pragma clang diagnostic pop #endif // __clang__ -template<class CO2Impl> - struct BrineCO2Helper{ - template<class CO2Arg> - using TabulatedDensityDetector = decltype(std::declval<CO2Arg>().tabulatedDensity); - static constexpr bool rawCO2Table = Dune::Std::is_detected<TabulatedDensityDetector, - CO2Impl >::value; - - template< typename T> - [[deprecated("Passing just CO2Tables to define a BrineCO2 fluidsystem/binarycoefficient is deprecated. Use Components::CO2<Scalar, CO2Tables> as template parameter instead.")]] - static constexpr void DefiningBrineCO2WithCO2Table() {} - - static constexpr bool isRawTable() - { - if constexpr (rawCO2Table) - DefiningBrineCO2WithCO2Table<CO2Impl>(); - return rawCO2Table; - } - }; } // end namespace Deprecated #endif diff --git a/dumux/common/pdesolver.hh b/dumux/common/pdesolver.hh index a62b2ac61d1e1258c1f4ea8049548cb0095b47e4..6354b45fdc4908524eeb7ef301ff932550a575d5 100644 --- a/dumux/common/pdesolver.hh +++ b/dumux/common/pdesolver.hh @@ -151,6 +151,12 @@ protected: return matrixHasCorrectSize; } + /*! + * \brief Default implementation for any matrix type + */ + template <class M> + bool checkSizesOfSubMatrices(const M&) const { return true; } + private: std::shared_ptr<Assembler> assembler_; std::shared_ptr<LinearSolver> linearSolver_; diff --git a/dumux/linear/amgbackend.hh b/dumux/linear/amgbackend.hh deleted file mode 100644 index 4bbf883c5b60526ab972bd6ca6e8d5d9a657ffb3..0000000000000000000000000000000000000000 --- a/dumux/linear/amgbackend.hh +++ /dev/null @@ -1,245 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -// -// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder -// SPDX-License-Identifier: GPL-3.0-or-later -// -/*! - * \file - * \ingroup Linear - * \brief Provides a parallel linear solver based on the ISTL AMG preconditioner - * and the ISTL BiCGSTAB solver. - */ -#ifndef DUMUX_PARALLEL_AMGBACKEND_HH -#define DUMUX_PARALLEL_AMGBACKEND_HH - -#warning "This header is deprecated and will be removed after release 3.7. Use the AMG solver from dumux/linear/istlsolvers.hh" - -#include <memory> - -#include <dune/common/exceptions.hh> -#include <dune/common/parallel/indexset.hh> -#include <dune/common/parallel/mpicommunication.hh> -#include <dune/common/parallel/mpihelper.hh> -#include <dune/grid/common/capabilities.hh> -#include <dune/istl/paamg/amg.hh> -#include <dune/istl/paamg/pinfo.hh> -#include <dune/istl/solvers.hh> - -#include <dumux/linear/solver.hh> -#include <dumux/linear/parallelhelpers.hh> -#include <dumux/linear/solvercategory.hh> - -namespace Dumux { - -// OLD AMG Backend. Use the new one from dumux/linear/istlsolvers.hh -template <class LinearSolverTraits> -class AMGBiCGSTABBackend : public LinearSolver -{ -public: - /*! - * \brief Construct the backend for the sequential case only - * - * \param paramGroup the parameter group for parameter lookup - */ - [[deprecated("Use new AMGBiCGSTABIstlSolver<LinearSolverTraits, LinearAlgebraTraits> with 2nd template parameter from dumux/linear/istlsolvers.hh.")]] - AMGBiCGSTABBackend(const std::string& paramGroup = "") - : LinearSolver(paramGroup) - , isParallel_(Dune::MPIHelper::getCommunication().size() > 1) - { - if (isParallel_) - DUNE_THROW(Dune::InvalidStateException, "Using sequential constructor for parallel run. Use signature with gridView and dofMapper!"); - - checkAvailabilityOfDirectSolver_(); - } - - /*! - * \brief Construct the backend for parallel or sequential runs - * - * \param gridView the grid view on which we are performing the multi-grid - * \param dofMapper an index mapper for dof entities - * \param paramGroup the parameter group for parameter lookup - */ - [[deprecated("Use new AMGBiCGSTABIstlSolver<LinearSolverTraits, LinearAlgebraTraits> with 2nd template parameter from dumux/linear/istlsolvers.hh.")]] - AMGBiCGSTABBackend(const typename LinearSolverTraits::GridView& gridView, - const typename LinearSolverTraits::DofMapper& dofMapper, - const std::string& paramGroup = "") - : LinearSolver(paramGroup) -#if HAVE_MPI - , isParallel_(Dune::MPIHelper::getCommunication().size() > 1) -#endif - { -#if HAVE_MPI - if constexpr (LinearSolverTraits::canCommunicate) - { - if (isParallel_) - phelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); - } -#endif - checkAvailabilityOfDirectSolver_(); - } - - /*! - * \brief Update the solver after grid adaption - * - * \param gridView the grid view on which we are performing the multi-grid - * \param dofMapper an index mapper for dof entities - */ - void updateAfterGridAdaption(const typename LinearSolverTraits::GridView& gridView, - const typename LinearSolverTraits::DofMapper& dofMapper) - { -#if HAVE_MPI - if (isParallel_) - phelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); -#endif - } - - /*! - * \brief Solve a linear system. - * - * \param A the matrix - * \param x the seeked solution vector, containing the initial solution upon entry - * \param b the right hand side vector - */ - template<class Matrix, class Vector> - bool solve(Matrix& A, Vector& x, Vector& b) - { -#if HAVE_MPI - solveSequentialOrParallel_(A, x, b); -#else - solveSequential_(A, x, b); -#endif - return result_.converged; - } - - /*! - * \brief The name of the solver - */ - std::string name() const - { - return "AMG-preconditioned BiCGSTAB solver"; - } - - /*! - * \brief The result containing the convergence history. - */ - const Dune::InverseOperatorResult& result() const - { - return result_; - } - - template<class Vector> - Scalar norm(const Vector& x) const = delete; - -private: - //! see https://gitlab.dune-project.org/core/dune-istl/-/issues/62 - void checkAvailabilityOfDirectSolver_() - { -#if !HAVE_SUPERLU && !HAVE_UMFPACK - std::cout << "\nAMGBiCGSTABBackend: No direct solver backend found. Using iterative solver as coarse grid solver.\n" - << "Note that dune-istl currently hard-codes a tolerance of 1e-2 for the iterative coarse grid solver.\n" - << "This may result in reduced accuracy or performance depending on your setup.\nConsider installing " - << "UMFPack (SuiteSparse) or SuperLU or apply the istl patch, see dumux/patches/README.md." << std::endl; -#endif - } - -#if HAVE_MPI - template<class Matrix, class Vector> - void solveSequentialOrParallel_(Matrix& A, Vector& x, Vector& b) - { - if constexpr (LinearSolverTraits::canCommunicate) - { - if (isParallel_) - { - if (LinearSolverTraits::isNonOverlapping(phelper_->gridView())) - { - using PTraits = typename LinearSolverTraits::template ParallelNonoverlapping<Matrix, Vector>; - solveParallel_<PTraits>(A, x, b); - } - else - { - using PTraits = typename LinearSolverTraits::template ParallelOverlapping<Matrix, Vector>; - solveParallel_<PTraits>(A, x, b); - } - } - else - solveSequential_(A, x, b); - } - else - { - solveSequential_(A, x, b); - } - } - - template<class ParallelTraits, class Matrix, class Vector> - void solveParallel_(Matrix& A, Vector& x, Vector& b) - { - using Comm = typename ParallelTraits::Comm; - using LinearOperator = typename ParallelTraits::LinearOperator; - using ScalarProduct = typename ParallelTraits::ScalarProduct; - - std::shared_ptr<Comm> comm; - std::shared_ptr<LinearOperator> linearOperator; - std::shared_ptr<ScalarProduct> scalarProduct; - prepareLinearAlgebraParallel<LinearSolverTraits, ParallelTraits>(A, b, comm, linearOperator, scalarProduct, *phelper_); - - using SeqSmoother = Dune::SeqSSOR<Matrix, Vector, Vector>; - using Smoother = typename ParallelTraits::template Preconditioner<SeqSmoother>; - solveWithAmg_<Smoother>(A, x, b, linearOperator, comm, scalarProduct); - } -#endif // HAVE_MPI - - template<class Matrix, class Vector> - void solveSequential_(Matrix& A, Vector& x, Vector& b) - { - using Comm = Dune::Amg::SequentialInformation; - using Traits = typename LinearSolverTraits::template Sequential<Matrix, Vector>; - using LinearOperator = typename Traits::LinearOperator; - using ScalarProduct = typename Traits::ScalarProduct; - - auto comm = std::make_shared<Comm>(); - auto linearOperator = std::make_shared<LinearOperator>(A); - auto scalarProduct = std::make_shared<ScalarProduct>(); - - using Smoother = Dune::SeqSSOR<Matrix, Vector, Vector>; - solveWithAmg_<Smoother>(A, x, b, linearOperator, comm, scalarProduct); - } - - template<class Smoother, class Matrix, class Vector, class LinearOperator, class Comm, class ScalarProduct> - void solveWithAmg_(Matrix& A, Vector& x, Vector& b, - std::shared_ptr<LinearOperator>& linearOperator, - std::shared_ptr<Comm>& comm, - std::shared_ptr<ScalarProduct>& scalarProduct) - { - using SmootherArgs = typename Dune::Amg::SmootherTraits<Smoother>::Arguments; - using Criterion = Dune::Amg::CoarsenCriterion<Dune::Amg::SymmetricCriterion<Matrix, Dune::Amg::FirstDiagonal>>; - - //! \todo Check whether the default accumulation mode atOnceAccu is needed. - //! \todo make parameters changeable at runtime from input file / parameter tree - Dune::Amg::Parameters params(15, 2000, 1.2, 1.6, Dune::Amg::atOnceAccu); - params.setDefaultValuesIsotropic(LinearSolverTraits::GridView::dimension); - params.setDebugLevel(this->verbosity()); - Criterion criterion(params); - SmootherArgs smootherArgs; - smootherArgs.iterations = 1; - smootherArgs.relaxationFactor = 1; - - using Amg = Dune::Amg::AMG<LinearOperator, Vector, Smoother, Comm>; - auto amg = std::make_shared<Amg>(*linearOperator, criterion, smootherArgs, *comm); - - Dune::BiCGSTABSolver<Vector> solver(*linearOperator, *scalarProduct, *amg, this->residReduction(), this->maxIter(), - comm->communicator().rank() == 0 ? this->verbosity() : 0); - - solver.apply(x, b, result_); - } - -#if HAVE_MPI - std::unique_ptr<ParallelISTLHelper<LinearSolverTraits>> phelper_; -#endif - Dune::InverseOperatorResult result_; - bool isParallel_ = false; -}; - -} // end namespace Dumux - -#endif diff --git a/dumux/linear/istlsolverfactorybackend.hh b/dumux/linear/istlsolverfactorybackend.hh index 9500bda36fd7434683e0afab95aefd674867c6d0..40e6709e10ab259b0d45db448c6629d108a544ca 100644 --- a/dumux/linear/istlsolverfactorybackend.hh +++ b/dumux/linear/istlsolverfactorybackend.hh @@ -97,47 +97,6 @@ class OldIstlSolverFactoryBackend : public LinearSolver { public: - /*! - * \brief Construct the backend for the sequential case only - * - * \param paramGroup the parameter group for parameter lookup - */ - [[deprecated("Use new IstlSolverFactoryBackend<LinearSolverTraits, LinearAlgebraTraits> with 2nd template parameter. Will be removed after 3.7.")]] - OldIstlSolverFactoryBackend(const std::string& paramGroup = "") - : paramGroup_(paramGroup) - , isParallel_(Dune::MPIHelper::getCommunication().size() > 1) - { - if (isParallel_) - DUNE_THROW(Dune::InvalidStateException, "Using sequential constructor for parallel run. Use signature with gridView and dofMapper!"); - - firstCall_ = true; - initializeParameters_(); - } - - /*! - * \brief Construct the backend for parallel or sequential runs - * - * \param gridView the grid view for parallel communication via the grid - * \param dofMapper an index mapper for dof entities - * \param paramGroup the parameter group for parameter lookup - */ - [[deprecated("Use new IstlSolverFactoryBackend<LinearSolverTraits, LinearAlgebraTraits> with 2nd template parameter. Will be removed after 3.7.")]] - OldIstlSolverFactoryBackend(const typename LinearSolverTraits::GridView& gridView, - const typename LinearSolverTraits::DofMapper& dofMapper, - const std::string& paramGroup = "") - : paramGroup_(paramGroup) -#if HAVE_MPI - , isParallel_(Dune::MPIHelper::getCommunication().size() > 1) -#endif - { - firstCall_ = true; - initializeParameters_(); -#if HAVE_MPI - if (isParallel_) - parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); -#endif - } - /*! * \brief Update the solver after grid adaption * diff --git a/dumux/linear/linearsolveracceptsmultitypematrix.hh b/dumux/linear/linearsolveracceptsmultitypematrix.hh deleted file mode 100644 index 5df421ee65dbc6c0bd9447ae320d5955586a3f59..0000000000000000000000000000000000000000 --- a/dumux/linear/linearsolveracceptsmultitypematrix.hh +++ /dev/null @@ -1,80 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -// -// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder -// SPDX-License-Identifier: GPL-3.0-or-later -// -/*! - * \file - * \ingroup Linear - * \brief Trait checking if linear solvers accept Dune::MultiTypeBlockMatrix or we need to convert the matrix - */ -#ifndef DUMUX_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_HH -#define DUMUX_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_HH - -#include <dumux/linear/seqsolverbackend.hh> -#ifndef DUMUX_SUPPRESS_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_WARNING -#warning "This header is deprecated and will be removed after release 3.7." -#endif - -// suppress all secondary deprecation warning from this deprecated file -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - -namespace Dumux { - -//! The default -template<class LinearSolver> -struct linearSolverAcceptsMultiTypeMatrix : public std::true_type {}; - -//! Solvers that don't accept multi-type matrices -//! Those are all with ILU preconditioner that doesn't support the additional block level -//! And the direct solvers that have BCRS Matrix hardcoded - -class ILUnBiCGSTABBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILUnBiCGSTABBackend> : public std::false_type {}; - -class ILUnCGBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILUnCGBackend> : public std::false_type {}; - -class ILU0BiCGSTABBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILU0BiCGSTABBackend> : public std::false_type {}; - -class ILU0CGBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILU0CGBackend> : public std::false_type {}; - -class ILU0RestartedGMResBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILU0RestartedGMResBackend> : public std::false_type {}; - -class ILUnRestartedGMResBackend; - -template<> -struct linearSolverAcceptsMultiTypeMatrix<ILUnRestartedGMResBackend> : public std::false_type {}; - -#if HAVE_SUPERLU -class SuperLUBackend; -template<> -struct linearSolverAcceptsMultiTypeMatrix<SuperLUBackend> : public std::false_type {}; -#endif // HAVE_SUPERLU - -#if HAVE_UMFPACK -class UMFPackBackend; -template<> -struct linearSolverAcceptsMultiTypeMatrix<UMFPackBackend> : public std::false_type {}; -#endif // HAVE_UMFPACK - -} // end namespace Dumux - -#pragma GCC diagnostic pop - -#endif diff --git a/dumux/linear/pdesolver.hh b/dumux/linear/pdesolver.hh index 8a51739c803e0a5320589a3558abe9b8f39b70ed..9e900695174943418b18a5c139c1d5bf0e46949b 100644 --- a/dumux/linear/pdesolver.hh +++ b/dumux/linear/pdesolver.hh @@ -32,11 +32,6 @@ #include <dumux/common/pdesolver.hh> #include <dumux/common/variablesbackend.hh> -// remove after deprecated code is removed (after 3.7) -#define DUMUX_SUPPRESS_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_WARNING -#include <dumux/linear/linearsolveracceptsmultitypematrix.hh> -#undef DUMUX_SUPPRESS_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_WARNING - #include <dumux/linear/matrixconverter.hh> namespace Dumux::Detail::LinearPDESolver { @@ -254,98 +249,13 @@ private: ); } - return solveLinearSystemImpl_(this->linearSolver(), - this->assembler().jacobian(), - deltaU, - this->assembler().residual()); - } - - /*! - * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. - * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for linear solvers that can handle MultiType matrices. - * - */ - template<class V = ResidualVector> - typename std::enable_if_t<!isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) - { - return ls.solve(A, x, b); - } - - - /*! - * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. - * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for linear solvers that can handle MultiType matrices. - * - */ - template<class LS = LinearSolver, class V = ResidualVector> - typename std::enable_if_t<linearSolverAcceptsMultiTypeMatrix<LS>() && - isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) - { - assert(this->checkSizesOfSubMatrices(A) && "Sub-blocks of MultiTypeBlockMatrix have wrong sizes!"); - return ls.solve(A, x, b); - } - - /*! - * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. - * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for linear solvers that cannot handle MultiType matrices. - * We copy the matrix into a 1x1 block BCRS matrix before solving. - * - */ - template<class LS = LinearSolver, class V = ResidualVector> - [[deprecated("After 3.7 LinearPDESolver will no longer support conversion of multitype matrices for solvers that don't support this feature!")]] - typename std::enable_if_t<!linearSolverAcceptsMultiTypeMatrix<LS>() && - isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) - { - assert(this->checkSizesOfSubMatrices(A) && "Sub-blocks of MultiTypeBlockMatrix have wrong sizes!"); - - // create the bcrs matrix the IterativeSolver backend can handle - const auto M = MatrixConverter<JacobianMatrix>::multiTypeToBCRSMatrix(A); - - // get the new matrix sizes - const std::size_t numRows = M.N(); - assert(numRows == M.M()); - - // create the vector the IterativeSolver backend can handle - const auto bTmp = VectorConverter<SolutionVector>::multiTypeToBlockVector(b); - assert(bTmp.size() == numRows); - - // create a blockvector to which the linear solver writes the solution - using VectorBlock = typename Dune::FieldVector<Scalar, 1>; - using BlockVector = typename Dune::BlockVector<VectorBlock>; - BlockVector y(numRows); - - // solve - const bool converged = ls.solve(M, y, bTmp); - - // copy back the result y into x - if(converged) - VectorConverter<SolutionVector>::retrieveValues(x, y); + assert(this->checkSizesOfSubMatrices(this->assembler().jacobian()) && "Matrix blocks have wrong sizes!"); - return converged; + return this->linearSolver().solve( + this->assembler().jacobian(), + deltaU, + this->assembler().residual() + ); } //! initialize the parameters by reading from the parameter tree diff --git a/dumux/material/binarycoefficients/brine_co2.hh b/dumux/material/binarycoefficients/brine_co2.hh index 0d18a6617696e47a629587a02549074bee88a4b5..cc59e6d856be01c614e4f60da09230d1020c7a73 100644 --- a/dumux/material/binarycoefficients/brine_co2.hh +++ b/dumux/material/binarycoefficients/brine_co2.hh @@ -16,7 +16,6 @@ #include <type_traits> #include <dune/common/debugstream.hh> -#include <dumux/common/deprecated.hh> #include <dumux/common/parameters.hh> #include <dumux/material/components/brine.hh> #include <dumux/material/components/h2o.hh> @@ -29,15 +28,9 @@ namespace Dumux::BinaryCoeff { * \ingroup Binarycoefficients * \brief Binary coefficients for brine and CO2. */ -template<class Scalar, class CO2Impl, bool verbose = true> +template<class Scalar, class CO2, bool verbose = true> class Brine_CO2 { using H2O = Components::H2O<Scalar>; - - static constexpr bool rawCO2Table = Deprecated::BrineCO2Helper<CO2Impl>::isRawTable(); - using CO2Component = typename std::conditional_t< rawCO2Table, - Components::CO2<Scalar, CO2Impl>, - CO2Impl >; - using CO2 = CO2Component; using IdealGas = Dumux::IdealGas<Scalar>; static constexpr int lPhaseIdx = 0; // index of the liquid phase static constexpr int gPhaseIdx = 1; // index of the gas phase diff --git a/dumux/material/fluidsystems/brineco2.hh b/dumux/material/fluidsystems/brineco2.hh index f82e9412e0c988cfb05603dede4a571bc55148c6..06a3a99b756ecab1b70195811077dffe2d826236 100644 --- a/dumux/material/fluidsystems/brineco2.hh +++ b/dumux/material/fluidsystems/brineco2.hh @@ -16,7 +16,6 @@ #include <dune/common/exceptions.hh> -#include <dumux/common/deprecated.hh> #include <dumux/common/parameters.hh> #include <dumux/material/idealgas.hh> #include <dumux/material/fluidsystems/base.hh> @@ -94,21 +93,14 @@ struct BrineCO2DefaultPolicy * \note This implementation always assumes NaCl stays in the liquid phase. */ template< class Scalar, - class CO2Impl, + class CO2Component, class H2OType = Components::TabulatedComponent<Components::H2O<Scalar>>, class Policy = BrineCO2DefaultPolicy</*constantSalinity?*/true> > class BrineCO2 -: public Base<Scalar, BrineCO2<Scalar, CO2Impl, H2OType, Policy>> +: public Base<Scalar, BrineCO2<Scalar, CO2Component, H2OType, Policy>> , public Detail::BrineCO2Indices<Policy::useConstantSalinity()> { - using ThisType = BrineCO2<Scalar, CO2Impl, H2OType, Policy>; - - static constexpr bool rawCO2Table = Deprecated::BrineCO2Helper<CO2Impl>::isRawTable(); - - using CO2Component = typename std::conditional_t< rawCO2Table, - Components::CO2<Scalar, CO2Impl>, - CO2Impl >; - + using ThisType = BrineCO2<Scalar, CO2Component, H2OType, Policy>; // binary coefficients using Brine_CO2 = BinaryCoeff::Brine_CO2<Scalar, CO2Component>; diff --git a/dumux/nonlinear/newtonsolver.hh b/dumux/nonlinear/newtonsolver.hh index 73c70df6075bd16f70c2e82cd89b31cc0bc0d0d6..2322be668b3efd1272c041a561757f4d4e3bc4cd 100644 --- a/dumux/nonlinear/newtonsolver.hh +++ b/dumux/nonlinear/newtonsolver.hh @@ -40,11 +40,6 @@ #include <dumux/io/format.hh> -// remove after deprecated code is removed (after 3.7) -#define DUMUX_SUPPRESS_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_WARNING -#include <dumux/linear/linearsolveracceptsmultitypematrix.hh> -#undef DUMUX_SUPPRESS_LINEAR_SOLVER_ACCEPTS_MULTITYPEMATRIX_WARNING - #include <dumux/linear/matrixconverter.hh> #include <dumux/assembly/partialreassembler.hh> @@ -1084,100 +1079,20 @@ private: "Chopped Newton update strategy not implemented."); } - virtual bool solveLinearSystem_(ResidualVector& deltaU) - { - return solveLinearSystemImpl_(this->linearSolver(), - this->assembler().jacobian(), - deltaU, - this->assembler().residual()); - } - /*! * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for regular vector types (not MultiTypeBlockVector) - * + * Throws Dumux::NumericalProblem if the linear solver didn't converge. */ - template<class V = ResidualVector> - typename std::enable_if_t<!isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) - { - return ls.solve(A, x, b); - } - - - /*! - * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. - * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for linear solvers that can handle MultiType matrices. - * - */ - template<class LS = LinearSolver, class V = ResidualVector> - typename std::enable_if_t<linearSolverAcceptsMultiTypeMatrix<LS>() && - isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) - { - assert(this->checkSizesOfSubMatrices(A) && "Sub-blocks of MultiTypeBlockMatrix have wrong sizes!"); - return ls.solve(A, x, b); - } - - /*! - * \brief Solve the linear system of equations \f$\mathbf{A}x - b = 0\f$. - * - * Throws Dumux::NumericalProblem if the linear solver didn't - * converge. - * - * Specialization for linear solvers that cannot handle MultiType matrices. - * We copy the matrix into a 1x1 block BCRS matrix before solving. - * - */ - template<class LS = LinearSolver, class V = ResidualVector> - [[deprecated("After 3.7 Newton will no longer support conversion of multitype matrices for solvers that don't support this feature!")]] - typename std::enable_if_t<!linearSolverAcceptsMultiTypeMatrix<LS>() && - isMultiTypeBlockVector<V>(), bool> - solveLinearSystemImpl_(LinearSolver& ls, - JacobianMatrix& A, - ResidualVector& x, - ResidualVector& b) + virtual bool solveLinearSystem_(ResidualVector& deltaU) { - assert(this->checkSizesOfSubMatrices(A) && "Sub-blocks of MultiTypeBlockMatrix have wrong sizes!"); - - // create the bcrs matrix the IterativeSolver backend can handle - const auto M = MatrixConverter<JacobianMatrix>::multiTypeToBCRSMatrix(A); - - // get the new matrix sizes - const std::size_t numRows = M.N(); - assert(numRows == M.M()); - - // create the vector the IterativeSolver backend can handle - const auto bTmp = VectorConverter<ResidualVector>::multiTypeToBlockVector(b); - assert(bTmp.size() == numRows); - - // create a blockvector to which the linear solver writes the solution - using VectorBlock = typename Dune::FieldVector<Scalar, 1>; - using BlockVector = typename Dune::BlockVector<VectorBlock>; - BlockVector y(numRows); - - // solve - const bool converged = ls.solve(M, y, bTmp); - - // copy back the result y into x - if(converged) - VectorConverter<ResidualVector>::retrieveValues(x, y); + assert(this->checkSizesOfSubMatrices(this->assembler().jacobian()) && "Matrix blocks have wrong sizes!"); - return converged; + return this->linearSolver().solve( + this->assembler().jacobian(), + deltaU, + this->assembler().residual() + ); } //! initialize the parameters by reading from the parameter tree diff --git a/test/multidomain/embedded/1d3d/root_soil_benchmark/main.cc b/test/multidomain/embedded/1d3d/root_soil_benchmark/main.cc index c08215bc5eca93e47296d327fcf4a8384f091968..e79b9e122eb0ca384c213d9d9ee3ce7728fb0fd7 100644 --- a/test/multidomain/embedded/1d3d/root_soil_benchmark/main.cc +++ b/test/multidomain/embedded/1d3d/root_soil_benchmark/main.cc @@ -25,9 +25,7 @@ #include <dumux/common/initialize.hh> #include <dumux/geometry/diameter.hh> -#include <dumux/linear/linearsolvertraits.hh> -#include <dumux/linear/linearalgebratraits.hh> -#include <dumux/linear/istlsolvers.hh> +#include <dumux/linear/seqsolverbackend.hh> #include <dumux/assembly/fvassembler.hh> #include <dumux/assembly/diffmethod.hh> diff --git a/test/multidomain/facet/tracer_tracer/main.cc b/test/multidomain/facet/tracer_tracer/main.cc index 054404035c3ea6fb35238b09c7d21b77d91e4c7a..e5c2edee8cc500f452ad7e6b17f9cd59c3af05ba 100644 --- a/test/multidomain/facet/tracer_tracer/main.cc +++ b/test/multidomain/facet/tracer_tracer/main.cc @@ -26,6 +26,7 @@ #include <dumux/discretization/elementsolution.hh> #include <dumux/discretization/evalgradients.hh> +#include <dumux/linear/seqsolverbackend.hh> #include <dumux/linear/istlsolvers.hh> #include <dumux/linear/linearsolvertraits.hh> #include <dumux/linear/linearalgebratraits.hh>