From 9e2f51975447230a5b7d98b9843d3d1a1eb07e12 Mon Sep 17 00:00:00 2001 From: Christoph Rettinger <christoph.rettinger@fau.de> Date: Tue, 24 Oct 2017 16:00:28 +0200 Subject: [PATCH] pe_coupling: Fixed and added asserts and checks --- src/pe_coupling/mapping/BodyBBMapping.cpp | 9 ++++++--- .../restoration/ExtrapolationDirectionFinder.h | 4 ++-- .../restoration/PDFReconstruction.h | 2 +- .../momentum_exchange_method/restoration/Reconstructor.h | 6 +++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/pe_coupling/mapping/BodyBBMapping.cpp b/src/pe_coupling/mapping/BodyBBMapping.cpp index 9defb26ec..7cec1f1fd 100644 --- a/src/pe_coupling/mapping/BodyBBMapping.cpp +++ b/src/pe_coupling/mapping/BodyBBMapping.cpp @@ -31,9 +31,12 @@ namespace pe_coupling { CellInterval getCellBB( const pe::ConstBodyID body, const IBlock & block, const shared_ptr<StructuredBlockStorage> & blockStorage, const uint_t numberOfGhostLayersToInclude ) { + + WALBERLA_ASSERT_NOT_NULLPTR( body ); + CellInterval cellBB; - if (body->isFinite()) + if( body->isFinite() ) { blockStorage->getCellBBFromAABB( cellBB, body->getAABB(), blockStorage->getLevel(block) ); } else @@ -41,8 +44,8 @@ CellInterval getCellBB( const pe::ConstBodyID body, const IBlock & block, const blockStorage->getCellBBFromAABB( cellBB, body->getAABB().getIntersection( blockStorage->getDomain() ), blockStorage->getLevel(block) ); } - cellBB.xMin() -= cell_idx_c(1); cellBB.yMin() -= cell_idx_c(1); cellBB.zMin() -= cell_idx_c(1); - cellBB.xMax() += cell_idx_c(1); cellBB.yMax() += cell_idx_c(1); cellBB.zMax() += cell_idx_c(1); + cellBB.xMin() -= cell_idx_t(1); cellBB.yMin() -= cell_idx_t(1); cellBB.zMin() -= cell_idx_t(1); + cellBB.xMax() += cell_idx_t(1); cellBB.yMax() += cell_idx_t(1); cellBB.zMax() += cell_idx_t(1); CellInterval blockBB = blockStorage->getBlockCellBB( block ); diff --git a/src/pe_coupling/momentum_exchange_method/restoration/ExtrapolationDirectionFinder.h b/src/pe_coupling/momentum_exchange_method/restoration/ExtrapolationDirectionFinder.h index 65801c09b..e23d38be8 100644 --- a/src/pe_coupling/momentum_exchange_method/restoration/ExtrapolationDirectionFinder.h +++ b/src/pe_coupling/momentum_exchange_method/restoration/ExtrapolationDirectionFinder.h @@ -61,7 +61,7 @@ template < typename Stencil_T > void findCorrespondingLatticeDirection( const Vector3<real_t> & direction, Vector3<cell_idx_t> & correspondingLatticeDirection ) { stencil::Direction correspondingDirection = stencil::C; - real_t innerProduct = real_c(0); + real_t innerProduct = real_t(0); for( auto d = Stencil_T::beginNoCenter(); d != Stencil_T::end(); ++d ) { // compute inner product <dir,c_i> @@ -146,7 +146,7 @@ void SphereNormalExtrapolationDirectionFinder blockStorage_->getBlockLocalCellCenter( *block, Cell(x,y,z), cx, cy, cz ); Vector3<real_t> bodyCenterPosition = (*bodyField)(x,y,z)->getPosition(); - WALBERLA_ASSERT( !std::isnan(bodyCenterPosition[0]) && !std::isnan(bodyCenterPosition[1]) && !std::isnan(bodyCenterPosition[2]) ); + WALBERLA_ASSERT( !math::isnan(bodyCenterPosition) ); Vector3<real_t> bodyNormal( cx - bodyCenterPosition[0], cy - bodyCenterPosition[1], cz - bodyCenterPosition[2] ); diff --git a/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h b/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h index eb5e7b761..9d751bf33 100644 --- a/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h +++ b/src/pe_coupling/momentum_exchange_method/restoration/PDFReconstruction.h @@ -118,7 +118,7 @@ void PDFReconstruction< LatticeModel_T, BoundaryHandling_T, Reconstructer_T > // reconstruct all missing PDFs (only inside the domain) if( optimizeForSmallObstacleFraction_ ) { - const uint_t numberOfGhostLayersToInclude = uint_c(0); + const uint_t numberOfGhostLayersToInclude = uint_t(0); for( auto bodyIt = pe::BodyIterator::begin(*block, bodyStorageID_); bodyIt != pe::BodyIterator::end(); ++bodyIt ) { diff --git a/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h b/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h index 45e3dca3c..8acb17a1e 100644 --- a/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h +++ b/src/pe_coupling/momentum_exchange_method/restoration/Reconstructor.h @@ -275,8 +275,8 @@ public: ( blockStorage, boundaryHandlingID, pdfFieldID, bodyFieldID, extrapolationDirectionFinder ) ) { if( enforceNoSlipConstraintAfterExtrapolation_ ) { - WALBERLA_ASSERT((boost::is_same<typename LatticeModel_T::Stencil, stencil::D3Q19>::value), - "Enforcing no-slip constraint after extrapolation currently only works with D3Q19 stencil!") + WALBERLA_CHECK((boost::is_same<typename LatticeModel_T::Stencil, stencil::D3Q19>::value), + "Enforcing no-slip constraint after extrapolation currently only works with D3Q19 stencil!"); } } @@ -373,7 +373,6 @@ void ExtrapolationReconstructor< LatticeModel_T, BoundaryHandling_T, Extrapolati WALBERLA_ASSERT_NOT_NULLPTR( block ); PdfField_T * pdfField = block->getData< PdfField_T >( pdfFieldID_ ); - WALBERLA_ASSERT_NOT_NULLPTR( pdfField ); if( numberOfCellsForExtrapolation == uint_t(3) ) @@ -415,6 +414,7 @@ void ExtrapolationReconstructor< LatticeModel_T, BoundaryHandling_T, Extrapolati WALBERLA_ASSERT_NOT_NULLPTR( (*bodyField)(x,y,z) ); Vector3<real_t> bodyVelocity = (*bodyField)(x,y,z)->velFromWF(cx,cy,cz); + WALBERLA_ASSERT( !math::isnan(bodyVelocity) ); // transforms to moment space (see MRT collision model) to set the body's velocity in cell without affecting other moments const real_t _1_2 = real_t(1) / real_t(2); -- GitLab