OpenLB 1.7
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 : _cuboidGeometry(cuboidGeometry),
38 _loadBalancer(loadBalancer),
39 _overlap(overlap),
40 clout(std::cout, "SuperGeometry" + std::to_string(D) + "D")
41{
42}
43
44template<typename T, unsigned D>
46 : SuperStructure(*(new CuboidGeometry<T,D> ()),
47 *(new LoadBalancer<T> ()),
48 overlap)
49{ }
50
51template<typename T, unsigned D>
53{
54 return _cuboidGeometry;
55}
56
57template<typename T, unsigned D>
59{
60 return _cuboidGeometry;
61}
62
63template<typename T, unsigned D>
66 return _overlap;
67}
69template<typename T, unsigned D>
71{
72 return _overlap;
74
75template<typename T, unsigned D>
77{
78 return _loadBalancer;
79}
80
81template<typename T, unsigned D>
83{
84 return _loadBalancer;
86
87template<typename T, unsigned D>
88template <typename F>
91 using loc = typename PhysR<T,D>::value_t;
92 Vector<loc,D> minPhysR = _cuboidGeometry.getMinPhysR();
93 Vector<loc,D> maxPhysR = _cuboidGeometry.getMaxPhysR();
94 const loc L = _cuboidGeometry.getMotherCuboid().getDeltaR();
95 for (loc iX=minPhysR[0]; iX < maxPhysR[0]; iX+=L) {
96 for (loc iY=minPhysR[1]; iY < maxPhysR[1]; iY+=L) {
97 if constexpr (D == 3) {
98 for (loc iZ=minPhysR[2]; iZ < maxPhysR[2]; iZ+=L) {
99 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
100 f({iX,iY,iZ});
101 } else {
102 f(iX,iY,iZ);
103 }
104 }
105 } else {
106 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
107 f({iX,iY});
108 } else {
109 f(iX,iY);
110 }
111 }
112 }
113 }
114};
115
116template<typename T, unsigned D>
117template <typename F>
119{
120 using loc = typename PhysR<T,D>::value_t;
121 Vector<loc,D> minPhysR = _cuboidGeometry.getMinPhysR();
122 Vector<loc,D> maxPhysR = _cuboidGeometry.getMaxPhysR();
123 const loc L = _cuboidGeometry.getMotherCuboid().getDeltaR();
124 for (loc iX=std::max(minPhysR[0],min[0]); iX < std::min(maxPhysR[0],max[0]+L); iX+=L) {
125 for (loc iY=std::max(minPhysR[1],min[1]); iY < std::min(maxPhysR[1],max[1]+L); iY+=L) {
126 if constexpr (D == 3) {
127 for (loc iZ=std::max(minPhysR[2],min[2]); iZ < std::min(maxPhysR[2],max[2]+L); iZ+=L) {
128 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
129 f({iX,iY,iZ});
130 } else {
131 f(iX,iY,iZ);
132 }
133 }
134 } else {
135 if constexpr (std::is_invocable_v<F, PhysR<T,D>>) {
136 f({iX,iY});
137 } else {
138 f(iX,iY);
139 }
140 }
141 }
142 }
143};
144
145template<typename T, unsigned D>
146template <typename F>
148{
149 forCorePhysLocations([&](PhysR<T,D> physLoc){
150 LatticeR<D+1> latticeR;
151 _cuboidGeometry.getLatticeR( latticeR.data(), physLoc.data() );
152 if constexpr (std::is_invocable_v<F, LatticeR<D+1>>) {
153 f(latticeR);
154 } else {
155 if constexpr (D == 3) {
156 f(latticeR[0],latticeR[1],latticeR[2],latticeR[3]);
157 } else {
158 f(latticeR[0],latticeR[1],latticeR[2]);
159 }
160 }
161 });
162};
163
164template<typename T, unsigned D>
165template <typename F>
167{
168 forCorePhysLocations(min, max, [&](PhysR<T,D> physLoc){
169 LatticeR<D+1> latticeR;
170 _cuboidGeometry.getLatticeR( latticeR.data(), physLoc.data() );
171 if constexpr (std::is_invocable_v<F, LatticeR<D+1>>) {
172 f(latticeR);
173 } else {
174 if constexpr (D == 3) {
175 f(latticeR[0],latticeR[1],latticeR[2],latticeR[3]);
176 } else {
177 f(latticeR[0],latticeR[1],latticeR[2]);
178 }
179 }
180 });
181};
182
183}
184
185#endif
Base class for all LoadBalancer.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
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(CuboidGeometry< T, D > &cuboidGeometry, LoadBalancer< T > &loadBalancer, int overlap=2)
Construction of a super structure.
Plain old scalar vector.
Definition vector.h:47
constexpr const T * data() const any_platform
Definition vector.h:161
Top level namespace for all of OpenLB.
std::conditional_t< D==2, CuboidGeometry2D< T >, CuboidGeometry3D< T > > CuboidGeometry
Definition aliases.h:47