25#ifndef DUMUX_2P_BOX_MATERIAL_INTERFACES_HH
26#define DUMUX_2P_BOX_MATERIAL_INTERFACES_HH
28#include <dune/common/exceptions.hh>
45template<
class Gr
idGeometry,
class PcKrSw>
48 using SubControlVolume =
typename GridGeometry::SubControlVolume;
51 template<
class SpatialParams,
class SolutionVector>
53 const SpatialParams& spatialParams,
54 const SolutionVector& x)
56 update(gridGeometry, spatialParams, x);
66 template<
class SpatialParams,
class SolutionVector>
67 void update(
const GridGeometry& gridGeometry,
68 const SpatialParams& spatialParams,
69 const SolutionVector& x)
73 DUNE_THROW(Dune::InvalidStateException,
"Determination of the interface material parameters with "
74 "this class only makes sense when using the box method!");
76 isOnMaterialInterface_.resize(gridGeometry.numDofs(),
false);
77 pcSwAtDof_.resize(gridGeometry.numDofs(),
nullptr);
78 auto fvGeometry =
localView(gridGeometry);
79 for (
const auto& element : elements(gridGeometry.gridView()))
82 fvGeometry.bind(element);
84 for (
const auto& scv : scvs(fvGeometry))
86 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
87 const auto& pcKrSw = fluidMatrixInteraction.pcSwCurve();
90 static_assert(std::is_lvalue_reference<
typename std::decay_t<
decltype(fluidMatrixInteraction)>::PcKrSwType>::value,
91 "In order to use the box-interface solver please provide access "
92 "to the material law parameters via returning (const) references");
95 if (!pcSwAtDof_[scv.dofIndex()])
96 pcSwAtDof_[scv.dofIndex()] = &pcKrSw;
99 else if (pcKrSw.endPointPc() < pcSwAtDof_[scv.dofIndex()]->endPointPc())
101 pcSwAtDof_[scv.dofIndex()] = &pcKrSw;
102 isOnMaterialInterface_[scv.dofIndex()] =
true;
106 else if ( !(pcKrSw == *(pcSwAtDof_[scv.dofIndex()])) )
107 isOnMaterialInterface_[scv.dofIndex()] =
true;
114 {
return isOnMaterialInterface_[scv.dofIndex()]; }
118 {
return *(pcSwAtDof_[scv.dofIndex()]); }
121 std::vector<bool> isOnMaterialInterface_;
122 std::vector<const PcKrSw*> pcSwAtDof_;
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==DiscretizationMethods::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
PcKrSw(T &&) -> PcKrSw< T >
Deduction guide for the PcKrSw class. Makes sure that PcKrSw stores a copy of T if the constructor is...
constexpr Box box
Definition: method.hh:139
Class that determines the material with the lowest capillary pressure (under fully water-saturated co...
Definition: boxmaterialinterfaces.hh:47
void update(const GridGeometry &gridGeometry, const SpatialParams &spatialParams, const SolutionVector &x)
Updates the scv -> dofparameter map.
Definition: boxmaterialinterfaces.hh:67
bool isOnMaterialInterface(const SubControlVolume &scv) const
Returns if this scv is connected to a material interface.
Definition: boxmaterialinterfaces.hh:113
BoxMaterialInterfaces(const GridGeometry &gridGeometry, const SpatialParams &spatialParams, const SolutionVector &x)
Definition: boxmaterialinterfaces.hh:52
const PcKrSw & pcSwAtDof(const SubControlVolume &scv) const
Returns the material parameters associated with the dof.
Definition: boxmaterialinterfaces.hh:117
The local element solution class for the box method.