BlockForestInitialization.cpp 19.1 KB
Newer Older
Christian Godenschwager's avatar
Christian Godenschwager committed
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
//======================================================================================================================
//
//  This file is part of waLBerla. waLBerla 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 3 of
//  the License, or (at your option) any later version.
//
//  waLBerla 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 waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file BlockForestInitialization.cpp
//! \ingroup mesh
//! \author Christian Godenschwager <christian.godenschwager@fau.de>
//
//======================================================================================================================

#include "BlockForestInitialization.h"

#include "blockforest/Initialization.h"
#include "blockforest/loadbalancing/StaticCurve.h"
#include "blockforest/loadbalancing/StaticParMetis.h"

#include "waLBerlaDefinitions.h"

#include "core/math/IntegerFactorization.h"
#include "core/math/Primes.h"

#include <map>

namespace walberla {
namespace mesh {

static inline uint_t uintAbsDiff( const uint_t x, const uint_t y )
{
   return x > y ? x - y : y - x;
}

43
44
45
46
47
48
49
50
51
52
static inline void compareAABB( const AABB & oldAABB, const AABB & newAABB )
{
   if(oldAABB != newAABB)
   {
      WALBERLA_LOG_INFO_ON_ROOT( "Domain AABB has been adapted to requested block size:\n" \
                                 "Old AABB: " << oldAABB   << "\n" \
                                 "New AABB: " << newAABB << "\n" )
   }
}

Christian Godenschwager's avatar
Christian Godenschwager committed
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
ComplexGeometryBlockforestCreator::ComplexGeometryBlockforestCreator( const AABB & aabb, const blockforest::SetupBlockForest::RootBlockExclusionFunction & rootBlockExclusionFunction )
   : aabb_(aabb), maxIterations_(25), acceptableRelativeError_( real_t(0.1) ), maxBlockSkewness_(2.0),
     processMemoryLimit_( real_t( 0.0 ) ), periodicity_( false, false, false ), rootBlockExclusionFunction_ ( rootBlockExclusionFunction ),
     workloadMemorySUIDAssignmentFunction_( blockforest::uniformWorkloadAndMemoryAssignment ),
#ifdef WALBERLA_BUILD_WITH_PARMETIS
     targetProcessAssignmentFunction_( blockforest::StaticLevelwiseParMetis() )
#else
     targetProcessAssignmentFunction_( blockforest::StaticLevelwiseCurveBalanceWeighted() )
#endif

{
}

shared_ptr<SetupBlockForest> ComplexGeometryBlockforestCreator::createSetupBlockForest( const uint_t targetNumRootBlocks, const uint_t numProcesses ) const
{
   std::set< uint_t > blockGridSizeTested;

   uint_t sizeBlockGrid = targetNumRootBlocks * uint_t(2);

   uint_t          bestSizeBlockGrid = sizeBlockGrid;
   uint_t          bestNumRootBlocks = std::numeric_limits<uint_t>::max();
   Vector3<uint_t> bestSizeBlockGrid3D( std::numeric_limits<uint_t>::max(), std::numeric_limits<uint_t>::max(), std::numeric_limits<uint_t>::max() );

   enum Dir { UP, DOWN };

   Dir dir = UP;

   uint_t i = 0;
   while( i < maxIterations_ )
   {
      while( blockGridSizeTested.find( sizeBlockGrid ) != blockGridSizeTested.end() )
      {
         switch(dir)
         {
         case UP:   ++sizeBlockGrid; break;
         case DOWN: --sizeBlockGrid; break;
         }

         if( sizeBlockGrid == uint_t(0) )
         {
            sizeBlockGrid = uint_t(1);
            dir = UP;
         }
      }

      const Vector3<uint_t> sizeBlockGrid3D = math::getFactors3D( sizeBlockGrid, aabb_.sizes() );

      if( maxBlockSkewness_ * real_c(sizeBlockGrid3D.min() ) < real_c( sizeBlockGrid3D.max() ) )
      {
         blockGridSizeTested.insert( sizeBlockGrid );
         continue;
      }

      const uint_t numRootBlocks = findNumBlocks( sizeBlockGrid3D );

      blockGridSizeTested.insert( sizeBlockGrid );

      if( uintAbsDiff( numRootBlocks, targetNumRootBlocks ) < uintAbsDiff( bestNumRootBlocks, targetNumRootBlocks ) )
      {
         bestNumRootBlocks   = numRootBlocks;
         bestSizeBlockGrid   = sizeBlockGrid;
         bestSizeBlockGrid3D = sizeBlockGrid3D;
      }

      const real_t factor = real_c( numRootBlocks ) / real_c( targetNumRootBlocks );

      if( std::fabs( factor - real_t(1) ) < acceptableRelativeError_ )
      {
         break;
      }
      if( numRootBlocks < targetNumRootBlocks )
      {
         sizeBlockGrid = uint_c( real_c( sizeBlockGrid ) / factor + real_t(0.5) );
         dir = UP;
      }
      else if( numRootBlocks > targetNumRootBlocks )
      {
         sizeBlockGrid = uint_c( real_c( sizeBlockGrid ) / factor + real_t(0.5) );
         dir = DOWN;
      }
      else
      {
         break;
      }

      ++i;
   }

141
   WALBERLA_LOG_INFO_ON_ROOT( "Using a block grid of size " << bestSizeBlockGrid3D << " (" << bestSizeBlockGrid << ") resulting in " << bestNumRootBlocks << " root blocks." )
Christian Godenschwager's avatar
Christian Godenschwager committed
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

   auto setupBlockForest = make_shared<SetupBlockForest>();
   setupBlockForest->addRootBlockExclusionFunction( rootBlockExclusionFunction_ );
   setupBlockForest->addWorkloadMemorySUIDAssignmentFunction( workloadMemorySUIDAssignmentFunction_ );

   setupBlockForest->init( aabb_, bestSizeBlockGrid3D[0], bestSizeBlockGrid3D[1], bestSizeBlockGrid3D[2], periodicity_[0], periodicity_[1], periodicity_[2] );

   setupBlockForest->balanceLoad( targetProcessAssignmentFunction_, numProcesses, uint_t(0), processMemoryLimit_, true, false );

   return setupBlockForest;
}



