3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
facesolution.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 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
25#define DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
26
27#include <algorithm>
28#include <cassert>
29#include <type_traits>
30#include <vector>
31
32namespace Dumux {
33
38template<class FaceSolutionVector>
40{
41 using FacePrimaryVariables = std::decay_t<decltype(std::declval<FaceSolutionVector>()[0])>;
42
43public:
44
45 template<class SubControlVolumeFace, class GridGeometry>
46 StaggeredFaceSolution(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol,
47 const GridGeometry& gridGeometry)
48 {
49
50 const auto& connectivityMap = gridGeometry.connectivityMap();
51 const auto& stencil = connectivityMap(GridGeometry::faceIdx(), GridGeometry::faceIdx(), scvf.index());
52
53 facePriVars_.reserve(stencil.size()+1);
54 map_.reserve(stencil.size()+1);
55
56 map_.push_back(scvf.dofIndex());
57 facePriVars_.push_back(sol[scvf.dofIndex()]);
58 for(const auto dofJ : stencil)
59 {
60 map_.push_back(dofJ);
61 facePriVars_.push_back(sol[dofJ]);
62 }
63 }
64
66 template<typename IndexType>
67 const FacePrimaryVariables& operator [](IndexType globalFaceDofIdx) const
68 {
69 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
70 assert (pos != map_.end());
71 return facePriVars_[pos - map_.begin()];
72 }
73
75 template<typename IndexType>
76 FacePrimaryVariables& operator [](IndexType globalFaceDofIdx)
77 {
78 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
79 assert (pos != map_.end());
80 return facePriVars_[pos - map_.begin()];
81 }
82
83private:
84
85 std::vector<FacePrimaryVariables> facePriVars_;
86 std::vector<unsigned int> map_;
87};
88
89} // end namespace Dumux
90
91#endif
Definition: adapt.hh:29
The global face variables class for staggered models.
Definition: facesolution.hh:40
const FacePrimaryVariables & operator[](IndexType globalFaceDofIdx) const
bracket operator const access
Definition: facesolution.hh:67
StaggeredFaceSolution(const SubControlVolumeFace &scvf, const FaceSolutionVector &sol, const GridGeometry &gridGeometry)
Definition: facesolution.hh:46