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); }
107 template<
class IpData,
class Context>
108 static auto darcyPermeability(
const ElementDiscretization<freeFlowMomentumIndex>& elemDisc,
109 const IpData& ipData,
110 const Context& context)
112 const auto& pmElemDisc = context.elemDisc;
113 return context.vars(pmElemDisc.scv(closestBoundaryScvIdx_(pmElemDisc, ipData.global()))).permeability();
122 template<
class Context,
class IpData>
123 static auto darcyVelocity(
const Context& context,
const IpData& ipData)
125 static_assert(!Concept::FVGridVariables<GridVariables<porousMediumIndex>>,
126 "The Darcy velocity requires the porous-medium model to use the general grid variables");
129 const auto& elemDisc = context.elemDisc;
133 typename Concept::GridVariablesCache_t<GridVariables<porousMediumIndex>>::InterpolationPointData ipCache;
134 ipCache.update(context.problem, elemDisc.element(), elemDisc, context, ipData);
136 const auto mobilityTensor = [&](
const auto& pmElemDisc,
const auto& pmElemVars,
const auto& pmIpData)
138 const auto vars = pmElemVars[pmElemDisc.scv(closestBoundaryScvIdx_(pmElemDisc, pmIpData.global()))];
139 auto tensor = vars.permeability();
140 tensor /= vars.viscosity(pmPhaseIdx);
144 return AdvectionType<porousMediumIndex>::fluxTerm(context.problem, elemDisc.element(), elemDisc,
145 context, pmPhaseIdx, ipData, ipCache, mobilityTensor);
151 template<
class ElementDiscretization,
class ContextOrElementVars,
class IpData>
152 static Scalar
density(
const ElementDiscretization& elemDisc,
153 const ContextOrElementVars& vars,
154 const IpData& ipData)
158 const auto& localBasis = elemDisc.feLocalBasis();
160 std::vector<Dune::FieldVector<Scalar, 1>> shapeValues;
161 localBasis.evaluateFunction(ipData.local(), shapeValues);
165 for (
const auto& localDof :
localDofs(elemDisc))
166 density += vars[localDof].density(pmPhaseIdx)*shapeValues[localDof.index()][0];
174 template<
class ElementDiscretization,
class ContextOrElementVars,
class IpData>
175 static Scalar
pressure(
const ElementDiscretization& elemDisc,
176 const ContextOrElementVars& vars,
177 const IpData& ipData)
181 const auto& localBasis = elemDisc.feLocalBasis();
183 std::vector<Dune::FieldVector<Scalar, 1>> shapeValues;
184 localBasis.evaluateFunction(ipData.local(), shapeValues);
188 for (
const auto& localDof :
localDofs(elemDisc))
189 pressure += vars[localDof].pressure(pmPhaseIdx)*shapeValues[localDof.index()][0];
197 static Scalar
advectiveFlux(
const Scalar insideQuantity,
const Scalar outsideQuantity,
const Scalar volumeFlow,
bool insideIsUpstream)
198 {
return (insideIsUpstream ? insideQuantity : outsideQuantity) * volumeFlow; }
202 template<
class PMElementDiscretization>
203 static std::size_t closestBoundaryScvIdx_(
const PMElementDiscretization& elemDisc,
204 const GlobalPosition<porousMediumIndex>& pos)
206 Scalar minDistance = 0.0;
207 std::size_t closestScvfIdx = 0;
208 bool foundClosestScvf =
false;
210 for (
const auto& scvf : scvfs(elemDisc))
212 if (!scvf.boundary())
215 const auto distance = (scvf.ipGlobal() - pos).two_norm();
216 if (!foundClosestScvf ||
distance < minDistance)
219 closestScvfIdx = scvf.index();
220 foundClosestScvf =
true;
224 if (!foundClosestScvf)
225 DUNE_THROW(Dune::InvalidStateException,
"Expected at least one boundary SCVF in porous-medium element discretization");
227 return elemDisc.scvf(closestScvfIdx).insideScvIdx();
235template<
class MDTraits,
class CouplingManager,
bool enableEnergyBalance>
241 template<std::
size_t id>
242 using SubDomainTypeTag =
typename MDTraits::template SubDomain<id>::TypeTag;
245 "Darcy Model must not be compositional");
247 static_assert(!enableEnergyBalance,
"Non-isothermal coupling is not implemented for control-volume finite element schemes");
250 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:151
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:196
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:174
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:122
static auto darcyPermeability(const ElementDiscretization< freeFlowMomentumIndex > &elemDisc, const IpData &ipData, const Context &context)
Returns the intrinsic permeability of the coupled Darcy element.
Definition couplingconditions_cvfe_cvfe.hh:107
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
static ctype distance(const Dune::FieldVector< ctype, dimWorld > &a, const Dune::FieldVector< ctype, dimWorld > &b)
Compute the shortest distance between two points.
Definition distance.hh:302
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