Loading [MathJax]/extensions/tex2jax.js
3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
staggeredfvproblem.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_STAGGERD_FV_PROBLEM_HH
26#define DUMUX_STAGGERD_FV_PROBLEM_HH
27
28#include <dune/common/rangeutilities.hh>
29
33
34namespace Dumux {
35
46template<class TypeTag>
47class StaggeredFVProblem : public FVProblem<TypeTag>
48{
50 using Implementation = GetPropType<TypeTag, Properties::Problem>;
52 using Element = typename GridView::template Codim<0>::Entity;
53
55 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
56 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
57 using GridFaceVariables = typename GridVariables::GridFaceVariables;
58 using ElementFaceVariables = typename GridFaceVariables::LocalView;
59
62 using FVElementGeometry = typename GridGeometry::LocalView;
63 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
64 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
66
67 using CoordScalar = typename GridView::ctype;
68 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
69
70 static constexpr auto cellCenterIdx = GridGeometry::cellCenterIdx();
71 static constexpr auto faceIdx = GridGeometry::faceIdx();
72
73 static constexpr auto numEqCellCenter = getPropValue<TypeTag, Properties::NumEqCellCenter>();
74 static constexpr auto numEqFace = getPropValue<TypeTag, Properties::NumEqFace>();
75
76public:
82 StaggeredFVProblem(std::shared_ptr<const GridGeometry> gridGeometry, const std::string& paramGroup = "")
84 { }
85
94 bool isDirichletCell(const Element& element,
95 const FVElementGeometry& fvGeometry,
96 const SubControlVolume& scv,
97 int pvIdx) const
98 { return false; }
99
118 template<class ElementVolumeVariables, class ElementFaceVariables, class Entity>
119 NumEqVector source(const Element &element,
120 const FVElementGeometry& fvGeometry,
121 const ElementVolumeVariables& elemVolVars,
122 const ElementFaceVariables& elementFaceVars,
123 const Entity &e) const
124 {
125 // forward to solution independent, fully-implicit specific interface
126 return asImp_().sourceAtPos(e.center());
127 }
128
144 NumEqVector neumann(const Element& element,
145 const FVElementGeometry& fvGeometry,
146 const ElementVolumeVariables& elemVolVars,
147 const ElementFaceVariables& elemFaceVars,
148 const SubControlVolumeFace& scvf) const
149 {
150 // forward it to the interface with only the global position
151 return asImp_().neumannAtPos(scvf.ipGlobal());
152 }
153
160 template<class Entity>
161 PrimaryVariables initial(const Entity& entity) const
162 {
163 return asImp_().initialAtPos(entity.center());
164 }
165
170 template<class SolutionVector>
171 void applyInitialSolution(SolutionVector& sol) const
172 {
173 sol[cellCenterIdx].resize(this->gridGeometry().numCellCenterDofs());
174 sol[faceIdx].resize(this->gridGeometry().numFaceDofs());
175
176 for (const auto& element : elements(this->gridGeometry().gridView()))
177 {
178 auto fvGeometry = localView(this->gridGeometry());
179 fvGeometry.bindElement(element);
180
181 // loop over sub control volumes
182 for (auto&& scv : scvs(fvGeometry))
183 {
184 // let the problem do the dirty work of nailing down
185 // the initial solution.
186 auto initPriVars = asImp_().initial(scv);
187 asImp_().applyInitialCellCenterSolution(sol, scv, initPriVars);
188 }
189
190 // loop over faces
191 for(auto&& scvf : scvfs(fvGeometry))
192 {
193 auto initPriVars = asImp_().initial(scvf);
194 asImp_().applyInitialFaceSolution(sol, scvf, initPriVars);
195 }
196 }
197 }
198
199
201 template<class SolutionVector>
202 void applyInitialCellCenterSolution(SolutionVector& sol,
203 const SubControlVolume& scv,
204 const PrimaryVariables& initSol) const
205 {
206 // while the container within the actual solution vector holds numEqCellCenter
207 // elements, we need to specify an offset to get the correct entry of the initial solution
208 static constexpr auto offset = PrimaryVariables::dimension - numEqCellCenter;
209
210 for(int pvIdx = 0; pvIdx < numEqCellCenter; ++pvIdx)
211 sol[cellCenterIdx][scv.dofIndex()][pvIdx] = initSol[pvIdx + offset];
212 }
213
215 template<class SolutionVector>
216 void applyInitialFaceSolution(SolutionVector& sol,
217 const SubControlVolumeFace& scvf,
218 const PrimaryVariables& initSol) const
219 {
220 for(int pvIdx = 0; pvIdx < numEqFace; ++pvIdx)
221 sol[faceIdx][scvf.dofIndex()][pvIdx] = initSol[pvIdx];
222 }
223
224protected:
226 Implementation &asImp_()
227 { return *static_cast<Implementation *>(this); }
228
230 const Implementation &asImp_() const
231 { return *static_cast<const Implementation *>(this); }
232};
233
234} // end namespace Dumux
235
236#endif
A helper to deduce a vector with the same size as numbers of equations.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:55
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:579
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:575
Base class for all staggered finite-volume problems.
Definition: staggeredfvproblem.hh:48
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: staggeredfvproblem.hh:144
bool isDirichletCell(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, int pvIdx) const
Returns whether a fixed Dirichlet value shall be used at a given cell.
Definition: staggeredfvproblem.hh:94
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: staggeredfvproblem.hh:230
StaggeredFVProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string &paramGroup="")
Constructor.
Definition: staggeredfvproblem.hh:82
PrimaryVariables initial(const Entity &entity) const
Evaluate the initial value for an element (for cell-centered primary variables) or face (for velociti...
Definition: staggeredfvproblem.hh:161
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: staggeredfvproblem.hh:226
void applyInitialFaceSolution(SolutionVector &sol, const SubControlVolumeFace &scvf, const PrimaryVariables &initSol) const
Applys the initial face solution.
Definition: staggeredfvproblem.hh:216
void applyInitialCellCenterSolution(SolutionVector &sol, const SubControlVolume &scv, const PrimaryVariables &initSol) const
Applys the initial cell center solution.
Definition: staggeredfvproblem.hh:202
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: staggeredfvproblem.hh:171
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elementFaceVars, const Entity &e) const
Evaluate the source term for all phases within a given sub-control-volume (-face).
Definition: staggeredfvproblem.hh:119
Base class for all finite volume problems.
Declares all properties used in Dumux.