From faac6e655914db0a8cd2c4beacb29b08d24f6bac Mon Sep 17 00:00:00 2001 From: Michael Kuron <m.kuron@gmx.de> Date: Mon, 12 Aug 2019 16:19:29 +0200 Subject: [PATCH] Provide block offsets to generated lattice models needed for RNG --- lbmpy_walberla/templates/LatticeModel.tmpl.cpp | 4 ++-- lbmpy_walberla/templates/LatticeModel.tmpl.h | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lbmpy_walberla/templates/LatticeModel.tmpl.cpp b/lbmpy_walberla/templates/LatticeModel.tmpl.cpp index 3db08c0..2b2065c 100644 --- a/lbmpy_walberla/templates/LatticeModel.tmpl.cpp +++ b/lbmpy_walberla/templates/LatticeModel.tmpl.cpp @@ -66,7 +66,7 @@ void {{class_name}}::Sweep::streamCollide( IBlock * block, const uint_t numberOf {{stream_collide_kernel|generate_block_data_to_field_extraction(parameters=['pdfs', 'pdfs_tmp'])|indent(4)}} auto & lm = dynamic_cast< lbm::PdfField<{{class_name}}> * > (pdfs)->latticeModel(); - lm.configureBlock(block); + WALBERLA_ASSERT_EQUAL( *(lm.blockId), block->getId() ); {{stream_collide_kernel|generate_refs_for_kernel_parameters(prefix='lm.', parameters_to_ignore=['pdfs', 'pdfs_tmp'])|indent(4) }} {{stream_collide_kernel|generate_call('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}} @@ -78,7 +78,7 @@ void {{class_name}}::Sweep::collide( IBlock * block, const uint_t numberOfGhostL {{collide_kernel|generate_block_data_to_field_extraction(parameters=['pdfs'])|indent(4)}} auto & lm = dynamic_cast< lbm::PdfField<{{class_name}}> * > (pdfs)->latticeModel(); - lm.configureBlock(block); + WALBERLA_ASSERT_EQUAL( *(lm.blockId), block->getId() ); {{collide_kernel|generate_refs_for_kernel_parameters(prefix='lm.', parameters_to_ignore=['pdfs', 'pdfs_tmp'])|indent(4) }} {{collide_kernel|generate_call('cell_idx_c(numberOfGhostLayersToInclude)')|indent(4)}} diff --git a/lbmpy_walberla/templates/LatticeModel.tmpl.h b/lbmpy_walberla/templates/LatticeModel.tmpl.h index e76e2dd..b5f2d37 100644 --- a/lbmpy_walberla/templates/LatticeModel.tmpl.h +++ b/lbmpy_walberla/templates/LatticeModel.tmpl.h @@ -57,6 +57,7 @@ #endif {% set lmIgnores = ('pdfs', 'pdfs_tmp') %} +{% set lmOffsets = ('block_offset_0', 'block_offset_1', 'block_offset_2') %} // Forward declarations @@ -121,19 +122,23 @@ public: {{stream_collide_kernel|generate_members(only_fields=True)|indent(8)}} }; - {{class_name}}( {{stream_collide_kernel|generate_constructor_parameters(lmIgnores) }} ) - : {{ stream_collide_kernel|generate_constructor_initializer_list(lmIgnores) }}, currentLevel(0) + {{class_name}}( {{stream_collide_kernel|generate_constructor_parameters(lmIgnores+lmOffsets) }} ) + : {{ stream_collide_kernel|generate_constructor_initializer_list(lmIgnores+lmOffsets) }}, currentLevel(0) {}; - void configure( IBlock & block, StructuredBlockStorage &) { configureBlock( &block ); } + void configure( IBlock & block, StructuredBlockStorage & storage ) { configureBlock( &block, &storage ); } // Parameters: {{stream_collide_kernel|generate_members(lmIgnores)|indent(4)}} private: - void configureBlock(IBlock * block) + void configureBlock(IBlock * block, StructuredBlockStorage * storage) { - {{stream_collide_kernel|generate_block_data_to_field_extraction(lmIgnores, no_declarations=True)|indent(8)}} + {{stream_collide_kernel|generate_block_data_to_field_extraction(lmIgnores+lmOffsets, no_declarations=True)|indent(8)}} + block_offset_0 = uint32_c(storage->getBlockCellBB(*block).xMin()); + block_offset_1 = uint32_c(storage->getBlockCellBB(*block).yMin()); + block_offset_2 = uint32_c(storage->getBlockCellBB(*block).zMin()); + blockId = &block->getId(); {% if refinement_scaling -%} const uint_t targetLevel = block->getBlockStorage().getLevel(*block); @@ -171,6 +176,7 @@ private: // Updated by configureBlock: {{stream_collide_kernel|generate_block_data_to_field_extraction(lmIgnores, declarations_only=True)|indent(4)}} + const IBlockID * blockId; uint_t currentLevel; // Backend classes can access private members: -- GitLab