version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
13#define DUMUX_DISCRETIZATION_STAGGERED_FACE_SOLUTION_HH
14
15#include <algorithm>
16#include <cassert>
17#include <type_traits>
18#include <vector>
19
20namespace Dumux {
21
26template<class FaceSolutionVector>
28{
29 using FacePrimaryVariables = std::decay_t<decltype(std::declval<FaceSolutionVector>()[0])>;
30
31public:
32
33 template<class SubControlVolumeFace, class GridGeometry>
34 StaggeredFaceSolution(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol,
35 const GridGeometry& gridGeometry)
36 {
37
38 const auto& connectivityMap = gridGeometry.connectivityMap();
39 const auto& stencil = connectivityMap(GridGeometry::faceIdx(), GridGeometry::faceIdx(), scvf.index());
40
41 facePriVars_.reserve(stencil.size()+1);
42 map_.reserve(stencil.size()+1);
43
44 map_.push_back(scvf.dofIndex());
45 facePriVars_.push_back(sol[scvf.dofIndex()]);
46 for(const auto dofJ : stencil)
47 {
48 map_.push_back(dofJ);
49 facePriVars_.push_back(sol[dofJ]);
50 }
51 }
52
54 template<typename IndexType>
55 const FacePrimaryVariables& operator [](IndexType globalFaceDofIdx) const
56 {
57 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
58 assert (pos != map_.end());
59 return facePriVars_[pos - map_.begin()];
60 }
61
63 template<typename IndexType>
64 FacePrimaryVariables& operator [](IndexType globalFaceDofIdx)
65 {
66 const auto pos = std::find(map_.begin(), map_.end(), globalFaceDofIdx);
67 assert (pos != map_.end());
68 return facePriVars_[pos - map_.begin()];
69 }
70
71private:
72
73 std::vector<FacePrimaryVariables> facePriVars_;
74 std::vector<unsigned int> map_;
75};
76
77} // end namespace Dumux
78
79#endif
The global face variables class for staggered models.
Definition: facesolution.hh:28
const FacePrimaryVariables & operator[](IndexType globalFaceDofIdx) const
bracket operator const access
Definition: facesolution.hh:55
StaggeredFaceSolution(const SubControlVolumeFace &scvf, const FaceSolutionVector &sol, const GridGeometry &gridGeometry)
Definition: facesolution.hh:34
Definition: adapt.hh:17