version 3.11-dev
Loading...
Searching...
No Matches
elementinterpolationpointdatacache.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_CVFE_ELEMENT_INTERPOLATION_POINT_DATA_CACHE_HH
13#define DUMUX_DISCRETIZATION_CVFE_ELEMENT_INTERPOLATION_POINT_DATA_CACHE_HH
14
15#include <cstddef>
16#include <ranges>
17#include <vector>
18
20
22
28template<class InterpolationPointData>
30{
31public:
32 template<class Problem, class ElementDiscretization, class ElementVariables>
33 void update(const Problem& problem,
34 const typename ElementDiscretization::Element& element,
35 const ElementDiscretization& elemDisc,
36 const ElementVariables& elemVars)
37 {
38 // the first update sizes the storage exactly, later updates reuse it
39 if (scvfCache_.empty())
40 {
41 std::size_t numQps = 0;
42 for (const auto& scvf : scvfs(elemDisc))
43 numQps += std::ranges::size(Dumux::CVFE::quadratureRule(elemDisc, scvf));
44 scvfCache_.reserve(numQps);
45 }
46
47 qpsOffset_.resize(elemDisc.numScvf());
48 std::size_t numQps = 0;
49 for (const auto& scvf : scvfs(elemDisc))
50 {
51 qpsOffset_[scvf.index()] = numQps;
52 for (const auto& qpData : Dumux::CVFE::quadratureRule(elemDisc, scvf))
53 {
54 if (numQps == scvfCache_.size())
55 scvfCache_.emplace_back();
56 scvfCache_[numQps++].update(problem, element, elemDisc, elemVars, qpData.ipData());
57 }
58 }
59 scvfCache_.resize(numQps);
60 }
61
62 const InterpolationPointData& scvfCache(std::size_t scvfIdx, std::size_t qpIdx) const
63 { return scvfCache_[qpsOffset_[scvfIdx] + qpIdx]; }
64
65 InterpolationPointData& scvfCache(std::size_t scvfIdx, std::size_t qpIdx)
66 { return scvfCache_[qpsOffset_[scvfIdx] + qpIdx]; }
67
68private:
69 std::vector<InterpolationPointData> scvfCache_;
70 std::vector<std::size_t> qpsOffset_;
71};
72
78template<class InterpolationPointData>
80{
81public:
82 template<class Problem, class ElementDiscretization, class ElementVariables>
83 void update(const Problem& problem,
84 const typename ElementDiscretization::Element& element,
85 const ElementDiscretization& elemDisc,
86 const ElementVariables& elemVars)
87 {
88 const auto elemQuadRule = Dumux::CVFE::quadratureRule(elemDisc, element);
89 elementCache_.resize(std::ranges::size(elemQuadRule));
90 for (const auto& qpData : elemQuadRule)
91 elementCache_[qpData.ipData().qpIndex()].update(problem, element, elemDisc, elemVars, qpData.ipData());
92
93 boundaryFaceCache_.resize(std::ranges::size(boundaryFaces(elemDisc)));
94 for (const auto& boundaryFace : boundaryFaces(elemDisc))
95 {
96 auto& bfCache = boundaryFaceCache_[boundaryFace.index()];
97 const auto quadRule = Dumux::CVFE::quadratureRule(elemDisc, boundaryFace);
98 bfCache.resize(std::ranges::size(quadRule));
99 for (const auto& qpData : quadRule)
100 bfCache[qpData.ipData().qpIndex()].update(problem, element, elemDisc, elemVars, qpData.ipData());
101 }
102 }
103
104 const InterpolationPointData& elementCache(std::size_t qpIdx) const
105 { return elementCache_[qpIdx]; }
106
107 InterpolationPointData& elementCache(std::size_t qpIdx)
108 { return elementCache_[qpIdx]; }
109
110 const InterpolationPointData& boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx) const
111 { return boundaryFaceCache_[bfIdx][qpIdx]; }
112
113 InterpolationPointData& boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx)
114 { return boundaryFaceCache_[bfIdx][qpIdx]; }
115
116private:
117 std::vector<InterpolationPointData> elementCache_;
118 std::vector<std::vector<InterpolationPointData>> boundaryFaceCache_;
119};
120
126template<class InterpolationPointData>
128{
129public:
130 template<class Problem, class ElementDiscretization, class ElementVariables>
131 void update(const Problem& problem,
132 const typename ElementDiscretization::Element& element,
133 const ElementDiscretization& elemDisc,
134 const ElementVariables& elemVars)
135 {
136 scvfCache_.update(problem, element, elemDisc, elemVars);
137 elementAndBoundaryCache_.update(problem, element, elemDisc, elemVars);
138 }
139
140 const InterpolationPointData& scvfCache(std::size_t scvfIdx, std::size_t qpIdx) const
141 { return scvfCache_.scvfCache(scvfIdx, qpIdx); }
142
143 InterpolationPointData& scvfCache(std::size_t scvfIdx, std::size_t qpIdx)
144 { return scvfCache_.scvfCache(scvfIdx, qpIdx); }
145
146 const InterpolationPointData& elementCache(std::size_t qpIdx) const
147 { return elementAndBoundaryCache_.elementCache(qpIdx); }
148
149 InterpolationPointData& elementCache(std::size_t qpIdx)
150 { return elementAndBoundaryCache_.elementCache(qpIdx); }
151
152 const InterpolationPointData& boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx) const
153 { return elementAndBoundaryCache_.boundaryFaceCache(bfIdx, qpIdx); }
154
155 InterpolationPointData& boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx)
156 { return elementAndBoundaryCache_.boundaryFaceCache(bfIdx, qpIdx); }
157
158private:
161};
162
163} // end namespace Dumux::Detail::CVFE
164
165#endif
Interpolation point data at the quadrature points of an element and of its boundary faces.
Definition elementinterpolationpointdatacache.hh:80
InterpolationPointData & elementCache(std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:107
const InterpolationPointData & elementCache(std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:104
InterpolationPointData & boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:113
void update(const Problem &problem, const typename ElementDiscretization::Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars)
Definition elementinterpolationpointdatacache.hh:83
const InterpolationPointData & boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:110
Interpolation point data at the quadrature points of the sub-control volume faces,...
Definition elementinterpolationpointdatacache.hh:128
InterpolationPointData & elementCache(std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:149
InterpolationPointData & boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:155
void update(const Problem &problem, const typename ElementDiscretization::Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars)
Definition elementinterpolationpointdatacache.hh:131
const InterpolationPointData & elementCache(std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:146
const InterpolationPointData & scvfCache(std::size_t scvfIdx, std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:140
InterpolationPointData & scvfCache(std::size_t scvfIdx, std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:143
const InterpolationPointData & boundaryFaceCache(std::size_t bfIdx, std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:152
Interpolation point data at the quadrature points of the sub-control volume faces of an element.
Definition elementinterpolationpointdatacache.hh:30
InterpolationPointData & scvfCache(std::size_t scvfIdx, std::size_t qpIdx)
Definition elementinterpolationpointdatacache.hh:65
void update(const Problem &problem, const typename ElementDiscretization::Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars)
Definition elementinterpolationpointdatacache.hh:33
const InterpolationPointData & scvfCache(std::size_t scvfIdx, std::size_t qpIdx) const
Definition elementinterpolationpointdatacache.hh:62
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition quadraturerules.hh:160
Definition elementinterpolationpointdatacache.hh:21
Quadrature rules over sub-control volumes and sub-control volume faces.