From f1d9d7a353021eb722e9a8342ef52ad03a5b03a0 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Thu, 14 Jan 2021 15:12:49 +0100 Subject: [PATCH] [linear] Factor out grid capabilities compatibilty layer into own header --- dumux/common/CMakeLists.txt | 1 + dumux/common/gridcapabilities.hh | 67 ++++++++++++++++++++++++++++++ dumux/linear/linearsolvertraits.hh | 41 ++---------------- 3 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 dumux/common/gridcapabilities.hh diff --git a/dumux/common/CMakeLists.txt b/dumux/common/CMakeLists.txt index 1dda198280..e26b4dfb2a 100644 --- a/dumux/common/CMakeLists.txt +++ b/dumux/common/CMakeLists.txt @@ -21,6 +21,7 @@ enumerate.hh exceptions.hh fixedlengthspline_.hh fvproblem.hh +gridcapabilities.hh indextraits.hh integrate.hh intersectionmapper.hh diff --git a/dumux/common/gridcapabilities.hh b/dumux/common/gridcapabilities.hh new file mode 100644 index 0000000000..77d4322882 --- /dev/null +++ b/dumux/common/gridcapabilities.hh @@ -0,0 +1,67 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see <http://www.gnu.org/licenses/>. * + *****************************************************************************/ +/*! + * \file + * \ingroup Common + * \brief dune-grid capabilities compatibility layer + */ +#ifndef DUMUX_COMMON_GRID_CAPABILITIES_HH +#define DUMUX_COMMON_GRID_CAPABILITIES_HH + +// TODO: The following is a temporary solution to make canCommunicate work. +// Once it is resolved upstream +// (https://gitlab.dune-project.org/core/dune-grid/issues/78), +// it should be guarded by a DUNE_VERSION macro and removed later. + +#if HAVE_UG +namespace Dune { +template<int dim> +class UGGrid; +} // end namespace Dumux +#endif // HAVE_UG + +namespace Dumux::Temp::Capabilities { + +template<class Grid, int codim> +struct canCommunicate +{ + static const bool v = false; +}; + +#if HAVE_UG +template<int dim, int codim> +struct canCommunicate<Dune::UGGrid<dim>, codim> +{ + static const bool v = true; +}; +#endif // HAVE_UG + +} // namespace Dumux::Temp::Capabilities +// end workaround + +namespace Dumux::Detail { + +template<class Grid, int dofCodim> +static constexpr bool canCommunicate = + Dune::Capabilities::canCommunicate<Grid, dofCodim>::v + || Dumux::Temp::Capabilities::canCommunicate<Grid, dofCodim>::v; + +} // namespace Dumux + +#endif diff --git a/dumux/linear/linearsolvertraits.hh b/dumux/linear/linearsolvertraits.hh index 9ed580bc38..7457a48023 100644 --- a/dumux/linear/linearsolvertraits.hh +++ b/dumux/linear/linearsolvertraits.hh @@ -31,36 +31,9 @@ #include <dune/istl/preconditioners.hh> #include <dune/grid/common/capabilities.hh> +#include <dumux/common/gridcapabilities.hh> #include <dumux/discretization/method.hh> -// TODO: The following is a temporary solution to make the parallel AMG work -// for UGGrid. Once it is resolved upstream -// (https://gitlab.dune-project.org/core/dune-grid/issues/78), -// it should be guarded by a DUNE_VERSION macro and removed later. - -#if HAVE_UG -#include <dune/grid/uggrid.hh> -#endif // HAVE_UG - -namespace Dumux::Temp::Capabilities { - -template<class Grid, int codim> -struct canCommunicate -{ - static const bool v = false; -}; - -#if HAVE_UG -template<int dim, int codim> -struct canCommunicate<Dune::UGGrid<dim>, codim> -{ - static const bool v = true; -}; -#endif // HAVE_UG - -} // namespace Dumux::Temp::Capabilities -// end workaround - namespace Dumux { //! The implementation is specialized for the different discretizations @@ -142,11 +115,7 @@ struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethod::box> using DofMapper = typename GridGeometry::VertexMapper; using Grid = typename GridGeometry::GridView::Traits::Grid; static constexpr int dofCodim = Grid::dimension; - - // TODO: see above for description of this workaround, remove second line if fixed upstream - static constexpr bool canCommunicate = - Dune::Capabilities::canCommunicate<Grid, dofCodim>::v - || Dumux::Temp::Capabilities::canCommunicate<Grid, dofCodim>::v; + static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>; template<class GridView> static bool isNonOverlapping(const GridView& gridView) @@ -161,11 +130,7 @@ struct LinearSolverTraitsImpl<GridGeometry, DiscretizationMethod::cctpfa> using DofMapper = typename GridGeometry::ElementMapper; using Grid = typename GridGeometry::GridView::Traits::Grid; static constexpr int dofCodim = 0; - - // TODO: see above for description of this workaround, remove second line if fixed upstream - static constexpr bool canCommunicate = - Dune::Capabilities::canCommunicate<Grid, dofCodim>::v - || Dumux::Temp::Capabilities::canCommunicate<Grid, dofCodim>::v; + static constexpr bool canCommunicate = Dumux::Detail::canCommunicate<Grid, dofCodim>; template<class GridView> static bool isNonOverlapping(const GridView& gridView) -- GitLab