13#ifndef DUMUX_MD_FREEFLOW_POROUSMEDIUM_COUPLINGCONDITIONS_CVFE_CVFE_HH
14#define DUMUX_MD_FREEFLOW_POROUSMEDIUM_COUPLINGCONDITIONS_CVFE_CVFE_HH
19#include <dune/common/exceptions.hh>
20#include <dune/common/fvector.hh>
24#include <dumux/common/concepts/variables_.hh>
32template<
class MDTraits,
class CouplingManager,
bool enableEnergyBalance,
bool isCompositional>
43template<
class MDTraits,
class CouplingManager>
55template<
class MDTraits,
class CouplingManager>
58 using Scalar =
typename MDTraits::Scalar;
60 template<std::
size_t id>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
62 template<std::
size_t id>
using ElementDiscretization =
typename GridDiscretization<id>::LocalView;
67 template<std::
size_t id>
using GlobalPosition =
typename GridDiscretization<id>::GridView::template Codim<0>::Geometry::GlobalCoordinate;
75 static constexpr bool adapterUsed = ModelTraits<porousMediumIndex>::numFluidPhases() > 1;
78 static constexpr int enableEnergyBalance = ModelTraits<freeFlowMassIndex>::enableEnergyBalance();
79 static_assert(ModelTraits<porousMediumIndex>::enableEnergyBalance() == enableEnergyBalance,
80 "All submodels must both be either isothermal or non-isothermal");
83 FluidSystem<porousMediumIndex>>::value,
84 "All submodels must use the same fluid system");
90 template<std::
size_t i>
91 static constexpr auto couplingPhaseIdx(Dune::index_constant<i>
id,
int coupledPhaseIdx = 0)
92 {
return IndexHelper::couplingPhaseIdx(
id, coupledPhaseIdx); }
97 template<std::
size_t i>
98 static constexpr auto couplingCompIdx(Dune::index_constant<i>
id,
int coupledCompIdx)
99 {
return IndexHelper::couplingCompIdx(
id, coupledCompIdx); }
105 template<
class IpData,
class Context>
106 static auto darcyPermeability(
const ElementDiscretization<freeFlowMomentumIndex>& elemDisc,
107 const IpData& ipData,
108 const Context& context)
110 return interpolate_(context, ipData.global(), [](
const auto& vars) { return vars.permeability(); });
118 template<
class Context,
class IpData>
119 static auto darcyVelocity(
const Context& context,
const IpData& ipData)
121 static_assert(!Concept::FVGridVariables<GridVariables<porousMediumIndex>>,
122 "The Darcy velocity requires the porous-medium model to use the general grid variables");
125 const auto& elemDisc = context.elemDisc;
129 typename Concept::GridVariablesCache_t<GridVariables<porousMediumIndex>>::InterpolationPointData ipCache;
130 ipCache.update(context.problem, elemDisc.element(), elemDisc, context, ipData);
132 const auto mobilityTensor = [&](
const auto& pmElemDisc,
const auto& pmElemVars,
const auto& pmIpData)
134 return interpolate_(context, pmIpData.global(), [&](
const auto& vars)
136 auto tensor = vars.permeability();
137 tensor /= vars.viscosity(pmPhaseIdx);
142 return AdvectionType<porousMediumIndex>::fluxTerm(context.problem, elemDisc.element(), elemDisc,
143 context, pmPhaseIdx, ipData, ipCache, mobilityTensor);
149 template<
class ElementDiscretization,
class ContextOrElementVars,
class IpData>
150 static Scalar
density(
const ElementDiscretization& elemDisc,
151 const ContextOrElementVars& vars,
152 const IpData& ipData)
156 const auto& localBasis = elemDisc.feLocalBasis();
158 std::vector<Dune::FieldVector<Scalar, 1>> shapeValues;
159 localBasis.evaluateFunction(ipData.local(), shapeValues);
163 for (
const auto& localDof :
localDofs(elemDisc))
164 density += vars[localDof].density(pmPhaseIdx)*shapeValues[localDof.index()][0];
172 template<
class ElementDiscretization,
class ContextOrElementVars,
class IpData>
173 static Scalar
pressure(
const ElementDiscretization& elemDisc,
174 const ContextOrElementVars& vars,
175 const IpData& ipData)
179 const auto& localBasis = elemDisc.feLocalBasis();
181 std::vector<Dune::FieldVector<Scalar, 1>> shapeValues;
182 localBasis.evaluateFunction(ipData.local(), shapeValues);
186 for (
const auto& localDof :
localDofs(elemDisc))
187 pressure += vars[localDof].pressure(pmPhaseIdx)*shapeValues[localDof.index()][0];
195 static Scalar
advectiveFlux(
const Scalar insideQuantity,
const Scalar outsideQuantity,
const Scalar volumeFlow,
bool insideIsUpstream)
196 {
return (insideIsUpstream ? insideQuantity : outsideQuantity) * volumeFlow; }
200 template<
class Context,
class Quantity>
201 static auto interpolate_(
const Context& context,
202 const GlobalPosition<porousMediumIndex>& globalPos,
203 const Quantity& quantity)
205 const auto& pmElemDisc = context.elemDisc;
209 const auto pmLocalPos = pmElemDisc.elementGeometry().local(globalPos);
211 std::vector<Dune::FieldVector<Scalar, 1>> shapeValues;
212 pmElemDisc.feLocalBasis().evaluateFunction(pmLocalPos, shapeValues);
214 std::decay_t<
decltype(quantity(context.vars(*
localDofs(pmElemDisc).begin())))> value(0.0);
215 for (
const auto& localDof :
localDofs(pmElemDisc))
217 auto localValue = quantity(context.vars(localDof));
218 localValue *= shapeValues[localDof.index()][0];
229template<
class MDTraits,
class CouplingManager,
bool enableEnergyBalance>
235 template<std::
size_t id>
236 using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
239 "Darcy Model must not be compositional");
241 static_assert(!enableEnergyBalance,
"Non-isothermal coupling is not implemented for control-volume finite element schemes");
244 using ParentType::ParentType;
The interface of the coupling manager for multi domain problems.
Definition multidomain/couplingmanager.hh:37
A base class which provides some common methods used for Stokes-Darcy coupling.
Definition couplingconditions_cvfe_cvfe.hh:56
static constexpr auto freeFlowMassIndex
Definition couplingconditions_cvfe_cvfe.hh:70
static constexpr auto freeFlowMomentumIndex
Definition couplingconditions_cvfe_cvfe.hh:69
static constexpr auto couplingCompIdx(Dune::index_constant< i > id, int coupledCompIdx)
Returns the corresponding component index needed for coupling.
Definition couplingconditions_cvfe_cvfe.hh:97
static constexpr auto porousMediumIndex
Definition couplingconditions_cvfe_cvfe.hh:71
static Scalar density(const ElementDiscretization &elemDisc, const ContextOrElementVars &vars, const IpData &ipData)
Returns the porous medium density at a given interpolation point.
Definition couplingconditions_cvfe_cvfe.hh:149
static Scalar advectiveFlux(const Scalar insideQuantity, const Scalar outsideQuantity, const Scalar volumeFlow, bool insideIsUpstream)
Evaluate an advective flux across the interface with full upwinding.
Definition couplingconditions_cvfe_cvfe.hh:194
static constexpr auto couplingPhaseIdx(Dune::index_constant< i > id, int coupledPhaseIdx=0)
Returns the corresponding phase index needed for coupling.
Definition couplingconditions_cvfe_cvfe.hh:90
static Scalar pressure(const ElementDiscretization &elemDisc, const ContextOrElementVars &vars, const IpData &ipData)
Returns the porous medium pressure at a given interpolation point.
Definition couplingconditions_cvfe_cvfe.hh:172
static auto darcyVelocity(const Context &context, const IpData &ipData)
Returns the Darcy velocity at an interpolation point of the coupled Darcy element.
Definition couplingconditions_cvfe_cvfe.hh:118
static auto darcyPermeability(const ElementDiscretization< freeFlowMomentumIndex > &elemDisc, const IpData &ipData, const Context &context)
Returns the intrinsic permeability of the coupled Darcy element at an interpolation point.
Definition couplingconditions_cvfe_cvfe.hh:105
Definition couplingconditions_cvfe_cvfe.hh:33
Defines all properties used in Dumux.
FFPMCouplingConditionsCvfeImpl< MDTraits, CouplingManager, GetPropType< typename MDTraits::template SubDomain< 0 >::TypeTag, Properties::ModelTraits >::enableEnergyBalance(),(GetPropType< typename MDTraits::template SubDomain< 0 >::TypeTag, Properties::ModelTraits >::numFluidComponents() > 1) > FFPMCouplingConditionsCvfe
Coupling conditions for a Darcy model and a (Navier-)Stokes model, both discretized with control-volu...
Definition couplingconditions_cvfe_cvfe.hh:44
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
Index helpers for the free-flow/porous-medium-flow coupling.
Class representing dofs on elements for control-volume finite element schemes.
Define some often used mathematical functions.
Traits for the free-flow/porous-medium-flow coupling.
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50
Helper struct to choose the correct index for phases and components. This is need if the porous-mediu...
Definition indexhelper.hh:30
This structs helps to check if the two sub models use the same fluidsystem. Specialization for the ca...
Definition multidomain/boundary/freeflowporousmedium/traits.hh:30