Commit 4e294e78 authored by Timo Koch's avatar Timo Koch
Browse files

Merge branch 'feature/ff-pm-helpers' into 'master'

Feature/ff pm helpers

See merge request !2967
parents 9544b557 c9abc5f1
Pipeline #11540 passed with stages
in 0 seconds
......@@ -38,6 +38,9 @@
#include <dumux/flux/fickslaw_fwd.hh>
#include <dumux/flux/forchheimerslaw_fwd.hh>
#include <dumux/multidomain/boundary/freeflowporousmedium/traits.hh>
#include <dumux/multidomain/boundary/freeflowporousmedium/indexhelper.hh>
namespace Dumux {
/*!
......@@ -77,122 +80,6 @@ struct FreeFlowPorousMediumCouplingOptions
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs helps to check if the two sub models use the same fluidsystem.
* Specialization for the case of using an adapter only for the free-flow model.
* \tparam FFFS The free-flow fluidsystem
* \tparam PMFS The porous-medium flow fluidsystem
*/
template<class FFFS, class PMFS>
struct IsSameFluidSystem
{
static_assert(FFFS::numPhases == 1, "Only single-phase fluidsystems may be used for free flow.");
static constexpr bool value = std::is_same<typename FFFS::MultiPhaseFluidSystem, PMFS>::value;
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs helps to check if the two sub models use the same fluidsystem.
* \tparam FS The fluidsystem
*/
template<class FS>
struct IsSameFluidSystem<FS, FS>
{
static_assert(FS::numPhases == 1, "Only single-phase fluidsystems may be used for free flow.");
static constexpr bool value = std::is_same<FS, FS>::value; // always true
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs indicates that Fick's law is not used for diffusion.
* \tparam DiffLaw The diffusion law.
*/
template<class DiffLaw>
struct IsFicksLaw : public std::false_type {};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs indicates that Fick's law is used for diffusion.
* \tparam DiffLaw The diffusion law.
*/
template<class T>
struct IsFicksLaw<Dumux::FicksLaw<T>> : public std::true_type {};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model.
* \tparam stokesIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
* \tparam hasAdapter Specifies whether an adapter class for the fluidsystem is used.
*/
template<std::size_t stokesIdx, std::size_t porousMediumIndex, class FFFS, bool hasAdapter>
struct IndexHelper;
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model. Specialization for the case that no adapter is used.
* \tparam stokesIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
*/
template<std::size_t stokesIdx, std::size_t porousMediumIndex, class FFFS>
struct IndexHelper<stokesIdx, porousMediumIndex, FFFS, false>
{
/*!
* \brief No adapter is used, just return the input index.
*/
template<std::size_t i>
static constexpr auto couplingPhaseIdx(Dune::index_constant<i>, int coupledPhaseIdx = 0)
{ return coupledPhaseIdx; }
/*!
* \brief No adapter is used, just return the input index.
*/
template<std::size_t i>
static constexpr auto couplingCompIdx(Dune::index_constant<i>, int coupledCompdIdx)
{ return coupledCompdIdx; }
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model. Specialization for the case that a adapter is used.
* \tparam stokesIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
*/
template<std::size_t stokesIdx, std::size_t porousMediumIndex, class FFFS>
struct IndexHelper<stokesIdx, porousMediumIndex, FFFS, true>
{
/*!
* \brief The free-flow model always uses phase index 0.
*/
static constexpr int couplingPhaseIdx(Dune::index_constant<stokesIdx>, int coupledPhaseIdx = 0)
{ return 0; }
/*!
* \brief The phase index of the porous-medium-flow model is given by the adapter fluidsytem (i.e., user input).
*/
static constexpr auto couplingPhaseIdx(Dune::index_constant<porousMediumIndex>, int coupledPhaseIdx = 0)
{ return FFFS::multiphaseFluidsystemPhaseIdx; }
/*!
* \brief The free-flow model does not need any change of the component index.
*/
static constexpr auto couplingCompIdx(Dune::index_constant<stokesIdx>, int coupledCompdIdx)
{ return coupledCompdIdx; }
/*!
* \brief The component index of the porous-medium-flow model is mapped by the adapter fluidsytem.
*/
static constexpr auto couplingCompIdx(Dune::index_constant<porousMediumIndex>, int coupledCompdIdx)
{ return FFFS::compIdx(coupledCompdIdx); }
};
template<class MDTraits, class CouplingManager, bool enableEnergyBalance, bool isCompositional>
class FreeFlowPorousMediumCouplingConditionsImplementation;
......@@ -244,14 +131,14 @@ private:
using ForchheimersLaw = Dumux::ForchheimersLaw<SubDomainTypeTag<porousMediumIndex>>;
static constexpr bool adapterUsed = ModelTraits<porousMediumIndex>::numFluidPhases() > 1;
using IndexHelper = Dumux::IndexHelper<freeFlowMassIndex, porousMediumIndex, FluidSystem<freeFlowMassIndex>, adapterUsed>;
using IndexHelper = FreeFlowPorousMediumCoupling::IndexHelper<freeFlowMassIndex, porousMediumIndex, FluidSystem<freeFlowMassIndex>, adapterUsed>;
static constexpr int enableEnergyBalance = GetPropType<SubDomainTypeTag<freeFlowMassIndex>, Properties::ModelTraits>::enableEnergyBalance();
static_assert(GetPropType<SubDomainTypeTag<porousMediumIndex>, Properties::ModelTraits>::enableEnergyBalance() == enableEnergyBalance,
"All submodels must both be either isothermal or non-isothermal");
static_assert(IsSameFluidSystem<FluidSystem<freeFlowMassIndex>,
FluidSystem<porousMediumIndex>>::value,
static_assert(FreeFlowPorousMediumCoupling::IsSameFluidSystem<FluidSystem<freeFlowMassIndex>,
FluidSystem<porousMediumIndex>>::value,
"All submodels must use the same fluid system");
using DiffusionCoefficientAveragingType = typename FreeFlowPorousMediumCouplingOptions::DiffusionCoefficientAveragingType;
......@@ -268,8 +155,8 @@ public:
* \brief Returns the corresponding component index needed for coupling.
*/
template<std::size_t i>
static constexpr auto couplingCompIdx(Dune::index_constant<i> id, int coupledCompdIdx)
{ return IndexHelper::couplingCompIdx(id, coupledCompdIdx); }
static constexpr auto couplingCompIdx(Dune::index_constant<i> id, int coupledCompIdx)
{ return IndexHelper::couplingCompIdx(id, coupledCompIdx); }
/*!
* \brief Returns the intrinsic permeability of the coupled Darcy element.
......
// -*- 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 FreeFlowPorousMediumCoupling
* \brief Index helpers for the free-flow/porous-medium-flow coupling.
*/
#ifndef DUMUX_MD_FREEFLOW_POROUSMEDIUM_INDEX_HELPER_HH
#define DUMUX_MD_FREEFLOW_POROUSMEDIUM_INDEX_HELPER_HH
#include <dune/common/indices.hh>
namespace Dumux::FreeFlowPorousMediumCoupling {
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model.
* \tparam freeFlowIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
* \tparam hasAdapter Specifies whether an adapter class for the fluidsystem is used.
*/
template<std::size_t freeFlowIdx, std::size_t porousMediumIndex, class FFFS, bool hasAdapter>
struct IndexHelper;
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model. Specialization for the case that no adapter is used.
* \tparam freeFlowIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
*/
template<std::size_t freeFlowIdx, std::size_t porousMediumIndex, class FFFS>
struct IndexHelper<freeFlowIdx, porousMediumIndex, FFFS, false>
{
/*!
* \brief No adapter is used, just return the input index.
*/
template<std::size_t i>
static constexpr auto couplingPhaseIdx(Dune::index_constant<i>, int coupledPhaseIdx = 0)
{ return coupledPhaseIdx; }
/*!
* \brief No adapter is used, just return the input index.
*/
template<std::size_t i>
static constexpr auto couplingCompIdx(Dune::index_constant<i>, int coupledCompdIdx)
{ return coupledCompdIdx; }
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief Helper struct to choose the correct index for phases and components. This is need if the porous-medium-flow model
features more fluid phases than the free-flow model. Specialization for the case that a adapter is used.
* \tparam freeFlowIdx The domain index of the free-flow model.
* \tparam porousMediumIndex The domain index of the porous-medium-flow model.
* \tparam FFFS The free-flow fluidsystem.
*/
template<std::size_t freeFlowIdx, std::size_t porousMediumIndex, class FFFS>
struct IndexHelper<freeFlowIdx, porousMediumIndex, FFFS, true>
{
/*!
* \brief The free-flow model always uses phase index 0.
*/
static constexpr int couplingPhaseIdx(Dune::index_constant<freeFlowIdx>, int coupledPhaseIdx = 0)
{ return 0; }
/*!
* \brief The phase index of the porous-medium-flow model is given by the adapter fluidsystem (i.e., user input).
*/
static constexpr auto couplingPhaseIdx(Dune::index_constant<porousMediumIndex>, int coupledPhaseIdx = 0)
{ return FFFS::multiphaseFluidsystemPhaseIdx; }
/*!
* \brief The free-flow model does not need any change of the component index.
*/
static constexpr auto couplingCompIdx(Dune::index_constant<freeFlowIdx>, int coupledCompIdx)
{ return coupledCompIdx; }
/*!
* \brief The component index of the porous-medium-flow model is mapped by the adapter fluidsystem.
*/
static constexpr auto couplingCompIdx(Dune::index_constant<porousMediumIndex>, int coupledCompIdx)
{ return FFFS::compIdx(coupledCompIdx); }
};
} // end namespace Dumux::FreeFlowPorousMediumCoupling
#endif
// -*- 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 FreeFlowPorousMediumCoupling
* \brief Traits for the free-flow/porous-medium-flow coupling.
*/
#ifndef DUMUX_MD_FREEFLOW_POROUSMEDIUM_TRAITS_HH
#define DUMUX_MD_FREEFLOW_POROUSMEDIUM_TRAITS_HH
#include <type_traits>
#include <dumux/flux/fickslaw_fwd.hh>
namespace Dumux::FreeFlowPorousMediumCoupling {
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs helps to check if the two sub models use the same fluidsystem.
* Specialization for the case of using an adapter only for the free-flow model.
* \tparam FFFS The free-flow fluidsystem
* \tparam PMFS The porous-medium flow fluidsystem
*/
template<class FFFS, class PMFS>
struct IsSameFluidSystem
{
static_assert(FFFS::numPhases == 1, "Only single-phase fluidsystems may be used for free flow.");
static constexpr bool value = std::is_same<typename FFFS::MultiPhaseFluidSystem, PMFS>::value;
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs helps to check if the two sub models use the same fluidsystem.
* \tparam FS The fluidsystem
*/
template<class FS>
struct IsSameFluidSystem<FS, FS>
{
static_assert(FS::numPhases == 1, "Only single-phase fluidsystems may be used for free flow.");
static constexpr bool value = std::is_same<FS, FS>::value; // always true
};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs indicates that Fick's law is not used for diffusion.
* \tparam DiffLaw The diffusion law.
*/
template<class DiffLaw>
struct IsFicksLaw : public std::false_type {};
/*!
* \ingroup FreeFlowPorousMediumCoupling
* \brief This structs indicates that Fick's law is used for diffusion.
* \tparam DiffLaw The diffusion law.
*/
template<class T>
struct IsFicksLaw<Dumux::FicksLaw<T>> : public std::true_type {};
} // end namespace Dumux::FreeFlowPorousMediumCoupling
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment