diff --git a/src/pe_coupling/mapping/BodyBBMapping.cpp b/src/pe_coupling/mapping/BodyBBMapping.cpp index 393f8778159ec9f5903388181627e348449bb70a..c3726a574fd68c97b6dc5329311f6bb927e0fb77 100644 --- a/src/pe_coupling/mapping/BodyBBMapping.cpp +++ b/src/pe_coupling/mapping/BodyBBMapping.cpp @@ -39,9 +39,26 @@ CellInterval getCellBB( const pe::ConstBodyID body, const IBlock & block, Struct if( body->isFinite() ) { blockStorage.getCellBBFromAABB( cellBB, body->getAABB(), blockStorage.getLevel(block) ); - } else + } + else { - blockStorage.getCellBBFromAABB( cellBB, body->getAABB().getIntersection( blockStorage.getDomain() ), blockStorage.getLevel(block) ); + // if body is infinite (global), its AABB is also infinite which then requires special treatment + + auto level = blockStorage.getLevel(block); + const real_t dx = blockStorage.dx(level); + const real_t dy = blockStorage.dy(level); + const real_t dz = blockStorage.dz(level); + Vector3<real_t> aabbExtensionByGhostLayers(real_c(numberOfGhostLayersToInclude) * dx, + real_c(numberOfGhostLayersToInclude) * dy, + real_c(numberOfGhostLayersToInclude) * dz); + auto extendedBlockAABB = blockStorage.getAABB(block.getId()).getExtended( aabbExtensionByGhostLayers ); + + // intersect the infinte (global) body with the block AABB, extended by its ghost layers + // then determine the cell bounding box of the intersection + blockStorage.getCellBBFromAABB( cellBB, body->getAABB().getIntersection( extendedBlockAABB ), level ); + + // if infinte body does not intersect with the extended block AABB, return an empty interval + if( cellBB.empty() ) return CellInterval(); } cellBB.xMin() -= cell_idx_t(1); cellBB.yMin() -= cell_idx_t(1); cellBB.zMin() -= cell_idx_t(1); @@ -61,7 +78,5 @@ CellInterval getCellBB( const pe::ConstBodyID body, const IBlock & block, Struct return cellBB; } - - } // namespace pe_coupling } // namespace walberla diff --git a/src/pe_coupling/mapping/BodyMapping.h b/src/pe_coupling/mapping/BodyMapping.h index 3c689ebb25e5f2d68c21862f23b5ecc683e21dc0..2e70c14398937f9ccb4077daa43b0826fbc29b52 100644 --- a/src/pe_coupling/mapping/BodyMapping.h +++ b/src/pe_coupling/mapping/BodyMapping.h @@ -54,6 +54,8 @@ void mapBody( const pe::BodyID & body, IBlock & block, StructuredBlockStorage & CellInterval cellBB = getCellBB( body, block, blockStorage, flagField->nrOfGhostLayers() ); + if( cellBB.empty() ) return; + Vector3<real_t> startCellCenter = blockStorage.getBlockLocalCellCenter( block, cellBB.min() ); const real_t dx = blockStorage.dx( blockStorage.getLevel(block) ); const real_t dy = blockStorage.dy( blockStorage.getLevel(block) ); diff --git a/src/pe_coupling/momentum_exchange_method/BodyMapping.h b/src/pe_coupling/momentum_exchange_method/BodyMapping.h index 6149ec635d62420205e4231c67170280c3259ad7..77d5cf401ce455d5b936a77031214beb62a73d17 100644 --- a/src/pe_coupling/momentum_exchange_method/BodyMapping.h +++ b/src/pe_coupling/momentum_exchange_method/BodyMapping.h @@ -198,6 +198,8 @@ void mapMovingBody( const pe::BodyID body, IBlock & block, StructuredBlockStorag CellInterval cellBB = getCellBB( body, block, blockStorage, flagField->nrOfGhostLayers() ); + if( cellBB.empty() ) return; + Vector3<real_t> startCellCenter = blockStorage.getBlockLocalCellCenter( block, cellBB.min() ); const real_t dx = blockStorage.dx( blockStorage.getLevel(block) ); const real_t dy = blockStorage.dy( blockStorage.getLevel(block) );