3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
boxmaterialinterfaces.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_2P_BOX_MATERIAL_INTERFACES_HH
26#define DUMUX_2P_BOX_MATERIAL_INTERFACES_HH
27
28#include <dune/common/exceptions.hh>
29
32
33namespace Dumux {
34
45template<class GridGeometry, class PcKrSw>
47{
48 using SubControlVolume = typename GridGeometry::SubControlVolume;
49
50public:
51 template<class SpatialParams, class SolutionVector>
52 BoxMaterialInterfaces(const GridGeometry& gridGeometry,
53 const SpatialParams& spatialParams,
54 const SolutionVector& x)
55 {
56 update(gridGeometry, spatialParams, x);
57 }
58
66 template<class SpatialParams, class SolutionVector>
67 void update(const GridGeometry& gridGeometry,
68 const SpatialParams& spatialParams,
69 const SolutionVector& x)
70 {
71 // make sure this is only called for geometries of the box method!
72 if (GridGeometry::discMethod != DiscretizationMethods::box)
73 DUNE_THROW(Dune::InvalidStateException, "Determination of the interface material parameters with "
74 "this class only makes sense when using the box method!");
75
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()))
80 {
81 const auto elemSol = elementSolution(element, x, gridGeometry);
82 fvGeometry.bind(element);
83
84 for (const auto& scv : scvs(fvGeometry))
85 {
86 const auto fluidMatrixInteraction = spatialParams.fluidMatrixInteraction(element, scv, elemSol);
87 const auto& pcKrSw = fluidMatrixInteraction.pcSwCurve();
88
89 // assert current preconditions on requiring the spatial params to store the pckrSw curve
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");
93
94 // if no parameters had been set, set them now
95 if (!pcSwAtDof_[scv.dofIndex()])
96 pcSwAtDof_[scv.dofIndex()] = &pcKrSw;
97
98 // otherwise only use the current ones if endPointPc (e.g. Brooks-Corey entry pressure) is lower
99 else if (pcKrSw.endPointPc() < pcSwAtDof_[scv.dofIndex()]->endPointPc())
100 {
101 pcSwAtDof_[scv.dofIndex()] = &pcKrSw;
102 isOnMaterialInterface_[scv.dofIndex()] = true;
103 }
104
105 // keep track of material interfaces in any case
106 else if ( !(pcKrSw == *(pcSwAtDof_[scv.dofIndex()])) )
107 isOnMaterialInterface_[scv.dofIndex()] = true;
108 }
109 }
110 }
111
113 bool isOnMaterialInterface(const SubControlVolume& scv) const
114 { return isOnMaterialInterface_[scv.dofIndex()]; }
115
117 const PcKrSw& pcSwAtDof(const SubControlVolume& scv) const
118 { return *(pcSwAtDof_[scv.dofIndex()]); }
119
120private:
121 std::vector<bool> isOnMaterialInterface_;
122 std::vector<const PcKrSw*> pcSwAtDof_;
123};
124
125} // end namespace Dumux
126
127#endif
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...
Definition: adapt.hh:29
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.