diff --git a/src/lbm/boundary/ParserUBB.h b/src/lbm/boundary/ParserUBB.h index 98a616c9c035ab6f3df2f4c9dc2c2805a553f368..2ef68c194d80636f53a55567190aa62c17d9700b 100644 --- a/src/lbm/boundary/ParserUBB.h +++ b/src/lbm/boundary/ParserUBB.h @@ -98,6 +98,16 @@ public: Vector3< real_t > velocity_; }; // class Velocity + static bool isParser(const BoundaryConfiguration & config) { + auto parser = dynamic_cast< const Parser * >( &config ); + return parser != nullptr; + } + + static bool isVelocity(const BoundaryConfiguration & config) { + auto velocity = dynamic_cast< const Velocity * >( &config ); + return velocity != nullptr; + } + typedef GhostLayerField< shared_ptr<Parser>, 1 > ParserField; typedef GhostLayerField< Vector3<real_t>, 1 > VelocityField; @@ -356,16 +366,17 @@ template< typename LatticeModel_T, typename flag_t, bool AdaptVelocityToExternal inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, StoreForce >::registerCell( const flag_t, const cell_idx_t x, const cell_idx_t y, const cell_idx_t z, const BoundaryConfiguration & parser ) { - WALBERLA_ASSERT_EQUAL( dynamic_cast< const Parser * >( &parser ), &parser ); WALBERLA_ASSERT_NOT_NULLPTR( parserField_ ); - if( auto v = dynamic_cast< const Velocity * >( &parser ) ) + if( isVelocity(parser) ) { + auto v = dynamic_cast< const Velocity * >( &parser ); velocityField_->get( x, y, z ) = v->velocity(); parserField_->get( x, y, z ) = nullptr; return; } + WALBERLA_ASSERT( isParser(parser) ); auto & p = dynamic_cast< const Parser & >( parser ); if( p.isTimeDependent() ) @@ -387,11 +398,11 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, Sto template< typename LatticeModel_T, typename flag_t, bool AdaptVelocityToExternalForce, bool StoreForce > inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, StoreForce >::registerCells( const flag_t, const CellInterval & cells, const BoundaryConfiguration & parser ) { - WALBERLA_ASSERT_EQUAL( dynamic_cast< const Parser * >( &parser ), &parser ); WALBERLA_ASSERT_NOT_NULLPTR( parserField_ ); - if( auto v = dynamic_cast< const Velocity * >( &parser ) ) + if( isVelocity(parser) ) { + auto v = dynamic_cast< const Velocity * >( &parser ); for( auto cell = parserField_->beginSliceXYZ( cells ); cell != parserField_->end(); ++cell ) { velocityField_->get( cell.x(), cell.y(), cell.z() ) = v->velocity(); @@ -400,6 +411,7 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, Sto return; } + WALBERLA_ASSERT( isParser(parser) ); auto & p = dynamic_cast< const Parser & >( parser ); if( p.isTimeDependent() ) @@ -428,11 +440,11 @@ template< typename CellIterator > inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, StoreForce >::registerCells( const flag_t, const CellIterator & begin, const CellIterator & end, const BoundaryConfiguration & parser ) { - WALBERLA_ASSERT_EQUAL( dynamic_cast< const Parser * >( &parser ), &parser ); WALBERLA_ASSERT_NOT_NULLPTR( parserField_ ); - if( auto v = dynamic_cast< const Velocity * >( &parser ) ) + if( isVelocity(parser) ) { + auto v = dynamic_cast< const Velocity * >( &parser ); for( auto cell = begin; cell != end; ++cell ) { velocityField_->get( cell.x(), cell.y(), cell.z() ) = v->velocity(); @@ -441,6 +453,7 @@ inline void ParserUBB< LatticeModel_T, flag_t, AdaptVelocityToExternalForce, Sto return; } + WALBERLA_ASSERT( isParser(parser) ); auto & p = dynamic_cast< const Parser & >( parser ); if( p.isTimeDependent() ) diff --git a/src/lbm/boundary/factories/all.h b/src/lbm/boundary/factories/all.h index 58e1f6bedb312486d7967be21d65f79441297167..b30d024da7931729c3cf8c6ed8455e88f4c87944 100644 --- a/src/lbm/boundary/factories/all.h +++ b/src/lbm/boundary/factories/all.h @@ -24,4 +24,5 @@ #include "DefaultBoundaryHandling.h" #include "DefaultBoundaryHandlingCollection.h" -#include "DefaultDiffusionBoundaryHandling.h" \ No newline at end of file +#include "DefaultDiffusionBoundaryHandling.h" +#include "ExtendedBoundaryHandlingFactory.h"