// 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: #ifndef DUNE_AMGCONSTRUCTION_HH #define DUNE_AMGCONSTRUCTION_HH #include #include #include #include #include "pinfo.hh" namespace Dune { namespace Amg { /** * @addtogroup ISTL_PAAMG * * @{ */ /** @file * @author Markus Blatt * @brief Helper classes for the construction of classes without * empty constructor. */ /** * @brief Traits class for generically constructing non default * constructable types. * * Needed because BCRSMatrix and Vector do a deep copy which is * too expensive. */ template struct ConstructionTraits { /** * @brief A type holding all the arguments needed to call the * constructor. */ typedef const void* Arguments; /** * @brief Construct an object with the specified arguments. * * In the default implementation the copy constructor is called. * @param args The arguments for the construction. */ static inline std::shared_ptr construct(Arguments& /*args*/) { return std::make_shared(); } }; template struct ConstructionTraits > { typedef const int Arguments; static inline std::shared_ptr> construct(Arguments& n) { return std::make_shared>(n); } }; template struct ParallelOperatorArgs { ParallelOperatorArgs(std::shared_ptr matrix, const C& comm) : matrix_(matrix), comm_(comm) {} std::shared_ptr matrix_; const C& comm_; }; #if HAVE_MPI struct OwnerOverlapCopyCommunicationArgs { OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat) : comm_(comm), cat_(cat) {} MPI_Comm comm_; SolverCategory::Category cat_; }; #endif struct SequentialCommunicationArgs { SequentialCommunicationArgs(Communication comm, [[maybe_unused]] int cat) : comm_(comm) {} Communication comm_; }; } // end Amg namspace // forward declaration template class OverlappingSchwarzOperator; template class NonoverlappingSchwarzOperator; namespace Amg { template struct ConstructionTraits > { typedef ParallelOperatorArgs Arguments; static inline std::shared_ptr> construct(const Arguments& args) { return std::make_shared> (args.matrix_, args.comm_); } }; template struct ConstructionTraits > { typedef ParallelOperatorArgs Arguments; static inline std::shared_ptr> construct(const Arguments& args) { return std::make_shared> (args.matrix_, args.comm_); } }; template struct MatrixAdapterArgs { MatrixAdapterArgs(std::shared_ptr matrix, const SequentialInformation) : matrix_(matrix) {} std::shared_ptr matrix_; }; template struct ConstructionTraits > { typedef const MatrixAdapterArgs Arguments; static inline std::shared_ptr> construct(Arguments& args) { return std::make_shared>(args.matrix_); } }; template<> struct ConstructionTraits { typedef const SequentialCommunicationArgs Arguments; static inline std::shared_ptr construct(Arguments& args) { return std::make_shared(args.comm_); } }; #if HAVE_MPI template struct ConstructionTraits > { typedef const OwnerOverlapCopyCommunicationArgs Arguments; static inline std::shared_ptr> construct(Arguments& args) { return std::make_shared>(args.comm_, args.cat_); } }; #endif /** @} */ } // namespace Amg } // namespace Dune #endif