OpenLB 1.8.1
Loading...
Searching...
No Matches
superStructure.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2014 Peter Weisbrod, Albert Mink, Mathias J. Krause
4 * 2021 Adrian Kummerlaender
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 */
24
25#ifndef SUPER_STRUCTURE_HH
26#define SUPER_STRUCTURE_HH
27
29
30namespace olb {
31
32
33template<typename T, unsigned D>
35 LoadBalancer<T>& loadBalancer,
36 int overlap)
37 : _cuboidDecomposition(cuboidDecomposition),
38 _loadBalancer(loadBalancer),
39 _overlap(overlap),
40 clout(std::cout, "SuperStructure" + std::to_string(D) + "D")
41{
42}
43
44template<typename T, unsigned D>
49
50template<typename T, unsigned D>
52{
53 return _cuboidDecomposition;
54}
55
56template<typename T, unsigned D>
58{
59 return _overlap;
60}
62template<typename T, unsigned D>
64{
65 return _overlap;
67
68template<typename T, unsigned D>
74template<typename T, unsigned D>
76{
77 return _loadBalancer;
78}
80template<typename T, unsigned D>
81template <typename F>
84 using loc = typename PhysR<T,D>::value_t;
85 Vector<loc,D> minPhysR = _cuboidDecomposition.getMinPhysR();
86 Vector<loc,D> maxPhysR = _cuboidDecomposition.getMaxPhysR();
87 const loc L = _cuboidDecomposition.getMotherCuboid().getDeltaR();
88 for (loc iX=minPhysR[0]; iX < maxPhysR[0]; iX+=L) {
89 for (loc iY=minPhysR[1]; iY < maxPhysR[1]; iY+=L) {
90 if constexpr (D == 3) {
91 for (loc iZ=minPhysR[2]; iZ < maxPhysR[2]; iZ+=L) {
92 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
93 f({iX,iY,iZ});
94 } else {
95 f(iX,iY,iZ);
96 }
97 }
98 } else {
99 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
100 f({iX,iY});
101 } else {
102 f(iX,iY);
103 }
104 }
105 }
106 }
107};
108
109template<typename T, unsigned D>
110template <typename F>
112{
113 using loc = typename PhysR<T,D>::value_t;
114 Vector<loc,D> minPhysR = _cuboidDecomposition.getMinPhysR();
115 Vector<loc,D> maxPhysR = _cuboidDecomposition.getMaxPhysR();
116 const loc L = _cuboidDecomposition.getDeltaR();
117 for (loc iX=std::max(minPhysR[0],min[0]); iX < std::min(maxPhysR[0],max[0]+L); iX+=L) {
118 for (loc iY=std::max(minPhysR[1],min[1]); iY < std::min(maxPhysR[1],max[1]+L); iY+=L) {
119 if constexpr (D == 3) {
120 for (loc iZ=std::max(minPhysR[2],min[2]); iZ < std::min(maxPhysR[2],max[2]+L); iZ+=L) {
121 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
122 f({iX,iY,iZ});
123 } else {
124 f(iX,iY,iZ);
125 }
126 }
127 } else {
128 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
129 f({iX,iY});
130 } else {
131 f(iX,iY);
132 }
133 }
134 }
135 }
136};
137
138template<typename T, unsigned D>
139template <typename F>
141{
142 forCorePhysLocations([&](PhysR<T,D> physLoc){
143 auto latticeR = _cuboidDecomposition.getLatticeR(physLoc);
144 if (latticeR) {
145 if constexpr (std::is_invocable_v<F, LatticeR<D+1>>) {
146 f(*latticeR);
147 } else {
148 auto lR = *latticeR;
149 if constexpr (D == 3) {
150 f(lR[0],lR[1],lR[2],lR[3]);
151 } else {
152 f(lR[0],lR[1],lR[2]);
153 }
154 }
155 }
156 });
157};
158
159template<typename T, unsigned D>
160template <typename F>
162{
163 forCorePhysLocations(min, max, [&](PhysR<T,D> physLoc){
164 auto latticeR = _cuboidDecomposition.getLatticeR(physLoc.data());
165 if (latticeR) {
166 if constexpr (std::is_invocable_v<F, LatticeR<D+1>>) {
167 f(*latticeR);
168 } else {
169 auto lR = *latticeR;
170 if constexpr (D == 3) {
171 f(lR[0],lR[1],lR[2],lR[3]);
172 } else {
173 f(lR[0],lR[1],lR[2]);
174 }
175 }
176 }
177 });
178};
179
180}
181
182#endif
Decomposition of a physical volume into a set of disjoint cuboids.
Base class for all LoadBalancer.
Definition vtiWriter.h:42
int getOverlap()
Read and write access to the overlap.
void forCorePhysLocations(F f) const
Iterate over discrete physical locations.
void forCoreSpatialLocations(F f) const
Iterate over spatial locations NOTE: Based on physical locations (as opposed to its blockStructure ve...
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
SuperStructure(CuboidDecomposition< T, D > &cuboidDecomposition, LoadBalancer< T > &loadBalancer, int overlap=2)
Construction of a super structure.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
Plain old scalar vector.
constexpr const T * data() const any_platform
Definition vector.h:172
Top level namespace for all of OpenLB.