25#ifndef DUMUX_MULTIDOMAIN_DARCYDARCY_BOUNDARY_COUPLINGMANAGER_HH
26#define DUMUX_MULTIDOMAIN_DARCYDARCY_BOUNDARY_COUPLINGMANAGER_HH
31#include <dune/common/indices.hh>
32#include <dune/common/exceptions.hh>
49template<
class MDTraits>
55 using Scalar =
typename MDTraits::Scalar;
56 using SolutionVector =
typename MDTraits::SolutionVector;
58 template<std::
size_t i>
using SubDomainTypeTag =
typename MDTraits::template SubDomain<i>::TypeTag;
64 template<std::
size_t i>
using GridGeometry =
typename MDTraits::template SubDomain<i>::GridGeometry;
65 template<std::
size_t i>
using FVElementGeometry =
typename GridGeometry<i>::LocalView;
66 template<std::
size_t i>
using SubControlVolumeFace =
typename GridGeometry<i>::SubControlVolumeFace;
67 template<std::
size_t i>
using SubControlVolume =
typename GridGeometry<i>::SubControlVolume;
68 template<std::
size_t i>
using GridView =
typename GridGeometry<i>::GridView;
69 template<std::
size_t i>
using Element =
typename GridView<i>::template Codim<0>::Entity;
71 template<std::
size_t i>
72 static constexpr auto domainIdx()
73 {
return typename MDTraits::template SubDomain<i>::Index{}; }
75 template<std::
size_t i>
76 static constexpr bool isCCTpfa()
79 using CouplingStencil = std::vector<std::size_t>;
91 void init(std::shared_ptr<Problem<domainIdx<0>()>> problem0,
92 std::shared_ptr<Problem<domainIdx<1>()>> problem1,
93 const SolutionVector&
curSol)
95 static_assert(isCCTpfa<0>() && isCCTpfa<1>(),
"Only cctpfa implemented!");
99 couplingMapper_.update(*
this);
117 template<std::
size_t i, std::
size_t j>
119 const Element<i>& element,
120 Dune::index_constant<j> domainJ)
const
122 static_assert(i != j,
"A domain cannot be coupled to itself!");
123 const auto eIdx = this->
problem(domainI).gridGeometry().elementMapper().index(element);
124 return couplingMapper_.couplingStencil(domainI, eIdx, domainJ);
134 template<std::
size_t i>
136 const SubControlVolumeFace<i>& scvf)
const
138 return couplingMapper_.isCoupled(domainI, scvf);
157 template<std::
size_t i>
159 const Element<i>& element,
160 const FVElementGeometry<i>& fvGeometry,
161 const ElementVolumeVariables<i>& elemVolVars,
162 const SubControlVolumeFace<i>& scvf,
163 int phaseIdx = 0)
const
166 static const bool enableGravity = getParamFromGroup<bool>(this->
problem(domainI).paramGroup(),
"Problem.EnableGravity");
167 constexpr auto otherDomainIdx = domainIdx<1-i>();
169 const auto& outsideElement = this->
problem(otherDomainIdx).gridGeometry().element(couplingMapper_.outsideElementIndex(domainI, scvf));
170 auto fvGeometryOutside =
localView(this->
problem(otherDomainIdx).gridGeometry());
171 fvGeometryOutside.bindElement(outsideElement);
173 const auto& flipScvf = fvGeometryOutside.scvf(couplingMapper_.flipScvfIndex(domainI, scvf));
174 const auto& outsideScv = fvGeometryOutside.scv(flipScvf.insideScvIdx());
175 const auto outsideVolVars =
volVars(otherDomainIdx, outsideElement, outsideScv);
177 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
178 const auto& insideVolVars = elemVolVars[insideScv];
180 using Extrusion =
typename GridGeometry<i>::Extrusion;
182 const auto tj =
computeTpfaTransmissibility(flipScvf, outsideScv, outsideVolVars.permeability(), outsideVolVars.extrusionFactor());
185 tij = Extrusion::area(scvf)*(ti * tj)/(ti + tj);
190 const auto rho = (insideVolVars.density(phaseIdx) + outsideVolVars.density(phaseIdx))*0.5;
191 const auto& g = this->
problem(domainI).spatialParams().gravity(scvf.ipGlobal());
194 const auto alpha_inside =
vtmv(scvf.unitOuterNormal(), insideVolVars.permeability(), g)*insideVolVars.extrusionFactor();
195 const auto alpha_outside =
vtmv(scvf.unitOuterNormal(), outsideVolVars.permeability(), g)*outsideVolVars.extrusionFactor();
198 const auto pInside = insideVolVars.pressure(0);
199 const auto pOutside = outsideVolVars.pressure(0);
201 flux = tij*(pInside - pOutside) + rho*Extrusion::area(scvf)*alpha_inside - rho*tij/tj*(alpha_inside - alpha_outside);
207 const auto pInside = insideVolVars.pressure(phaseIdx);
208 const auto pOutside = outsideVolVars.pressure(phaseIdx);
211 flux = tij*(pInside - pOutside);
215 static const Scalar upwindWeight = getParam<Scalar>(
"Flux.UpwindWeight");
216 auto upwindTerm = [phaseIdx](
const auto&
volVars){
return volVars.density(phaseIdx)*
volVars.mobility(phaseIdx); };
217 if (std::signbit(flux))
218 flux *= (upwindWeight*upwindTerm(outsideVolVars)
219 + (1.0 - upwindWeight)*upwindTerm(insideVolVars));
221 flux *= (upwindWeight*upwindTerm(insideVolVars)
222 + (1.0 - upwindWeight)*upwindTerm(outsideVolVars));
225 flux /= Extrusion::area(scvf)*insideVolVars.extrusionFactor();
230 template<std::
size_t i>
231 VolumeVariables<i>
volVars(Dune::index_constant<i> domainI,
232 const Element<i>& element,
233 const SubControlVolume<i>& scv)
const
Define some often used mathematical functions.
A helper to deduce a vector with the same size as numbers of equations.
Element solution classes and factory functions.
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:118
Tensor::field_type computeTpfaTransmissibility(const SubControlVolumeFace &scvf, const SubControlVolume &scv, const Tensor &T, typename SubControlVolume::Traits::Scalar extrusionFactor)
Free function to evaluate the Tpfa transmissibility associated with the flux (in the form of flux = T...
Definition: tpfa/computetransmissibility.hh:47
Dune::DenseMatrix< MAT >::value_type vtmv(const Dune::DenseVector< V1 > &v1, const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V2 > &v2)
Evaluates the scalar product of a vector v2, projected by a matrix M, with a vector v1.
Definition: math.hh:863
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:46
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
A vector of primary variables.
Definition: common/properties.hh:49
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:57
The type for a global container for the volume variables.
Definition: common/properties.hh:105
Traits extracting the public Extrusion type from T Defaults to NoExtrusion if no such type is found.
Definition: extrusion.hh:166
Coupling manager for equal-dimension boundary coupling of darcy models.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:52
std::unordered_map< std::size_t, CouplingStencil > CouplingStencils
export stencil types
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:84
Scalar advectiveFluxCoupling(Dune::index_constant< i > domainI, const Element< i > &element, const FVElementGeometry< i > &fvGeometry, const ElementVolumeVariables< i > &elemVolVars, const SubControlVolumeFace< i > &scvf, int phaseIdx=0) const
Evaluate the boundary conditions for a coupled Neumann boundary segment.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:158
const CouplingStencil & couplingStencil(Dune::index_constant< i > domainI, const Element< i > &element, Dune::index_constant< j > domainJ) const
Methods to be accessed by the assembly.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:118
VolumeVariables< i > volVars(Dune::index_constant< i > domainI, const Element< i > &element, const SubControlVolume< i > &scv) const
Return the volume variables of domain i for a given element and scv.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:231
void init(std::shared_ptr< Problem< domainIdx< 0 >()> > problem0, std::shared_ptr< Problem< domainIdx< 1 >()> > problem1, const SolutionVector &curSol)
Methods to be accessed by main.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:91
bool isCoupled(Dune::index_constant< i > domainI, const SubControlVolumeFace< i > &scvf) const
If the boundary entity is on a coupling boundary.
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:135
MDTraits MultiDomainTraits
export traits
Definition: multidomain/boundary/darcydarcy/couplingmanager.hh:82
the default mapper for conforming equal dimension boundary coupling between two domains (box or cc)
Definition: boundary/darcydarcy/couplingmapper.hh:49
Definition: multidomain/couplingmanager.hh:46
void setSubProblems(const std::tuple< std::shared_ptr< SubProblems >... > &problems)
set the pointers to the sub problems
Definition: multidomain/couplingmanager.hh:247
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:264
SolutionVector & curSol()
the solution vector of the coupled problem
Definition: multidomain/couplingmanager.hh:278
void updateSolution(const SolutionVector &curSol)
Updates the entire solution vector, e.g. before assembly or after grid adaption.
Definition: multidomain/couplingmanager.hh:186
Declares all properties used in Dumux.
Free functions to evaluate the transmissibilities associated with flux evaluations across sub-control...
The interface of the coupling manager for multi domain problems.