3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
boxmaterialinterfaceparams.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_INTERFACE_PARAMS_HH
26#define DUMUX_2P_BOX_MATERIAL_INTERFACE_PARAMS_HH
27
28#include <dune/common/exceptions.hh>
29
32
33namespace Dumux {
34
45template<class SpatialParams>
47{
48public:
49 using MaterialLawParams = typename SpatialParams::MaterialLaw::Params;
50
58 template<class GridGeometry, class SolutionVector>
59 void update(const GridGeometry& gridGeometry,
60 const SpatialParams& spatialParams,
61 const SolutionVector& x)
62 {
63 using MaterialLaw = typename SpatialParams::MaterialLaw;
64
65 // Make sure the spatial params return a const ref and no copy!
66 using Elem = typename GridGeometry::GridView::template Codim<0>::Entity;
67 using ElemSol = decltype( elementSolution(Elem(), x, gridGeometry) );
68 using Scv = typename GridGeometry::SubControlVolume;
69 using ReturnType = decltype(spatialParams.materialLawParams(Elem(), Scv(), ElemSol()));
70 static_assert(std::is_lvalue_reference<ReturnType>::value,
71 "In order to use the box-interface solver please provide access "
72 "to the material law parameters via returning (const) references");
73
74 // make sure this is only called for geometries of the box method!
75 if (GridGeometry::discMethod != DiscretizationMethod::box)
76 DUNE_THROW(Dune::InvalidStateException, "Determination of the interface material parameters with "
77 "this class only makes sense when using the box method!");
78
79 isUpdated_ = true;
80 isOnMaterialInterface_.resize(gridGeometry.numDofs(), false);
81 dofParams_.resize(gridGeometry.numDofs(), nullptr);
82 for (const auto& element : elements(gridGeometry.gridView()))
83 {
84 const auto elemSol = elementSolution(element, x, gridGeometry);
85
86 auto fvGeometry = localView(gridGeometry);
87 fvGeometry.bind(element);
88 for (const auto& scv : scvs(fvGeometry))
89 {
90 const auto& params = spatialParams.materialLawParams(element, scv, elemSol);
91
92 // if no parameters had been set, set them now
93 if (dofParams_[scv.dofIndex()] == nullptr)
94 dofParams_[scv.dofIndex()] = &params;
95
96 // otherwise only use the current ones if endPointPc (e.g. Brooks-Corey entry pressure) is lower
97 else if (MaterialLaw::endPointPc( params ) < MaterialLaw::endPointPc( *(dofParams_[scv.dofIndex()]) ))
98 {
99 dofParams_[scv.dofIndex()] = &params;
100 isOnMaterialInterface_[scv.dofIndex()] = true;
101 }
102
103 // keep track of material interfaces in any case
104 else if ( !(params == *(dofParams_[scv.dofIndex()])) )
105 isOnMaterialInterface_[scv.dofIndex()] = true;
106 }
107 }
108 }
109
111 template<class Scv>
112 bool isOnMaterialInterface(const Scv& scv) const
113 { assert(isUpdated_); return isOnMaterialInterface_[scv.dofIndex()]; }
114
116 template<class Scv>
117 const MaterialLawParams& getDofParams(const Scv& scv) const
118 { assert(isUpdated_); return *(dofParams_[scv.dofIndex()]); }
119
120private:
121 bool isUpdated_{false};
122 std::vector<bool> isOnMaterialInterface_;
123 std::vector<const MaterialLawParams*> dofParams_;
124};
125
126} // end namespace Dumux
127
128#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==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:115
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Class that determines the material with the lowest capillary pressure (under fully water-saturated co...
Definition: boxmaterialinterfaceparams.hh:47
typename SpatialParams::MaterialLaw::Params MaterialLawParams
Definition: boxmaterialinterfaceparams.hh:49
void update(const GridGeometry &gridGeometry, const SpatialParams &spatialParams, const SolutionVector &x)
Updates the scv -> dofparameter map.
Definition: boxmaterialinterfaceparams.hh:59
const MaterialLawParams & getDofParams(const Scv &scv) const
Returns the material parameters associated with the dof.
Definition: boxmaterialinterfaceparams.hh:117
bool isOnMaterialInterface(const Scv &scv) const
Returns if this scv is connected to a material interface.
Definition: boxmaterialinterfaceparams.hh:112
The local element solution class for the box method.