 shared_ptr<SetupBlockForest> ComplexGeometryBlockforestCreator::createSetupBlockForest( const Vector3<real_t> & blockSize, const uint_t numProcesses ) const
{
   Vector3<uint_t> numBlocks;

   for( uint_t i = uint_t(0); i < uint_t(3); ++i )
      numBlocks[i] = uint_c( std::ceil( aabb_.size( i ) / blockSize[i] ) );

   AABB newAABB( real_t(0), real_t(0), real_t(0),
                 real_c( numBlocks[0] ) * blockSize[0], real_c( numBlocks[1] ) * blockSize[1], real_c( numBlocks[2] ) * blockSize[2] );

   newAABB.translate( aabb_.center() - newAABB.center() );
167
   compareAABB(aabb_, newAABB);
Christian Godenschwager's avatar
Christian Godenschwager committed
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

   auto setupBlockForest = make_shared<SetupBlockForest>();
   setupBlockForest->addRootBlockExclusionFunction( rootBlockExclusionFunction_ );
   setupBlockForest->addWorkloadMemorySUIDAssignmentFunction( workloadMemorySUIDAssignmentFunction_ );

   setupBlockForest->init( newAABB, numBlocks[0], numBlocks[1], numBlocks[2], periodicity_[0], periodicity_[1], periodicity_[2] );

   setupBlockForest->balanceLoad( targetProcessAssignmentFunction_, numProcesses, uint_t(0), processMemoryLimit_, true, false );

   return setupBlockForest;
}

shared_ptr<BlockForest> ComplexGeometryBlockforestCreator::createBlockForest( const uint_t targetNumRootBlocks ) const
{
   shared_ptr< blockforest::SetupBlockForest> setupBlockForest = createSetupBlockForest( targetNumRootBlocks );

   auto blockForest = make_shared< blockforest::BlockForest >( MPIManager::instance()->rank(), *setupBlockForest );

   return blockForest;
}

shared_ptr<BlockForest> ComplexGeometryBlockforestCreator::createBlockForest( const Vector3<real_t> & blockSize ) const
{
   shared_ptr< blockforest::SetupBlockForest> setupBlockForest = createSetupBlockForest( blockSize );

   auto blockForest = make_shared< blockforest::BlockForest >( MPIManager::instance()->rank(), *setupBlockForest );

   return blockForest;
}

uint_t ComplexGeometryBlockforestCreator::findNumBlocks( const Vector3<uint_t> & numRootBlocks3D ) const
{
200
   WALBERLA_LOG_DEVEL_ON_ROOT( "Testing block grid " << numRootBlocks3D )
Christian Godenschwager's avatar
Christian Godenschwager committed
201
202
203
204
205
206

   SetupBlockForest setupBlockForest;
   setupBlockForest.addRootBlockExclusionFunction( rootBlockExclusionFunction_ );

   setupBlockForest.init( aabb_, numRootBlocks3D[0], numRootBlocks3D[1], numRootBlocks3D[2], periodicity_[0], periodicity_[1], periodicity_[2] );

207
   WALBERLA_LOG_DEVEL_ON_ROOT( "Testing block grid " << numRootBlocks3D << " resulted in " << setupBlockForest.getNumberOfBlocks() )
Christian Godenschwager's avatar
Christian Godenschwager committed
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

   return uint_c( setupBlockForest.getNumberOfBlocks() );

}















ComplexGeometryStructuredBlockforestCreator::ComplexGeometryStructuredBlockforestCreator( const AABB & aabb, const Vector3<real_t> & cellSize, const blockforest::SetupBlockForest::RootBlockExclusionFunction & rootBlockExclusionFunction )
   : aabb_(aabb), cellSize_( cellSize ), maxIterations_(25), acceptableRelativeError_( real_t(0.1) ),
     processMemoryLimit_( real_t( 0.0 ) ), periodicity_( false, false, false ),
     rootBlockExclusionFunction_ ( rootBlockExclusionFunction ),
     workloadMemorySUIDAssignmentFunction_( blockforest::uniformWorkloadAndMemoryAssignment ),
#ifdef WALBERLA_BUILD_WITH_PARMETIS
     targetProcessAssignmentFunction_( blockforest::StaticLevelwiseParMetis() )
#else
     targetProcessAssignmentFunction_( blockforest::StaticLevelwiseCurveBalanceWeighted() )
#endif
{
}


shared_ptr<SetupBlockForest> ComplexGeometryStructuredBlockforestCreator::createSetupBlockForest( const uint_t targetNumRootBlocks, const uint_t numProcesses ) const
{

   Vector3<uint_t> numCells = domainSizeCells();
   real_t domainVolume = real_c( numCells[0] ) * real_c( numCells[1] ) * real_c( numCells[2] );

   std::set< uint_t > blockSizeTested;

   uint_t blockSize = uint_c( std::pow( domainVolume / ( real_t(2) * real_t( targetNumRootBlocks ) ), real_t(1) / real_t(3) ) + 0.5 );

   uint_t          bestBlockSize = blockSize;
   uint_t          bestNumRootBlocks = std::numeric_limits<uint_t>::max();

   enum Dir { UP, DOWN };

   Dir dir = UP;

   uint_t i = 0;
   while( i < maxIterations_ )
   {
      while( blockSizeTested.find( blockSize ) != blockSizeTested.end() )
      {
         switch(dir)
         {
         case UP:   ++blockSize; break;
         case DOWN: --blockSize; break;
         }

         if( blockSize == uint_t(0) )
         {
            blockSize = uint_t(1);
            dir = UP;
         }
      }

      const uint_t numRootBlocks = findNumBlocks( Vector3<uint_t>( blockSize, blockSize, blockSize ) );

      blockSizeTested.insert( blockSize );

      if( uintAbsDiff( numRootBlocks, targetNumRootBlocks ) < uintAbsDiff( bestNumRootBlocks, targetNumRootBlocks ) )
      {
         bestNumRootBlocks   = numRootBlocks;
         bestBlockSize       = blockSize;
      }

      const real_t factor = real_c( numRootBlocks ) / real_c( targetNumRootBlocks );

      if( std::fabs( factor - real_t(1) ) < acceptableRelativeError_ )
      {
         break;
      }
      if( numRootBlocks < targetNumRootBlocks )
      {
         blockSize = uint_c( real_c( blockSize ) * std::pow( factor, real_t(1) / real_t(3) ) + real_t(0.5) );
         dir = UP;
      }
      else if( numRootBlocks > targetNumRootBlocks )
      {
         blockSize = uint_c( real_c( blockSize ) * std::pow( factor, real_t(1) / real_t(3) ) + real_t(0.5) );
         dir = DOWN;
      }
      else
      {
         break;
      }

      ++i;
   }

310
   WALBERLA_LOG_INFO_ON_ROOT( "Using a block of size " << bestBlockSize << " resulting in " << bestNumRootBlocks << " root blocks." )
Christian Godenschwager's avatar
Christian Godenschwager committed
311
312
313
314
315
316
317
318
319
320
321

   Vector3<uint_t> numBlocks( uint_c( std::ceil( real_c( numCells[0] ) / real_c( bestBlockSize ) ) ),
                              uint_c( std::ceil( real_c( numCells[1] ) / real_c( bestBlockSize ) ) ),
                              uint_c( std::ceil( real_c( numCells[2] ) / real_c( bestBlockSize ) ) ) );

   AABB newAABB( real_t(0), real_t(0), real_t(0),
                 real_c( numBlocks[0] * bestBlockSize ) * cellSize_[0],
                 real_c( numBlocks[1] * bestBlockSize ) * cellSize_[1],
                 real_c( numBlocks[2] * bestBlockSize ) * cellSize_[2] );

   newAABB.translate( aabb_.center() - newAABB.center() );
322
   compareAABB(aabb_, newAABB);
Christian Godenschwager's avatar
Christian Godenschwager committed
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353

   auto setupBlockForest = make_shared<SetupBlockForest>();
   setupBlockForest->addRootBlockExclusionFunction( rootBlockExclusionFunction_ );
   setupBlockForest->addWorkloadMemorySUIDAssignmentFunction( workloadMemorySUIDAssignmentFunction_ );

   if( refinementSelectionFunction_ )
      setupBlockForest->addRefinementSelectionFunction( refinementSelectionFunction_ );

   setupBlockForest->init( newAABB, numBlocks[0], numBlocks[1], numBlocks[2], periodicity_[0], periodicity_[1], periodicity_[2] );

   setupBlockForest->balanceLoad( targetProcessAssignmentFunction_, numProcesses, uint_t(0), processMemoryLimit_, true, false );

   return setupBlockForest;
}



shared_ptr<SetupBlockForest> ComplexGeometryStructuredBlockforestCreator::createSetupBlockForest( const Vector3<uint_t> & blockSize, const uint_t numProcesses ) const
{
   Vector3<uint_t> numCells = domainSizeCells();

   Vector3<uint_t> numBlocks( uint_c( std::ceil( real_c( numCells[0] ) / real_c( blockSize[0] ) ) ),
                              uint_c( std::ceil( real_c( numCells[1] ) / real_c( blockSize[1] ) ) ),
                              uint_c( std::ceil( real_c( numCells[2] ) / real_c( blockSize[2] ) ) ) );

   AABB newAABB( real_t(0), real_t(0), real_t(0),
                 real_c( numBlocks[0] * blockSize[0] ) * cellSize_[0],
                 real_c( numBlocks[1] * blockSize[1] ) * cellSize_[1],
                 real_c( numBlocks[2] * blockSize[2] ) * cellSize_[2] );

   newAABB.translate( aabb_.center() - newAABB.center() );
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
   compareAABB(aabb_, newAABB);

   auto setupBlockForest = make_shared<SetupBlockForest>();
   setupBlockForest->addRootBlockExclusionFunction( rootBlockExclusionFunction_ );
   setupBlockForest->addWorkloadMemorySUIDAssignmentFunction( workloadMemorySUIDAssignmentFunction_ );

   if( refinementSelectionFunction_ )
      setupBlockForest->addRefinementSelectionFunction( refinementSelectionFunction_ );

   setupBlockForest->init( newAABB, numBlocks[0], numBlocks[1], numBlocks[2], periodicity_[0], periodicity_[1], periodicity_[2] );

   setupBlockForest->balanceLoad( targetProcessAssignmentFunction_, numProcesses, uint_t(0), processMemoryLimit_, true, false );

   return setupBlockForest;
}

shared_ptr<SetupBlockForest> ComplexGeometryStructuredBlockforestCreator::createSetupBlockForest( const Vector3<uint_t> & cellsPerBlock, const Vector3<uint_t> & numBlocks ) const
{
   uint_t numProcesses = numBlocks[0] * numBlocks[1] * numBlocks[2];

Christian Godenschwager's avatar
Christian Godenschwager committed
374

375
376
377
378
379
   AABB newAABB(real_t(0), real_t(0), real_t(0), real_c(numBlocks[0] * cellsPerBlock[0]) * cellSize_[0],
                real_c(numBlocks[1] * cellsPerBlock[1]) * cellSize_[1], real_c(numBlocks[2] * cellsPerBlock[2]) * cellSize_[2]);

   newAABB.translate( aabb_.center() - newAABB.center() );
   compareAABB(aabb_, newAABB);
Christian Godenschwager's avatar
Christian Godenschwager committed
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

   auto setupBlockForest = make_shared<SetupBlockForest>();
   setupBlockForest->addRootBlockExclusionFunction( rootBlockExclusionFunction_ );
   setupBlockForest->addWorkloadMemorySUIDAssignmentFunction( workloadMemorySUIDAssignmentFunction_ );

   if( refinementSelectionFunction_ )
      setupBlockForest->addRefinementSelectionFunction( refinementSelectionFunction_ );

   setupBlockForest->init( newAABB, numBlocks[0], numBlocks[1], numBlocks[2], periodicity_[0], periodicity_[1], periodicity_[2] );

   setupBlockForest->balanceLoad( targetProcessAssignmentFunction_, numProcesses, uint_t(0), processMemoryLimit_, true, false );

   return setupBlockForest;
}

shared_ptr<StructuredBlockForest> ComplexGeometryStructuredBlockforestCreator::createStructuredBlockForest( const uint_t targetNumRootBlocks ) const
{
   shared_ptr< blockforest::SetupBlockForest> setupBlockForest = createSetupBlockForest( targetNumRootBlocks );

   Vector3< real_t > blockSize( setupBlockForest->getRootBlockXSize(),
                                setupBlockForest->getRootBlockYSize(),
                                setupBlockForest->getRootBlockZSize() );

   Vector3<uint_t> blockSizeCells( uint_c( blockSize[0] / cellSize_[0] + real_t(0.5) ), uint_c( blockSize[1] / cellSize_[1] + real_t(0.5) ), uint_c( blockSize[2] / cellSize_[2] + real_t(0.5) ) );

405
406
407
   WALBERLA_ASSERT_FLOAT_EQUAL( blockSize[0] / cellSize_[0], real_c( blockSizeCells[0] ) )
   WALBERLA_ASSERT_FLOAT_EQUAL( blockSize[1] / cellSize_[1], real_c( blockSizeCells[1] ) )
   WALBERLA_ASSERT_FLOAT_EQUAL( blockSize[2] / cellSize_[2], real_c( blockSizeCells[2] ) )
Christian Godenschwager's avatar
Christian Godenschwager committed
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430

   auto blockForest = make_shared< blockforest::BlockForest >( MPIManager::instance()->rank(), *setupBlockForest );

   auto structuredBlockForest = make_shared< blockforest::StructuredBlockForest >( blockForest, blockSizeCells[0], blockSizeCells[1], blockSizeCells[2] );

   structuredBlockForest->createCellBoundingBoxes();

   return structuredBlockForest;
}

shared_ptr<StructuredBlockForest> ComplexGeometryStructuredBlockforestCreator::createStructuredBlockForest( const Vector3<uint_t> & blockSize ) const
{
   shared_ptr< blockforest::SetupBlockForest> setupBlockForest = createSetupBlockForest( blockSize );

   auto blockForest = make_shared< blockforest::BlockForest >( MPIManager::instance()->rank(), *setupBlockForest );

   auto structuredBlockForest = make_shared< blockforest::StructuredBlockForest >( blockForest, blockSize[0], blockSize[1], blockSize[2] );

   structuredBlockForest->createCellBoundingBoxes();

   return structuredBlockForest;
}

431
432
433
434
435
436
437
438
439
440
441
442
443
shared_ptr<StructuredBlockForest> ComplexGeometryStructuredBlockforestCreator::createStructuredBlockForest( const Vector3<uint_t> & cellsPerBlock, const Vector3<uint_t> & numBlocks ) const
{
   shared_ptr< blockforest::SetupBlockForest> setupBlockForest = createSetupBlockForest( cellsPerBlock, numBlocks );

   auto blockForest = make_shared< blockforest::BlockForest >( MPIManager::instance()->rank(), *setupBlockForest );

   auto structuredBlockForest = make_shared< blockforest::StructuredBlockForest >( blockForest, cellsPerBlock[0], cellsPerBlock[1], cellsPerBlock[2] );

   structuredBlockForest->createCellBoundingBoxes();

   return structuredBlockForest;
}

Christian Godenschwager's avatar
Christian Godenschwager committed
444
445
uint_t ComplexGeometryStructuredBlockforestCreator::findNumBlocks( const Vector3<uint_t> & blockSize ) const
{
446
   WALBERLA_LOG_DEVEL_ON_ROOT( "Testing block size " << blockSize )
Christian Godenschwager's avatar
Christian Godenschwager committed
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471

   Vector3<uint_t> numCells( uint_c( std::ceil( aabb_.xSize() / cellSize_[0] ) ),
                             uint_c( std::ceil( aabb_.ySize() / cellSize_[1] ) ),
                             uint_c( std::ceil( aabb_.zSize() / cellSize_[2] ) ) );

   Vector3<uint_t> numBlocks( uint_c( std::ceil( real_c( numCells[0] ) / real_c( blockSize[0] ) ) ),
                              uint_c( std::ceil( real_c( numCells[1] ) / real_c( blockSize[1] ) ) ),
                              uint_c( std::ceil( real_c( numCells[2] ) / real_c( blockSize[2] ) ) ) );

   AABB newAABB( real_t(0), real_t(0), real_t(0),
                 real_c( numBlocks[0] * blockSize[0] ) * cellSize_[0],
                 real_c( numBlocks[1] * blockSize[1] ) * cellSize_[1],
                 real_c( numBlocks[2] * blockSize[2] ) * cellSize_[2] );

   newAABB.translate( aabb_.center() - newAABB.center() );


   SetupBlockForest setupBlockForest;
   setupBlockForest.addRootBlockExclusionFunction( rootBlockExclusionFunction_ );

   if( refinementSelectionFunction_ )
      setupBlockForest.addRefinementSelectionFunction( refinementSelectionFunction_ );

   setupBlockForest.init( newAABB, numBlocks[0], numBlocks[1], numBlocks[2], periodicity_[0], periodicity_[1], periodicity_[2] );

472
   WALBERLA_LOG_DEVEL_ON_ROOT( "Testing block size " << blockSize << " resulted in " << setupBlockForest.getNumberOfBlocks() )
Christian Godenschwager's avatar
Christian Godenschwager committed
473
474
475
476
477
478
479

   return setupBlockForest.getNumberOfBlocks();

}

} // namespace mesh
} // namespace walberla