1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
/* This file is part of the OpenLB library
*
* Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
* <http://www.openlb.net/>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/** \file
* Representation of the 3D block geometry -- generic implementation.
*/
#ifndef BLOCK_GEOMETRY_3D_HH
#define BLOCK_GEOMETRY_3D_HH
#include "geometry/blockGeometry3D.h"
namespace olb {
template<typename T>
BlockGeometry3D<T>::BlockGeometry3D(T x0, T y0, T z0, T h, int nX, int nY, int nZ, int iCglob)
: BlockData3D<T,int>(nX,nY,nZ), BlockGeometryStructure3D<T>(iCglob),
_cuboid(x0, y0, z0, h, nX, nY, nZ)
{
this->_statistics = BlockGeometryStatistics3D<T>(this);
addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}
template<typename T>
BlockGeometry3D<T>::BlockGeometry3D(Cuboid3D<T>& cuboid, int iCglob)
: BlockData3D<T,int>(cuboid.getNx(),cuboid.getNy(),cuboid.getNz()),
BlockGeometryStructure3D<T>(iCglob), _cuboid(cuboid)
{
this->_statistics = BlockGeometryStatistics3D<T>(this);
addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}
template<typename T>
BlockGeometry3D<T>::BlockGeometry3D(BlockGeometry3D const& rhs)
: BlockData3D<T,int>(rhs.getNx(), rhs.getNy(), rhs.getNz()),
BlockGeometryStructure3D<T>(rhs._iCglob), _cuboid(rhs._cuboid)
{
this->_statistics = BlockGeometryStatistics3D<T>(this);
addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
}
template<typename T>
BlockGeometry3D<T>& BlockGeometry3D<T>::operator=(BlockGeometry3D const& rhs)
{
this->_nx = rhs._nx;
this->_ny = rhs._ny;
this->_nz = rhs._nz;
this->_iCglob = rhs._iCglob;
_cuboid = rhs._cuboid;
this->_statistics = BlockGeometryStatistics3D<T>(this);
addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
return *this;
}
template<typename T>
BlockStructure3D& BlockGeometry3D<T>::getBlockStructure()
{
return *this;
}
template<typename T>
BlockGeometryStatistics3D<T>& BlockGeometry3D<T>::getStatistics(bool verbose)
{
return this->_statistics;
}
template<typename T>
BlockGeometryStatistics3D<T> const& BlockGeometry3D<T>::getStatistics(bool verbose) const
{
return this->_statistics;
}
template<typename T>
Vector<T,3> BlockGeometry3D<T>::getOrigin() const
{
return _cuboid.getOrigin();
}
template<typename T>
const T BlockGeometry3D<T>::getDeltaR() const
{
return _cuboid.getDeltaR();
}
template<typename T>
int BlockGeometry3D<T>::getNx() const
{
return _cuboid.getNx();
}
template<typename T>
int BlockGeometry3D<T>::getNy() const
{
return _cuboid.getNy();
}
template<typename T>
int BlockGeometry3D<T>::getNz() const
{
return _cuboid.getNz();
}
template<typename T>
int& BlockGeometry3D<T>::get(int iX, int iY, int iZ)
{
resetStatistics();
return BlockData3D<T,int>::get(iX,iY,iZ,0);
}
template<typename T>
int const& BlockGeometry3D<T>::get(int iX, int iY, int iZ) const
{
return BlockData3D<T,int>::get(iX,iY,iZ,0);
}
template<typename T>
int BlockGeometry3D<T>::getMaterial(int iX, int iY, int iZ) const
{
int material;
if (iX < 0 || iX + 1 > getNx() || iY < 0 || iY
+ 1 > getNy() || iZ < 0 || iZ + 1 > getNz()) {
material = 0;
} else {
material = BlockData3D<T,int>::get(iX,iY,iZ,0);
}
return material;
}
template<typename T>
void BlockGeometry3D<T>::getPhysR(T physR[3], const int& iX, const int& iY,
const int& iZ) const
{
_cuboid.getPhysR(physR, iX, iY, iZ);
return;
}
///TODO up, DONE down
/*
template<typename T>
olb::ScalarField3D<int>* BlockGeometry3D<T>::getRawData() {
return &_geometryData;
}*/
/*
template<typename T>
void BlockGeometry3D<T>::resize(int X, int Y, int Z, int nX, int nY, int nZ) {
olb::ScalarField3D<int> geometryDataTemp(nX, nY, nZ);
geometryDataTemp.construct();
geometryDataTemp.reset();
for(int iX=0; iX<nX; iX++) {
for(int iY=0; iY<nY; iY++) {
for(int iZ=0; iZ<nZ; iZ++) {
geometryDataTemp.get(iX, iY, iZ)
= _geometryData.get(X + iX, Y + iY, Z + iZ);
}
}
}
_geometryData.swap(geometryDataTemp);
geometryDataTemp.deConstruct();
}
*/
/*
template<typename T>
void BlockGeometry3D<T>::refineMesh(int level) {
// new number of Voxels in X-,Y-,and Z-direction and new spacing
int _nXnew = level * getNx();
int _nYnew = level * getNy();
int _nZnew = level * getNz();
T _hnew = getDeltaR() / ((T) level);
olb::ScalarField3D<int> _refinedGeometryData(_nXnew, _nYnew,
_nZnew);
_refinedGeometryData.construct();
for (int iX = 0; iX < getNx(); iX++) {
for (int iY = 0; iY < getNy(); iY++) {
for (int iZ = 0; iZ < getNz(); iZ++) {
for (int li = 0; li < level; li++) {
for (int lj = 0; lj < level; lj++) {
for (int lk = 0; lk < level; lk++) {
_refinedGeometryData.get(level * iX + li, level
* iY + lj, level * iZ + lk) = getMaterial(
iX, iY, iZ);
}
}
}
}
}
}
for (int iX = 0; iX < _nXnew; iX++) {
for (int iY = 0; iY < _nYnew; iY++) {
for (int iZ = 0; iZ < _nZnew; iZ++) {
if (iX == 0 || iY == 0 || iZ == 0 || iX == _nXnew - 1 || iY
== _nYnew - 1 || iZ == _nZnew - 1)
_refinedGeometryData.get(iX, iY, iZ) = 0;
}
}
}
reInit(getOrigin()[0], getOrigin()[1], getOrigin()[2], _hnew, _nXnew - 2, _nYnew - 2, _nZnew - 2, this->_iCglob,
&_refinedGeometryData);
}*/
template<typename T>
void BlockGeometry3D<T>::addToStatisticsList(bool* statisticStatus)
{
_statisticsUpdateNeeded.push_back(statisticStatus);
}
template<typename T>
void BlockGeometry3D<T>::removeFromStatisticsList(bool* statisticStatus)
{
_statisticsUpdateNeeded.remove(statisticStatus);
}
template<typename T>
void BlockGeometry3D<T>::printLayer(int x0, int x1, int y0, int y1, int z0,
int z1, bool linenumber)
{
for (int x = x0; x <= x1; x++) {
if (linenumber) {
this->clout << x << ": ";
}
for (int y = y0; y <= y1; y++) {
for (int z = z0; z <= z1; z++) {
this->clout << getMaterial(x, y, z) << " ";
}
if (y1 - y0 != 0 && z1 - z0 != 0) {
this->clout << std::endl;
}
}
if (x1 - x0 != 0) {
this->clout << std::endl;
}
}
this->clout << std::endl;
}
template<typename T>
void BlockGeometry3D<T>::printLayer(int direction, int layer, bool linenumber)
{
assert(direction >= 0 && direction <= 2);
switch (direction) {
case 0:
printLayer(layer, layer, 0, getNy() - 1, 0, getNz() - 1, linenumber);
break;
case 1:
printLayer(0, getNx() - 1, layer, layer, 0, getNz() - 1, linenumber);
break;
case 2:
printLayer(0, getNx() - 1, 0, getNy() - 1, layer, layer, linenumber);
break;
}
}
template<typename T>
void BlockGeometry3D<T>::printNode(int x0, int y0, int z0)
{
for (int x = x0 - 1; x <= x0 + 1; x++) {
this->clout << "x=" << x << std::endl;
for (int y =
|