OpenLB 1.7
Loading...
Searching...
No Matches
cuboidGeometry3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2007, 2014 Mathias J. Krause
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
29#ifndef CUBOID_GEOMETRY_3D_HH
30#define CUBOID_GEOMETRY_3D_HH
31
32
33#include <iostream>
34#include <math.h>
35#include <algorithm>
36#include <set>
37#include <limits>
38
41
42namespace olb {
43
44template<typename T>
46 : _motherCuboid(0,0,0,0,0,0,0), _periodicityOn(false), clout(std::cout, "CuboidGeometry3D")
47{
48 _cuboids.reserve(2);
49 add(_motherCuboid);
50 split(0, 1);
51}
52
53template<typename T>
54CuboidGeometry3D<T>::CuboidGeometry3D(T originX, T originY, T originZ, T deltaR,
55 int nX, int nY, int nZ, int nC)
56 : _motherCuboid(originX, originY, originZ, deltaR, nX, nY, nZ),
57 _periodicityOn(false), clout(std::cout, "CuboidGeometry3D")
58{
59 _cuboids.reserve(nC+2);
60 add(_motherCuboid);
61 split(0, nC);
62}
63
64template<typename T>
65CuboidGeometry3D<T>::CuboidGeometry3D(std::vector<T> origin, T deltaR,
66 std::vector<int> extent, int nC)
67 : CuboidGeometry3D(origin[0], origin[1], origin[2], deltaR,
68 extent[0], extent[1], extent[2], nC)
69{ }
70
71template<typename T>
73 Vector<int,3> extent, int nC)
74 : CuboidGeometry3D(origin[0], origin[1], origin[2], deltaR,
75 extent[0], extent[1], extent[2], nC)
76{ }
77
78template<typename T>
81 motherCuboid.getOrigin(), motherCuboid.getDeltaR(),
82 motherCuboid.getExtent(), nC)
83{ }
84
85template<typename T>
87 : _motherCuboid( indicatorF.getMin()[0], indicatorF.getMin()[1], indicatorF.getMin()[2], voxelSize,
88 (int)((indicatorF.getMax()[0] - indicatorF.getMin()[0]) / voxelSize + 1.5),
89 (int)((indicatorF.getMax()[1] - indicatorF.getMin()[1]) / voxelSize + 1.5),
90 (int)((indicatorF.getMax()[2] - indicatorF.getMin()[2]) / voxelSize + 1.5)),
91 _periodicityOn(false), clout(std::cout, "CuboidGeometry3D")
92{
93 _cuboids.reserve(nC+2);
94 add(_motherCuboid);
95 if (nC > 1) {
96 split(0, nC);
97 shrink(indicatorF);
98 }
99}
100
101template<typename T>
102CuboidGeometry3D<T>::CuboidGeometry3D(std::shared_ptr<IndicatorF3D<T>> indicator_sharedPtrF, T voxelSize, int nC)
103 : CuboidGeometry3D<T>(*indicator_sharedPtrF, voxelSize, nC)
104{
105}
106
107template<typename T>
108CuboidGeometry3D<T>::CuboidGeometry3D(IndicatorF3D<T>& indicatorF, T voxelSize, int nC, std::string minimizeBy)
109 : _motherCuboid( indicatorF.getMin()[0], indicatorF.getMin()[1], indicatorF.getMin()[2], voxelSize,
110 (int)((indicatorF.getMax()[0] - indicatorF.getMin()[0]) / voxelSize + 1.5),
111 (int)((indicatorF.getMax()[1] - indicatorF.getMin()[1]) / voxelSize + 1.5),
112 (int)((indicatorF.getMax()[2] - indicatorF.getMin()[2]) / voxelSize + 1.5)),
113 _periodicityOn(false), clout(std::cout, "CuboidGeometry3D")
114{
115 _cuboids.reserve(nC+2);
116 add(_motherCuboid);
117
118 if ( minimizeBy == "volume" ) {
119 minimizeByVolume(*this, indicatorF, nC);
120 }
121 else if ( minimizeBy == "weight" ) {
122 minimizeByWeight(*this, indicatorF, nC);
123 }
124}
125
126template<typename T>
127CuboidGeometry3D<T>::CuboidGeometry3D(std::shared_ptr<IndicatorF3D<T>> indicator_sharedPtrF, T voxelSize, int nC, std::string minimizeBy)
128 : CuboidGeometry3D<T>(*indicator_sharedPtrF, voxelSize, nC, minimizeBy)
129{
130}
131
132template<typename T>
134
135
136template<typename T>
138{
139 return _cuboids[iC];
140}
141
142template<typename T>
144{
145 return _cuboids[iC];
146}
147
148template<typename T>
150{
151 return _motherCuboid;
152}
153
154template<typename T>
156{
157 return _motherCuboid;
158}
159
160template<typename T>
161void CuboidGeometry3D<T>::setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ)
162{
163 _periodicityOn[0] = periodicityX;
164 _periodicityOn[1] = periodicityY;
165 _periodicityOn[2] = periodicityZ;
166}
167
168
169template<typename T>
170int CuboidGeometry3D<T>::get_iC(T x, T y, T z, int offset) const
171{
172 unsigned i;
173 for (i = 0; i < _cuboids.size(); i++) {
174 if (_cuboids[i].checkPoint(x, y, z, offset)) {
175 return (int)i;
176 }
177 }
178 return (int)i;
179}
180
181
182template<typename T>
183int CuboidGeometry3D<T>::get_iC(Vector<T,3> coords, int offset) const
184{
185 return get_iC(coords[0], coords[1], coords[2], offset);
186}
187
188template<typename T>
189int CuboidGeometry3D<T>::get_iC(T x, T y, T z, int orientationX, int orientationY,
190 int orientationZ) const
191{
192 unsigned i;
193 for (i = 0; i < _cuboids.size(); i++) {
194 if (_cuboids[i].checkPoint(x, y, z) &&
195 _cuboids[i].checkPoint(x + orientationX / _cuboids[i].getDeltaR(),
196 y + orientationY / _cuboids[i].getDeltaR(),
197 z + orientationZ / _cuboids[i].getDeltaR())) {
198 return (int)i;
199 }
200 }
201 return (int)i;
202}
203
204template<typename T>
205bool CuboidGeometry3D<T>::getC(T physR[3], int& iC) const
206{
207 const int iCtmp = get_iC(physR[0], physR[1], physR[2]);
208 if (iCtmp < getNc()) {
209 iC = iCtmp;
210 return true;
211 }
212 else {
213 return false;
214 }
215}
216
217template<typename T>
218bool CuboidGeometry3D<T>::getC(std::vector<T> physR, int& iC) const
219{
220 const int iCtmp = get_iC(physR);
221 if (iCtmp < getNc()) {
222 iC = iCtmp;
223 return true;
224 }
225 else {
226 return false;
227 }
228}
229
230template<typename T>
231bool CuboidGeometry3D<T>::getC(const Vector<T,3>& physR, int& iC) const
232{
233 const int iCtmp = get_iC(physR);
234 if (iCtmp < getNc()) {
235 iC = iCtmp;
236 return true;
237 }
238 else {
239 return false;
240 }
241}
242
243template<typename T>
244bool CuboidGeometry3D<T>::getLatticeR(int latticeR[4], const T physR[3]) const
245{
246 int iCtmp = get_iC(physR[0], physR[1], physR[2]);
247 if (iCtmp < getNc()) {
248 latticeR[0] = iCtmp;
249 latticeR[1] = (int)util::floor( (physR[0] - _cuboids[latticeR[0]].getOrigin()[0] ) / _cuboids[latticeR[0]].getDeltaR() + .5);
250 latticeR[2] = (int)util::floor( (physR[1] - _cuboids[latticeR[0]].getOrigin()[1] ) / _cuboids[latticeR[0]].getDeltaR() + .5);
251 latticeR[3] = (int)util::floor( (physR[2] - _cuboids[latticeR[0]].getOrigin()[2] ) / _cuboids[latticeR[0]].getDeltaR() + .5);
252 return true;
253 }
254 else {
255 return false;
256 }
257}
258
259template<typename T>
260bool CuboidGeometry3D<T>::getFloorLatticeR(const std::vector<T>& physR, std::vector<int>& latticeR) const
261{
262 int iCtmp = get_iC(physR[0], physR[1], physR[2]);
263 if (iCtmp < getNc()) {
264 latticeR[0] = iCtmp;
265 latticeR[1] = (int)util::floor( (physR[0] - _cuboids[latticeR[0]].getOrigin()[0] ) / _cuboids[latticeR[0]].getDeltaR() );
266 latticeR[2] = (int)util::floor( (physR[1] - _cuboids[latticeR[0]].getOrigin()[1] ) / _cuboids[latticeR[0]].getDeltaR() );
267 latticeR[3] = (int)util::floor( (physR[2] - _cuboids[latticeR[0]].getOrigin()[2] ) / _cuboids[latticeR[0]].getDeltaR() );
268 return true;
269 }
270 else {
271 return false;
272 }
273}
274
275template<typename T>
277 const Vector<T,3>& physR, Vector<int,4>& latticeR) const
278{
279 int iCtmp = get_iC(physR[0], physR[1], physR[2]);
280 if (iCtmp < getNc()) {
281 latticeR[0] = iCtmp;
282 latticeR[1] = (int)util::floor( (physR[0] - _cuboids[latticeR[0]].getOrigin()[0] ) / _cuboids[latticeR[0]].getDeltaR() );
283 latticeR[2] = (int)util::floor( (physR[1] - _cuboids[latticeR[0]].getOrigin()[1] ) / _cuboids[latticeR[0]].getDeltaR() );
284 latticeR[3] = (int)util::floor( (physR[2] - _cuboids[latticeR[0]].getOrigin()[2] ) / _cuboids[latticeR[0]].getDeltaR() );
285 return true;
286 }
287 else {
288 return false;
289 }
290}
291
292template<typename T>
293void CuboidGeometry3D<T>::getPhysR(T physR[3], const int& iCglob, const int& iX, const int& iY, const int& iZ) const
294{
295 _cuboids[iCglob].getPhysR(physR, iX, iY, iZ);
296 for (int iDim = 0; iDim < 3; iDim++) {
297 if (_periodicityOn[iDim]) {
298 //std::cout << "!!! " << iDim << _periodicityOn[iDim] <<":"<< _motherCuboid.getDeltaR()*(_motherCuboid.getExtent()[iDim]) << std::endl;
299 physR[iDim] = remainder( physR[iDim] - _motherCuboid.getOrigin()[iDim]
300 + _motherCuboid.getDeltaR() * (_motherCuboid.getExtent()[iDim]),
301 _motherCuboid.getDeltaR() * (_motherCuboid.getExtent()[iDim]));
302 // solving the rounding error problem for double
303 if ( physR[iDim]*physR[iDim] < 0.001 * _motherCuboid.getDeltaR()*_motherCuboid.getDeltaR() ) {
304 physR[iDim] = T();
305 }
306 // make it to mod instead remainer
307 if ( physR[iDim] < 0 ) {
308 physR[iDim] += _motherCuboid.getDeltaR() *( _motherCuboid.getExtent()[iDim]);
309 }
310 // add origin
311 physR[iDim] += _motherCuboid.getOrigin()[iDim];
312 }
313 }
314 return;
315}
316
317template<typename T>
318void CuboidGeometry3D<T>::getPhysR(T physR[3], const int latticeR[4]) const
319{
320 getPhysR(physR, latticeR[0], latticeR[1], latticeR[2], latticeR[3]);
321}
322
323template<typename T>
324void CuboidGeometry3D<T>::getPhysR(T physR[3], LatticeR<4> latticeR) const
325{
326 getPhysR(physR, latticeR[0], latticeR[1], latticeR[2], latticeR[3]);
327}
328
329template<typename T>
330void CuboidGeometry3D<T>::getPhysR(T physR[3], const int iCglob, LatticeR<3> latticeR) const
331{
332 getPhysR(physR, iCglob, latticeR[0], latticeR[1], latticeR[2]);
333}
334
335template<typename T>
336void CuboidGeometry3D<T>::getNeighbourhood(int cuboid, std::vector<int>& neighbours, int overlap)
337{
338 neighbours.clear();
339
340 std::set<int> dummy;
341
342 for (int iC = 0; iC < getNc(); iC++) {
343 if (cuboid == iC) {
344 continue;
345 }
346 T globX = get(iC).getOrigin()[0];
347 T globY = get(iC).getOrigin()[1];
348 T globZ = get(iC).getOrigin()[2];
349 T nX = get(iC).getNx();
350 T nY = get(iC).getNy();
351 T nZ = get(iC).getNz();
352 T deltaR = get(iC).getDeltaR();
353 if (get(cuboid).checkInters(globX,
354 globX + (nX + overlap - 1)*deltaR,
355 globY - overlap * deltaR,
356 globY + (nY + overlap - 1)*deltaR,
357 globZ - overlap * deltaR,
358 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
359 //neighbours.push_back(iC);
360 dummy.insert(iC);
361 }
362
363 if (_periodicityOn[0]) {
364 if (get(cuboid).getOrigin()[0] + (get(cuboid).getNx() + overlap - 1)*get(cuboid).getDeltaR() > getMaxPhysR()[0]) {
365 Cuboid3D<T> cub(get(cuboid).getOrigin()[0]-getMaxPhysR()[0],
366 get(cuboid).getOrigin()[1],
367 get(cuboid).getOrigin()[2],
368 get(cuboid).getDeltaR(),
369 get(cuboid).getNx(),
370 get(cuboid).getNy(),
371 get(cuboid).getNz());
372 if (cub.checkInters(globX - overlap * deltaR,
373 globX + (nX + overlap - 1)*deltaR,
374 globY - overlap * deltaR,
375 globY + (nY + overlap - 1)*deltaR,
376 globZ - overlap * deltaR,
377 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
378 dummy.insert(iC);
379 }
380 }
381 if (get(cuboid).getOrigin()[0] - overlap*get(cuboid).getDeltaR() < getMinPhysR()[0]) {
382 Cuboid3D<T> cub(get(cuboid).getOrigin()[0]+getMaxPhysR()[0],
383 get(cuboid).getOrigin()[1],
384 get(cuboid).getOrigin()[2],
385 get(cuboid).getDeltaR(),
386 get(cuboid).getNx(),
387 get(cuboid).getNy(),
388 get(cuboid).getNz());
389 if (cub.checkInters(globX - overlap * deltaR,
390 globX + (nX + overlap - 1)*deltaR,
391 globY - overlap * deltaR,
392 globY + (nY + overlap - 1)*deltaR,
393 globZ - overlap * deltaR,
394 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
395 dummy.insert(iC);
396 }
397 }
398 }
399
400 if (_periodicityOn[1]) {
401 if (get(cuboid).getOrigin()[1] + (get(cuboid).getNy() + overlap - 1)*get(cuboid).getDeltaR() > getMaxPhysR()[1]) {
402 Cuboid3D<T> cub(get(cuboid).getOrigin()[0],
403 get(cuboid).getOrigin()[1]-getMaxPhysR()[1],
404 get(cuboid).getOrigin()[2],
405 get(cuboid).getDeltaR(),
406 get(cuboid).getNx(),
407 get(cuboid).getNy(),
408 get(cuboid).getNz());
409 if (cub.checkInters(globX - overlap * deltaR,
410 globX + (nX + overlap - 1)*deltaR,
411 globY - overlap * deltaR,
412 globY + (nY + overlap - 1)*deltaR,
413 globZ - overlap * deltaR,
414 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
415 dummy.insert(iC);
416 }
417 }
418 if (get(cuboid).getOrigin()[1] - overlap*get(cuboid).getDeltaR() < getMinPhysR()[1]) {
419 Cuboid3D<T> cub(get(cuboid).getOrigin()[0],
420 get(cuboid).getOrigin()[1]+getMaxPhysR()[1],
421 get(cuboid).getOrigin()[2],
422 get(cuboid).getDeltaR(),
423 get(cuboid).getNx(),
424 get(cuboid).getNy(),
425 get(cuboid).getNz());
426 if (cub.checkInters(globX - overlap * deltaR,
427 globX + (nX + overlap - 1)*deltaR,
428 globY - overlap * deltaR,
429 globY + (nY + overlap - 1)*deltaR,
430 globZ - overlap * deltaR,
431 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
432 dummy.insert(iC);
433 }
434 }
435 }
436
437 if (_periodicityOn[2]) {
438 if (get(cuboid).getOrigin()[2] + (get(cuboid).getNz() + overlap - 1)*get(cuboid).getDeltaR() > getMaxPhysR()[2]) {
439 Cuboid3D<T> cub(get(cuboid).getOrigin()[0],
440 get(cuboid).getOrigin()[1],
441 get(cuboid).getOrigin()[2]-getMaxPhysR()[2],
442 get(cuboid).getDeltaR(),
443 get(cuboid).getNx(),
444 get(cuboid).getNy(),
445 get(cuboid).getNz());
446 if (cub.checkInters(globX - overlap * deltaR,
447 globX + (nX + overlap - 1)*deltaR,
448 globY - overlap * deltaR,
449 globY + (nY + overlap - 1)*deltaR,
450 globZ - overlap * deltaR,
451 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
452 dummy.insert(iC);
453 }
454 }
455 if (get(cuboid).getOrigin()[2] - overlap*get(cuboid).getDeltaR() < getMinPhysR()[2]) {
456 Cuboid3D<T> cub(get(cuboid).getOrigin()[0],
457 get(cuboid).getOrigin()[1],
458 get(cuboid).getOrigin()[2]+getMaxPhysR()[2],
459 get(cuboid).getDeltaR(),
460 get(cuboid).getNx(),
461 get(cuboid).getNy(),
462 get(cuboid).getNz());
463 if (cub.checkInters(globX - overlap * deltaR,
464 globX + (nX + overlap - 1)*deltaR,
465 globY - overlap * deltaR,
466 globY + (nY + overlap - 1)*deltaR,
467 globZ - overlap * deltaR,
468 globZ + (nZ + overlap - 1)*deltaR, overlap)) {
469 dummy.insert(iC);
470 }
471 }
472 }
473
474 }
475 std::set<int>::iterator it = dummy.begin();
476 for (; it != dummy.end(); ++it) {
477 neighbours.push_back(*it);
478 }
479}
480
481template<typename T>
483{
484 return _cuboids.size();
485}
486
487template<typename T>
489{
490 T minRatio = 1.;
491 for (unsigned i = 0; i < _cuboids.size(); i++) {
492 if ((T)_cuboids[i].getNx() / (T)_cuboids[i].getNy() < minRatio) {
493 minRatio = (T)_cuboids[i].getNx() / (T)_cuboids[i].getNy();
494 }
495 if ((T)_cuboids[i].getNy() / (T)_cuboids[i].getNz() < minRatio) {
496 minRatio = (T)_cuboids[i].getNy() / (T)_cuboids[i].getNz();
497 }
498 if ((T)_cuboids[i].getNz() / (T)_cuboids[i].getNx() < minRatio) {
499 minRatio = (T)_cuboids[i].getNz() / (T)_cuboids[i].getNx();
500 }
501 }
502 return minRatio;
503}
504
505template<typename T>
507{
508 T maxRatio = 1.;
509 for (unsigned i = 0; i < _cuboids.size(); i++) {
510 if ((T)_cuboids[i].getNx() / (T)_cuboids[i].getNy() > maxRatio) {
511 maxRatio = (T)_cuboids[i].getNx() / (T)_cuboids[i].getNy();
512 }
513 if ((T)_cuboids[i].getNy() / (T)_cuboids[i].getNz() > maxRatio) {
514 maxRatio = (T)_cuboids[i].getNy() / (T)_cuboids[i].getNz();
515 }
516 if ((T)_cuboids[i].getNz() / (T)_cuboids[i].getNx() > maxRatio) {
517 maxRatio = (T)_cuboids[i].getNz() / (T)_cuboids[i].getNx();
518 }
519 }
520 return maxRatio;
521}
522
523template<typename T>
525{
526 Vector<T,3> output (_cuboids[0].getOrigin());
527 for (unsigned i = 0; i < _cuboids.size(); i++) {
528 if (_cuboids[i].getOrigin()[0] < output[0]) {
529 output[0] = _cuboids[i].getOrigin()[0];
530 }
531 if (_cuboids[i].getOrigin()[1] < output[1]) {
532 output[1] = _cuboids[i].getOrigin()[1];
533 }
534 if (_cuboids[i].getOrigin()[2] < output[2]) {
535 output[2] = _cuboids[i].getOrigin()[2];
536 }
537 }
538 return output;
539}
540
541template<typename T>
543{
544 Vector<T,3> output (_cuboids[0].getOrigin());
545 output[0] += _cuboids[0].getNx()*_cuboids[0].getDeltaR();
546 output[1] += _cuboids[0].getNy()*_cuboids[0].getDeltaR();
547 output[2] += _cuboids[0].getNz()*_cuboids[0].getDeltaR();
548 for (unsigned i = 0; i < _cuboids.size(); i++) {
549 if (_cuboids[i].getOrigin()[0] + _cuboids[i].getNx()*_cuboids[i].getDeltaR() > output[0]) {
550 output[0] = _cuboids[i].getOrigin()[0] + _cuboids[i].getNx()*_cuboids[i].getDeltaR();
551 }
552 if (_cuboids[i].getOrigin()[1] + _cuboids[i].getNy()*_cuboids[i].getDeltaR() > output[1]) {
553 output[1] = _cuboids[i].getOrigin()[1] + _cuboids[i].getNy()*_cuboids[i].getDeltaR();
554 }
555 if (_cuboids[i].getOrigin()[2] + _cuboids[i].getNz()*_cuboids[i].getDeltaR() > output[2]) {
556 output[2] = _cuboids[i].getOrigin()[2] + _cuboids[i].getNz()*_cuboids[i].getDeltaR();
557 }
558 }
559 return output;
560}
561
562template<typename T>
564{
565 T minVolume = _cuboids[0].getPhysVolume();
566 for (unsigned i = 0; i < _cuboids.size(); i++) {
567 if (_cuboids[i].getPhysVolume() < minVolume) {
568 minVolume = _cuboids[i].getPhysVolume();
569 }
570 }
571 return minVolume;
572}
573
574template<typename T>
576{
577 T maxVolume = _cuboids[0].getPhysVolume();
578 for (unsigned i = 0; i < _cuboids.size(); i++) {
579 if (_cuboids[i].getPhysVolume() > maxVolume) {
580 maxVolume = _cuboids[i].getPhysVolume();
581 }
582 }
583 return maxVolume;
584}
585
586template<typename T>
588{
589 size_t minNodes = _cuboids[0].getLatticeVolume();
590 for (unsigned i = 0; i < _cuboids.size(); i++) {
591 if (_cuboids[i].getLatticeVolume() < minNodes) {
592 minNodes = _cuboids[i].getLatticeVolume();
593 }
594 }
595 return minNodes;
596}
597
598template<typename T>
600{
601 size_t maxNodes = _cuboids[0].getLatticeVolume();
602 for (unsigned i = 0; i < _cuboids.size(); i++) {
603 if (_cuboids[i].getLatticeVolume() > maxNodes) {
604 maxNodes = _cuboids[i].getLatticeVolume();
605 }
606 }
607 return maxNodes;
608}
609
610template<typename T>
612{
613 size_t minNodes = _cuboids[0].getWeight();
614 for (unsigned i = 0; i < _cuboids.size(); i++) {
615 if (_cuboids[i].getWeight() < minNodes) {
616 minNodes = _cuboids[i].getWeight();
617 }
618 }
619 return minNodes;
620}
621
622template<typename T>
624{
625 size_t maxNodes = _cuboids[0].getWeight();
626 for (unsigned i = 0; i < _cuboids.size(); i++) {
627 if (_cuboids[i].getWeight() > maxNodes) {
628 maxNodes = _cuboids[i].getWeight();
629 }
630 }
631 return maxNodes;
632}
633
634template<typename T>
636{
637 T minDelta = _cuboids[0].getDeltaR();
638 for (unsigned i = 0; i < _cuboids.size(); i++) {
639 if (_cuboids[i].getDeltaR() < minDelta) {
640 minDelta = _cuboids[i].getDeltaR();
641 }
642 }
643 return minDelta;
644}
645
646template<typename T>
648{
649 T maxDelta = _cuboids[0].getDeltaR();
650 for (unsigned i = 0; i < _cuboids.size(); i++) {
651 if (_cuboids[i].getDeltaR() > maxDelta) {
652 maxDelta = _cuboids[i].getDeltaR();
653 }
654 }
655 return maxDelta;
656}
657
658
659template<typename T>
661{
662 return _motherCuboid == rhs._motherCuboid
663 && _periodicityOn == rhs._periodicityOn
664 && _cuboids == rhs._cuboids;
665}
666
667
668
669template<typename T>
671{
672
673 _cuboids.push_back(cuboid);
674}
675
676template<typename T>
678{
679
680 _cuboids.erase(_cuboids.begin() + iC);
681}
682
683
684template<typename T>
686{
687 std::vector<bool> allZero;
688 int latticeR[4];
689 T physR[3];
690 for (unsigned iC = 0; iC < _cuboids.size(); iC++) {
691 latticeR[0] = iC;
692 allZero.push_back(true);
693 for (int iX = 0; iX < _cuboids[iC].getNx(); iX++) {
694 for (int iY = 0; iY < _cuboids[iC].getNy(); iY++) {
695 for (int iZ = 0; iZ < _cuboids[iC].getNz(); iZ++) {
696 latticeR[1] = iX;
697 latticeR[2] = iY;
698 latticeR[3] = iZ;
699 getPhysR(physR,latticeR);
700 bool inside[1];
701 indicatorF(inside,physR);
702 if (inside[0]) {
703 allZero[iC] = 0;
704 }
705 }
706 }
707 }
708 }
709 for (int iC = _cuboids.size() - 1; iC >= 0; iC--) {
710 if (allZero[iC] ) {
711 remove(iC);
712 }
713 }
714}
715
716template<typename T>
718{
719 std::vector<bool> allZero(_cuboids.size(), false);
720 for (unsigned iC = 0; iC < _cuboids.size(); iC++) {
721 allZero[iC] = (_cuboids[iC].getWeight() == 0);
722 }
723 for (int iC = _cuboids.size() - 1; iC >= 0; iC--) {
724 if (allZero[iC]) {
725 remove(iC);
726 }
727 }
728}
729
730template<typename T>
732{
733 int latticeR[4];
734 T physR[3];
735 bool inside[1];
736
737 latticeR[0] = iC;
738 size_t fullCells = 0;
739 int xN = get(iC).getNx();
740 int yN = get(iC).getNy();
741 int zN = get(iC).getNz();
742 int maxX = 0;
743 int maxY = 0;
744 int maxZ = 0;
745 int newX = xN - 1;
746 int newY = yN - 1;
747 int newZ = zN - 1;
748 for (int iX = 0; iX < xN; iX++) {
749 for (int iY = 0; iY < yN; iY++) {
750 for (int iZ = 0; iZ < zN; iZ++) {
751 latticeR[1] = iX;
752 latticeR[2] = iY;
753 latticeR[3] = iZ;
754 getPhysR(physR,latticeR);
755 indicatorF(inside,physR);
756 if (inside[0]) {
757 fullCells++;
758 maxX = util::max(maxX, iX);
759 maxY = util::max(maxY, iY);
760 maxZ = util::max(maxZ, iZ);
761 newX = util::min(newX, iX);
762 newY = util::min(newY, iY);
763 newZ = util::min(newZ, iZ);
764 }
765 }
766 }
767 }
768 // if (maxX+2 < xN) maxX+=2; else if (maxX+1 < xN) maxX+=1;
769 // if (maxY+2 < yN) maxY+=2; else if (maxY+1 < yN) maxY+=1;
770 // if (maxZ+2 < zN) maxZ+=2; else if (maxZ+1 < zN) maxZ+=1;
771 //
772 // if (newX-2 >= 0) newX-=2; else if (newX-1 >= 0) newX-=1;
773 // if (newY-2 >= 0) newY-=2; else if (newY-1 >= 0) newY-=1;
774 // if (newZ-2 >= 0) newZ-=2; else if (newZ-1 >= 0) newZ-=1;
775
776 if (fullCells > 0) {
777 get(iC).setWeight(fullCells);
778 _cuboids[iC].resize(newX, newY, newZ, maxX - newX + 1, maxY - newY + 1, maxZ - newZ + 1);
779 }
780 else {
781 remove(iC);
782 }
783}
784
785template<typename T>
787{
788 for (int iC = getNc() - 1; iC >= 0; iC--) {
789 shrink(iC, indicatorF);
790 }
791 // shrink mother cuboid
792 Vector<T,3> minPhysR = getMinPhysR();
793 Vector<T,3> maxPhysR = getMaxPhysR();
794 T minDelataR = getMinDeltaR();
795 _motherCuboid = Cuboid3D<T>(minPhysR[0], minPhysR[1], minPhysR[2], minDelataR,
796 (int)((maxPhysR[0]-minPhysR[0])/minDelataR + 0.5),
797 (int)((maxPhysR[1]-minPhysR[1])/minDelataR + 0.5),
798 (int)((maxPhysR[2]-minPhysR[2])/minDelataR + 0.5));
799}
800
801template<typename T>
803{
804 _motherCuboid.refine(factor);
805 for (auto& cuboid : _cuboids) {
806 cuboid.refine(factor);
807 }
808}
809
810template<typename T>
812{
813 const T tolerance = std::numeric_limits<T>::epsilon();
814 const T currDeltaR = _motherCuboid.getDeltaR();
815 const int factor = std::ceil(currDeltaR / goalDeltaR);
816 if (util::fabs(currDeltaR / factor - goalDeltaR) < tolerance) {
817 refine(factor);
818 return true;
819 } else {
820 return false;
821 }
822}
823
824template<typename T>
825void CuboidGeometry3D<T>::split(int iC, int p)
826{
827 Cuboid3D<T> temp(_cuboids[iC].getOrigin()[0], _cuboids[iC].getOrigin()[1],
828 _cuboids[iC].getOrigin()[2], _cuboids[iC].getDeltaR(),
829 _cuboids[iC].getNx(), _cuboids[iC].getNy(), _cuboids[iC].getNz());
830 temp.divide(p, _cuboids);
831 remove(iC);
832}
833
834template<typename T>
836{
837 Cuboid3D<T> temp(_cuboids[iC].getOrigin()[0], _cuboids[iC].getOrigin()[1],
838 _cuboids[iC].getOrigin()[2], _cuboids[iC].getDeltaR(),
839 _cuboids[iC].getNx(), _cuboids[iC].getNy(), _cuboids[iC].getNz());
840 const int p = std::max(1, temp.getNx() / width);
841 const int q = std::max(1, temp.getNy() / width);
842 const int r = std::max(1, temp.getNz() / width);
843 temp.divide(p, q, r, _cuboids);
844 remove(iC);
845}
846
847template<typename T>
849{
850 T averageWeight = get(iC).getWeight() / (T) p;
851 // clout << "Mother " << get(iC).getWeight() << " " << averageWeight << std::endl;
852 Cuboid3D<T> temp(_cuboids[iC].getOrigin()[0], _cuboids[iC].getOrigin()[1],
853 _cuboids[iC].getOrigin()[2], _cuboids[iC].getDeltaR(),
854 _cuboids[iC].getNx(), _cuboids[iC].getNy(), _cuboids[iC].getNz());
855
856 int latticeR[4];
857 T physR[3];
858 latticeR[0] = iC;
859 int xN = get(iC).getNx();
860 int yN = get(iC).getNy();
861 int zN = get(iC).getNz();
862 T deltaR = get(iC).getDeltaR();
863 int fullCells = 0;
864
865 Vector<T, 3> globPos_child = get(iC).getOrigin();
866 std::vector<int> extend_child = {xN, yN, zN};
867 int localPos_child = 0;
868
869 // looking for largest extend, because halfing the cuboid by its largest extend will result in the smallest surface and therfore in the least comminication cells
870 if ( get(iC).getNx() >= get(iC).getNy() && get(iC).getNx() >= get(iC).getNz()) {
871 // clout << "Cut in x direction!" << std::endl;
872
873 // for each child cuboid search for the optimal cutting plane
874 for ( int iChild = 0; iChild < p - 1; iChild++) {
875 fullCells = 0;
876 int fullCells_minusOne = 0;
877
878 for (int iX = localPos_child; iX < xN; iX++) {
879 fullCells_minusOne = fullCells;
880 for (int iY = 0; iY < yN; iY++) {
881 for (int iZ = 0; iZ < zN; iZ++) {
882 latticeR[1] = iX;
883 latticeR[2] = iY;
884 latticeR[3] = iZ;
885 getPhysR(physR,latticeR);
886 bool inside[1];
887 indicatorF(inside,physR);
888 if (inside[0]) {
889 fullCells++;
890 }
891 }
892 }
893 // the optimal cutting plane is determined, so that the child cuboid's cells inside the indicator are the closest to the total cells inside the indicator per number of children
894 if ( fullCells >= averageWeight ) {
895 if ( (fullCells - averageWeight) > (averageWeight - fullCells_minusOne) ) {
896 iX--;
897 }
898 // clout << "found optimal iX = " << iX << std::endl;
899 extend_child[0] = iX - localPos_child + 1;
900
901 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
902 _cuboids.push_back(child);
903
904 globPos_child[0] += extend_child[0]*deltaR;
905 localPos_child += extend_child[0] + 1;
906 // clout << "added child " << iChild << " of " << p << std::endl;
907
908 break;
909 }
910 }
911
912 }
913
914 extend_child[0] = xN - localPos_child + p - 1;
915
916 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
917 _cuboids.push_back(child);
918
919 // clout << "added last child of " << p << std::endl;
920
921 }
922 else if ( get(iC).getNy() >= get(iC).getNx() && get(iC).getNy() >= get(iC).getNz()) {
923 // clout << "Cut in y direction!" << std::endl;
924
925 for ( int iChild = 0; iChild < p - 1; iChild++) {
926 fullCells = 0;
927 int fullCells_minusOne = 0;
928
929 for (int iY = localPos_child; iY < yN; iY++) {
930 fullCells_minusOne = fullCells;
931 for (int iX = 0; iX < xN; iX++) {
932 for (int iZ = 0; iZ < zN; iZ++) {
933 latticeR[1] = iX;
934 latticeR[2] = iY;
935 latticeR[3] = iZ;
936 getPhysR(physR,latticeR);
937 bool inside[1];
938 indicatorF(inside,physR);
939 if (inside[0]) {
940 fullCells++;
941 }
942 }
943 }
944 if ( fullCells >= averageWeight ) {
945 if ( (fullCells - averageWeight) > (averageWeight - fullCells_minusOne) ) {
946 iY--;
947 }
948 // clout << "found optimal iY = " << iY << std::endl;
949 extend_child[1] = iY - localPos_child + 1;
950
951 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
952 _cuboids.push_back(child);
953
954 globPos_child[1] += extend_child[1]*deltaR;
955 localPos_child += extend_child[1] + 1;
956 // clout << "added child " << iChild << " of " << p << std::endl;
957
958 break;
959 }
960 }
961
962 }
963
964 extend_child[1] = yN - localPos_child + p - 1;
965
966 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
967 _cuboids.push_back(child);
968
969 // clout << "added last child of " << p << std::endl;
970 }
971 else {
972 // clout << "Cut in z direction!" << std::endl;
973
974 for ( int iChild = 0; iChild < p - 1; iChild++) {
975 fullCells = 0;
976 int fullCells_minusOne = 0;
977
978 for (int iZ = localPos_child; iZ < zN; iZ++) {
979 fullCells_minusOne = fullCells;
980 for (int iY = 0; iY < yN; iY++) {
981 for (int iX = 0; iX < xN; iX++) {
982 latticeR[1] = iX;
983 latticeR[2] = iY;
984 latticeR[3] = iZ;
985 getPhysR(physR,latticeR);
986 bool inside[1];
987 indicatorF(inside,physR);
988 if (inside[0]) {
989 fullCells++;
990 }
991 }
992 }
993 if ( fullCells >= averageWeight ) {
994 if ( (fullCells - averageWeight) > (averageWeight - fullCells_minusOne) ) {
995 iZ--;
996 }
997 // clout << "found optimal iZ = " << iZ << std::endl;
998 extend_child[2] = iZ - localPos_child + 1;
999
1000 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
1001 _cuboids.push_back(child);
1002
1003 globPos_child[2] += extend_child[2]*deltaR;
1004 localPos_child += extend_child[2] + 1;
1005 // clout << "added child " << iChild << " of " << p << std::endl;
1006
1007 break;
1008 }
1009 }
1010
1011 }
1012
1013 extend_child[2] = zN - localPos_child + p - 1;
1014
1015 Cuboid3D<T> child(globPos_child[0], globPos_child[1], globPos_child[2], deltaR, extend_child[0], extend_child[1], extend_child[2]);
1016 _cuboids.push_back(child);
1017
1018 // clout << "added last child of " << p << std::endl;
1019 }
1020}
1021
1022template<typename T>
1023void CuboidGeometry3D<T>::splitFractional(int iC, int iD, std::vector<T> fractions)
1024{
1025 Cuboid3D<T> tmp = _cuboids[iC];
1026 tmp.divideFractional(iD, fractions, _cuboids);
1027 remove(iC);
1028}
1029
1030template<typename T>
1032{
1033 std::swap(this->_cuboids, rhs._cuboids);
1034 std::swap(this->_motherCuboid, rhs._motherCuboid);
1035 std::swap(this->_periodicityOn[0], rhs._periodicityOn[0]);
1036 std::swap(this->_periodicityOn[1], rhs._periodicityOn[1]);
1037 std::swap(this->_periodicityOn[2], rhs._periodicityOn[2]);
1038 std::swap(this->clout, rhs.clout);
1039}
1040
1041template<typename T>
1043{
1044 _cuboids.swap(cuboids);
1045}
1046
1047template<typename T>
1049{
1050 this->_cuboids.clear();
1051 for ( unsigned iC = 0; iC < cuboids.size(); iC++) {
1052 add(cuboids[iC]);
1053 }
1054}
1055
1056template<typename T>
1058{
1059 #ifdef PARALLEL_MODE_OMP
1060 #pragma omp parallel for schedule(dynamic,1)
1061 #endif
1062 for (int iC=0; iC < getNc(); ++iC) {
1063 int latticeR[4] { iC, 0, 0, 0 };
1064 T physR[3];
1065 int xN = get(iC).getNx();
1066 int yN = get(iC).getNy();
1067 int zN = get(iC).getNz();
1068 size_t fullCells = 0;
1069 for (int iX = 0; iX < xN; iX++) {
1070 for (int iY = 0; iY < yN; iY++) {
1071 for (int iZ = 0; iZ < zN; iZ++) {
1072 latticeR[1] = iX;
1073 latticeR[2] = iY;
1074 latticeR[3] = iZ;
1075 getPhysR(physR,latticeR);
1076 bool inside[1];
1077 indicatorF(inside,physR);
1078 if (inside[0]) {
1079 fullCells++;
1080 }
1081 }
1082 }
1083 }
1084 get(iC).setWeight(fullCells);
1085 }
1086}
1087
1088
1089template<typename T>
1091{
1092 return 1 // _periodicityOn
1093 + _motherCuboid.getNblock() // _motherCuboid
1094 + _cuboids.size() > 0 ? 1 + _cuboids.size() * _cuboids[0].getNblock() : 0; // _cuboids;
1095}
1096
1097
1098template<typename T>
1100{
1101 return 3 * sizeof(bool) // _periodicityOn
1102 + _motherCuboid.getSerializableSize() // _motherCuboid
1103 + (_cuboids.size() > 0 ?
1104 sizeof(size_t) + _cuboids.size() * _cuboids[0].getSerializableSize() :
1105 0); // _cuboids;
1106}
1107
1108template<typename T>
1109bool* CuboidGeometry3D<T>::getBlock(std::size_t iBlock, std::size_t& sizeBlock, bool loadingMode)
1110{
1111 std::size_t currentBlock = 0;
1112 size_t sizeBufferIndex = 0;
1113 bool* dataPtr = nullptr;
1114
1115 registerVar<bool> (iBlock, sizeBlock, currentBlock, dataPtr, _periodicityOn[0], 3);
1116 registerSerializableOfConstSize (iBlock, sizeBlock, currentBlock, dataPtr, _motherCuboid, loadingMode);
1117 registerStdVectorOfSerializablesOfConstSize (iBlock, sizeBlock, currentBlock, sizeBufferIndex, dataPtr,
1118 _cuboids, loadingMode);
1119
1120 return dataPtr;
1121}
1122
1123
1124template<typename T>
1126{
1127 clout << "---Cuboid Stucture Statistics---" << std::endl;
1128 clout << " Number of Cuboids: " << "\t" << getNc() << std::endl;
1129 clout << " Delta (min): " << "\t" << "\t" << getMinDeltaR() << std::endl;
1130 clout << " (max): " << "\t" << "\t" << getMaxDeltaR() << std::endl;
1131 clout << " Ratio (min): " << "\t" << "\t" << getMinRatio() << std::endl;
1132 clout << " (max): " << "\t" << "\t" << getMaxRatio() << std::endl;
1133 clout << " Nodes (min): " << "\t" << "\t" << getMinLatticeVolume() << std::endl;
1134 clout << " (max): " << "\t" << "\t" << getMaxLatticeVolume() << std::endl;
1135 clout << " Weight (min): " << "\t" << "\t" << getMinLatticeWeight() << std::endl;
1136 clout << " (max): " << "\t" << "\t" << getMaxLatticeWeight() << std::endl;
1137 clout << "--------------------------------" << std::endl;
1138}
1139
1140template<typename T>
1142{
1143 clout << "Mothercuboid :" << std::endl;
1144 getMotherCuboid().print();
1145
1146 for (int iC = 0; iC < getNc(); iC++) {
1147 clout << "Cuboid #" << iC << ": " << std::endl;
1148 get(iC).print();
1149 }
1150}
1151
1152template<typename T>
1153void CuboidGeometry3D<T>::writeToExistingFile(std::string completeFileName, LoadBalancer<T>& loadBalancer)
1154{
1155 std::ofstream fout;
1156 if ( singleton::mpi().isMainProcessor() ) {
1157
1158 // Open File
1159 fout.open(completeFileName.c_str(), std::ios::app);
1160 if (!fout) {
1161 clout << "Error: could not open " << completeFileName << std::endl;
1162 }
1163
1164 // --- Preamble --- //
1165 fout << "<CuboidGeometry dimension=\"3\" " << _cuboidParameters(getMotherCuboid()) << ">\n";
1166
1167 // TODO: Move Cuboid XML Serialization to Cuboid3D class
1168 for (int iC = 0; iC < getNc(); ++iC) {
1169 fout << "<Cuboid " << _cuboidParameters(get(iC)) << " />\n";
1170 }
1171
1172 fout << "</CuboidGeometry>\n";
1173
1174 // Close File
1175 fout.close();
1176 }
1177}
1178
1179
1180template<typename T>
1181void CuboidGeometry3D<T>::writeToFile(std::string fileName, LoadBalancer<T>& loadBalancer)
1182{
1183 std::string fname = singleton::directories().getLogOutDir() + fileName + ".xml";
1184 std::ofstream fout;
1185 if (singleton::mpi().isMainProcessor()) {
1186 fout.open(fname.c_str(), std::ios::trunc);
1187 fout << "<?xml version=\"1.0\"?>\n";
1188 fout << "<XMLContent>\n";
1189 fout.close();
1190 fout.clear();
1191 }
1192
1193 writeToExistingFile(fname, loadBalancer);
1194
1195 if (singleton::mpi().isMainProcessor()) {
1196 fout.open(fname.c_str(), std::ios::app);
1197 fout << "</XMLContent>\n";
1198 fout.close();
1199 }
1200}
1201
1202
1203// TODO: Move this method to Cuboid3D<T> class
1205template<typename T>
1207{
1208 std::stringstream ss;
1209 ss.flags(std::ios::scientific);
1210 ss.precision (std::numeric_limits<double>::digits10 + 1);
1211 ss << " extent=\"";
1212 for (int i = 0; i<3; i++) {
1213 ss << cub.getExtent()[i] << " ";
1214 }
1215
1216 ss << "\" origin=\"";
1217 for (int i = 0; i<3; i++) {
1218 ss << cub.getOrigin()[i] << " ";
1219 }
1220
1221 ss << "\" deltaR=\"" << cub.getDeltaR();
1222 ss << "\" weight=\"" << cub.getWeightValue();
1223 return ss.str();
1224}
1225
1226
1227} // namespace olb
1228
1229#endif
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
Definition cuboid3D.h:58
void divideFractional(int iD, std::vector< T > fractions, std::vector< Cuboid3D< T > > &childrenC) const
Divides the cuboid into fractions along the iDth dimension.
Definition cuboid3D.hh:530
Vector< T, 3 > getOrigin() const
Read only access to left lower corner coordinates.
Definition cuboid3D.hh:135
Vector< int, 3 > const getExtent() const
Read only access to the number of voxels in every dimension.
Definition cuboid3D.hh:165
int getWeightValue() const
Returns the actual value of weight (-1 for getLatticeVolume())
Definition cuboid3D.hh:177
bool checkInters(T globX0, T globX1, T globY0, T globY1, T globZ0, T globZ1, int overlap=0) const
Checks whether there is an intersection with the cuboid extended with an layer of size overlap*delta.
Definition cuboid3D.hh:409
T getDeltaR() const
Read only access to the distance of cuboid nodes.
Definition cuboid3D.hh:141
void divide(int p, int q, int r, std::vector< Cuboid3D< T > > &childrenC) const
Divides the cuboid in p*q*r cuboids of equal volume and add them to the given vector.
Definition cuboid3D.hh:488
int getNz() const
Read access to cuboid depth.
Definition cuboid3D.hh:159
int getNy() const
Read access to cuboid height.
Definition cuboid3D.hh:153
int getNx() const
Read access to cuboid width.
Definition cuboid3D.hh:147
A cuboid geometry represents a voxel mesh.
void splitByWeight(int iC, int p, IndicatorF3D< T > &indicatorF)
Splits cuboid iC, removes it and adds p cuboids of same weight.
T getMinRatio() const
Returns the minimum of the ratio nX/NY in the structure.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
void swap(CuboidGeometry3D< T > &rhs)
Swaps data from input into object.
size_t getSerializableSize() const override
Binary size for the serializer interface.
bool operator==(CuboidGeometry3D< T > &rhs)
Compares two CuboidGeometries.
T getMaxRatio() const
Returns the maximum of the ratio nX/NY in the structure.
void refine(int factor)
Refines mesh by splitting each cell into factor^3 cells.
bool getFloorLatticeR(const std::vector< T > &physR, std::vector< int > &latticeR) const
Returns true and the util::floor lattice position to the given physical position if the physical posi...
void writeToFile(std::string fileName, LoadBalancer< T > &loadBalancer)
Save CuboidGeometry into XML File.
void shrink(int iC, IndicatorF3D< T > &indicatorF)
Shrink cuboid iC so that no empty planes are left.
size_t getNblock() const override
Number of data blocks for the serializer interface.
void swapCuboids(std::vector< Cuboid3D< T > > &cuboids)
Swaps the vector of cuboids.
void replaceCuboids(std::vector< Cuboid3D< T > > &cuboids)
Replace the vector of cuboids.
int get_iC(T globX, T globY, T globZ, int offset=0) const
Gives for a given point (globX/globY/globZ) the related cuboidID and _p if the point is not in any of...
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Return a pointer to the memory of the current block and its size for the serializable interface.
T getMaxDeltaR() const
Returns the maximum delta in the structure.
void print() const
Prints cuboid geometry details.
bool getC(T physR[3], int &iC) const
Returns true and the cuboid number of the nearest lattice position to the given physical position if ...
void split(int iC, int p)
Splits cuboid iC, removes it and adds p cuboids of same volume.
bool tryRefineTo(T deltaR)
Tries to refine mesh to given deltaR.
Vector< T, 3 > getMinPhysR() const
Returns the minimum coordinate in the structure.
virtual ~CuboidGeometry3D()
Destructs CuboidGeometry.
size_t getMaxLatticeVolume() const
Returns the maximum number of nodes in the structure.
bool getLatticeR(int latticeR[4], const T physR[3]) const
Returns true and the nearest lattice position to the given physical position if the physical position...
void remove(int iC)
Removes the cuboid iC.
void writeToExistingFile(std::string completeFileName, LoadBalancer< T > &loadBalancer)
Save CuboidGeometry into an existing XML File.
T getMinPhysVolume() const
Returns the minimum volume in the structure.
int getNc() const
Returns the number of cuboids in the structure.
void setWeights(IndicatorF3D< T > &indicatorF)
Sets the number of full cells of each cuboid.
Vector< T, 3 > getMaxPhysR() const
Returns the maximum coordinate in the structure.
void splitRegular(int iC, int width)
Splits cuboid iC, removes it, adds approx. width^3 sized new cuboids.
Cuboid3D< T > getMotherCuboid()
Returns the smallest cuboid that includes all cuboids of the structure.
CuboidGeometry3D()
Constructs empty Geometry.
void add(Cuboid3D< T > cuboid)
Adds a cuboid.
size_t getMinLatticeVolume() const
Returns the minimum number of nodes in the structure.
void removeByWeight()
Removes all cuboids where weight = 0.
void printExtended()
Prints cuboid geometry details plus details of all cuboids.
size_t getMaxLatticeWeight() const
Returns the maximum number of nodes in the structure inside the indicator.
T getMinDeltaR() const
Returns the minimum delta in the structure.
size_t getMinLatticeWeight() const
Returns the minimum number of nodes in the structure inside the indicator.
void getPhysR(T physR[3], const int &iCglob, const int &iX, const int &iY, const int &iZ) const
Returns the physical position to the given lattice position respecting periodicity for the overlap no...
void splitFractional(int iC, int iD, std::vector< T > fractions)
Splits cuboid iC along dimension iD into cuboids of fractions.
T getMaxPhysVolume() const
Returns the maximum volume in the structure.
void getNeighbourhood(int cuboid, std::vector< int > &neighbours, int overlap=0)
Stores the iC of the neighbouring cuboids in a vector;.
void setPeriodicity(bool periodicityX, bool periodicityY, bool periodicityZ)
Set flag to enable/disable periodicity depending of direction. Be aware that not all directions are t...
IndicatorF3D is an application from .
Base class for all LoadBalancer.
Plain old scalar vector.
Definition vector.h:47
std::string getLogOutDir() const
Definition singleton.h:89
The description of a vector of 3D cuboid – header file.
MpiManager & mpi()
Directories & directories()
Definition singleton.h:150
ADf< T, DIM > floor(const ADf< T, DIM > &a)
Definition aDiff.h:869
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130
cpu::simd::Pack< T > fabs(cpu::simd::Pack< T > value)
Definition pack.h:106
Top level namespace for all of OpenLB.
void minimizeByVolume(CuboidGeometry3D< T > &cGeometry, IndicatorF3D< T > &indicatorF, int nC)
Splits into nC cuboids by-volume.
void minimizeByWeight(CuboidGeometry3D< T > &cGeometry, IndicatorF3D< T > &indicatorF, int nC)