Commit 7a623bf2 authored by Markus Holzer's avatar Markus Holzer
Browse files

Merge branch 'mr_fix_pdffield_initializer' into 'master'

PdfField Initializer Fix

Closes #185

See merge request walberla/walberla!540
parents 368ea2c8 47a79cba
...@@ -160,7 +160,7 @@ inline bool Cell::operator==( const Cell & rhs ) const ...@@ -160,7 +160,7 @@ inline bool Cell::operator==( const Cell & rhs ) const
**********************************************************************************************************************/ **********************************************************************************************************************/
inline cell_idx_t Cell::operator[]( std::size_t idx ) const inline cell_idx_t Cell::operator[]( std::size_t idx ) const
{ {
WALBERLA_ASSERT_LESS( idx, 3, "Index 'idx' = " << idx << " out of bounds! Cell: " << *this ); WALBERLA_ASSERT_LESS( idx, 3, "Index 'idx' = " << idx << " out of bounds! Cell: " << *this )
return cell[idx]; return cell[idx];
} }
...@@ -259,7 +259,7 @@ inline Cell Cell::operator-() const ...@@ -259,7 +259,7 @@ inline Cell Cell::operator-() const
**********************************************************************************************************************/ **********************************************************************************************************************/
inline cell_idx_t & Cell::operator[]( std::size_t idx ) inline cell_idx_t & Cell::operator[]( std::size_t idx )
{ {
WALBERLA_ASSERT_LESS( idx, 3, "Index 'idx' = " << idx << " out of bounds! Cell: " << *this ); WALBERLA_ASSERT_LESS( idx, 3, "Index 'idx' = " << idx << " out of bounds! Cell: " << *this )
return cell[idx]; return cell[idx];
} }
......
...@@ -146,11 +146,11 @@ public: ...@@ -146,11 +146,11 @@ public:
const CellIntervalIterator & operator--() { decrement(); return *this; } const CellIntervalIterator & operator--() { decrement(); return *this; }
CellIntervalIterator operator--(int) { CellIntervalIterator tmp = *this; decrement(); return tmp; } CellIntervalIterator operator--(int) { CellIntervalIterator tmp = *this; decrement(); return tmp; }
bool operator==(const CellIntervalIterator & other) const { WALBERLA_ASSERT_EQUAL( &ci_, &other.ci_ ); return cell_ == other.cell_; } bool operator==(const CellIntervalIterator & other) const { WALBERLA_ASSERT_EQUAL( &ci_, &other.ci_ ) return cell_ == other.cell_; }
bool operator!=(const CellIntervalIterator & other) const { WALBERLA_ASSERT_EQUAL( &ci_, &other.ci_ ); return cell_ != other.cell_; } bool operator!=(const CellIntervalIterator & other) const { WALBERLA_ASSERT_EQUAL( &ci_, &other.ci_ ) return cell_ != other.cell_; }
Cell operator*() const { WALBERLA_ASSERT( ci_.contains(cell_) ); return cell_; } Cell operator*() const { WALBERLA_ASSERT( ci_.contains(cell_) ) return cell_; }
const Cell * operator->() const { WALBERLA_ASSERT( ci_.contains(cell_) ); return &cell_; } const Cell * operator->() const { WALBERLA_ASSERT( ci_.contains(cell_) ) return &cell_; }
private: private:
inline void increment(); inline void increment();
...@@ -259,9 +259,9 @@ inline CellInterval& CellInterval::shift( const cell_idx_t x, const cell_idx_t y ...@@ -259,9 +259,9 @@ inline CellInterval& CellInterval::shift( const cell_idx_t x, const cell_idx_t y
inline CellInterval& CellInterval::shift( const uint_t x, const uint_t y, const uint_t z ) { inline CellInterval& CellInterval::shift( const uint_t x, const uint_t y, const uint_t z ) {
WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(x), 0 ); WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(x), 0 )
WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(y), 0 ); WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(y), 0 )
WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(z), 0 ); WALBERLA_ASSERT_GREATER_EQUAL( cell_idx_c(z), 0 )
min_.x() += cell_idx_c(x); min_.x() += cell_idx_c(x);
min_.y() += cell_idx_c(y); min_.y() += cell_idx_c(y);
......
...@@ -31,7 +31,7 @@ namespace cell { ...@@ -31,7 +31,7 @@ namespace cell {
/// Complexity is O(N), where N == this->size() /// Complexity is O(N), where N == this->size()
CellInterval CellSet::boundingBox() const { CellInterval CellSet::boundingBox() const {
WALBERLA_ASSERT( !empty() ); WALBERLA_ASSERT( !empty() )
Set<Cell>::const_iterator beginIt = Set<Cell>::begin(); Set<Cell>::const_iterator beginIt = Set<Cell>::begin();
Set<Cell>::const_iterator endIt = Set<Cell>::end(); Set<Cell>::const_iterator endIt = Set<Cell>::end();
......
...@@ -99,7 +99,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config ) ...@@ -99,7 +99,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{ {
WALBERLA_LOG_WARNING( "Error in expression for u_x\n" << WALBERLA_LOG_WARNING( "Error in expression for u_x\n" <<
"Error : " << parser.error() << "\n" << "Error : " << parser.error() << "\n" <<
"Expression: " << ux_expr_str ); "Expression: " << ux_expr_str )
valid = false; valid = false;
} }
...@@ -109,7 +109,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config ) ...@@ -109,7 +109,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{ {
WALBERLA_LOG_WARNING( "Error in expression for u_y\n" << WALBERLA_LOG_WARNING( "Error in expression for u_y\n" <<
"Error : " << parser.error() << "\n" << "Error : " << parser.error() << "\n" <<
"Expression: " << uy_expr_str ); "Expression: " << uy_expr_str )
valid = false; valid = false;
} }
...@@ -119,7 +119,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config ) ...@@ -119,7 +119,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{ {
WALBERLA_LOG_WARNING( "Error in expression for u_z\n" << WALBERLA_LOG_WARNING( "Error in expression for u_z\n" <<
"Error : " << parser.error() << "\n" << "Error : " << parser.error() << "\n" <<
"Expression: " << uz_expr_str ); "Expression: " << uz_expr_str )
valid = false; valid = false;
} }
...@@ -129,7 +129,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config ) ...@@ -129,7 +129,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{ {
WALBERLA_LOG_WARNING( "Error in expression for rho\n" << WALBERLA_LOG_WARNING( "Error in expression for rho\n" <<
"Error : " << parser.error() << "\n" << "Error : " << parser.error() << "\n" <<
"Expression: " << rho_expr_str ); "Expression: " << rho_expr_str )
valid = false; valid = false;
} }
......
...@@ -32,6 +32,9 @@ namespace walberla { ...@@ -32,6 +32,9 @@ namespace walberla {
namespace lbm { namespace lbm {
namespace initializer { namespace initializer {
template< bool UseCellCenter >
auto getCoordinates(const Cell& globalCell, const real_t dx);
template< typename LatticeModel_T > template< typename LatticeModel_T >
class PdfFieldInitializer class PdfFieldInitializer
......
...@@ -24,6 +24,27 @@ namespace walberla { ...@@ -24,6 +24,27 @@ namespace walberla {
namespace lbm { namespace lbm {
namespace initializer { namespace initializer {
template<>
auto getCoordinates<false>(const Cell& globalCell, const real_t dx) {
Cell coords;
for(uint_t d = 0; d < 3; ++d) {
coords[d] = cell_idx_c( real_c(globalCell[d]) * dx );
}
return coords;
}
template<>
auto getCoordinates<true>(const Cell& globalCell, const real_t dx) {
Vector3<real_t> coords;
for(uint_t d = 0; d < 3; ++d) {
coords[d] = (real_c(globalCell[d]) + 0.5_r) * dx ;
}
return coords;
}
template< typename LatticeModel_T > template< typename LatticeModel_T >
PdfFieldInitializer< LatticeModel_T >::PdfFieldInitializer( const BlockDataID & pdfFieldId, const shared_ptr<StructuredBlockForest> & blocks ) PdfFieldInitializer< LatticeModel_T >::PdfFieldInitializer( const BlockDataID & pdfFieldId, const shared_ptr<StructuredBlockForest> & blocks )
...@@ -34,18 +55,25 @@ template< typename LatticeModel_T > ...@@ -34,18 +55,25 @@ template< typename LatticeModel_T >
template< typename InitFunc > template< typename InitFunc >
void PdfFieldInitializer< LatticeModel_T >::initDensity( InitFunc & func ) const void PdfFieldInitializer< LatticeModel_T >::initDensity( InitFunc & func ) const
{ {
constexpr bool UseCellCenter = std::is_invocable_r_v<real_t, InitFunc, Vector3<real_t> const&>;
static_assert( UseCellCenter || std::is_invocable_r_v<real_t, InitFunc, Cell const&> );
for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt ) for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
{ {
auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ ); auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( pdfField ); WALBERLA_ASSERT_NOT_NULLPTR( pdfField )
const auto level = blocks_->getLevel(*blockIt);
const auto dx = blocks_->dx(level);
for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt ) for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt )
{ {
Cell globalCell( cellIt.cell() ); Cell globalCell( cellIt.cell() );
blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt ); blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt );
auto coords = getCoordinates<UseCellCenter>( globalCell, dx );
const Vector3<real_t> velocity = pdfField->getVelocity( cellIt.cell() ); const Vector3<real_t> velocity = pdfField->getVelocity( cellIt.cell() );
pdfField->setDensityAndVelocity( cellIt.cell(), velocity, func( globalCell ) ); pdfField->setDensityAndVelocity( cellIt.cell(), velocity, func(coords) );
} }
} }
} }
...@@ -55,18 +83,25 @@ template< typename LatticeModel_T > ...@@ -55,18 +83,25 @@ template< typename LatticeModel_T >
template< typename InitFunc > template< typename InitFunc >
void PdfFieldInitializer< LatticeModel_T >::initVelocity( InitFunc & func ) const void PdfFieldInitializer< LatticeModel_T >::initVelocity( InitFunc & func ) const
{ {
constexpr bool UseCellCenter = std::is_invocable_r_v<Vector3<real_t>, InitFunc, Vector3<real_t> const&>;
static_assert( UseCellCenter || std::is_invocable_r_v<Vector3<real_t>, InitFunc, Cell const&> );
for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt ) for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
{ {
auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ ); auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( pdfField ); WALBERLA_ASSERT_NOT_NULLPTR( pdfField )
const auto level = blocks_->getLevel(*blockIt);
const auto dx = blocks_->dx(level);
for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt ) for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt )
{ {
Cell globalCell( cellIt.cell() ); Cell globalCell( cellIt.cell() );
blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt ); blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt );
auto coords = getCoordinates<UseCellCenter>( globalCell, dx );
const real_t density = pdfField->getDensity( cellIt.cell() ); const real_t density = pdfField->getDensity( cellIt.cell() );
pdfField->setDensityAndVelocity( cellIt.cell(), func( globalCell ), density ); pdfField->setDensityAndVelocity( cellIt.cell(), func( coords ), density );
} }
} }
} }
...@@ -76,18 +111,25 @@ template< typename LatticeModel_T > ...@@ -76,18 +111,25 @@ template< typename LatticeModel_T >
template< typename InitFunc > template< typename InitFunc >
void PdfFieldInitializer< LatticeModel_T >::initDensityAndVelocity( InitFunc & func ) const void PdfFieldInitializer< LatticeModel_T >::initDensityAndVelocity( InitFunc & func ) const
{ {
constexpr bool UseCellCenter = std::is_invocable_r_v<std::vector<real_t>, InitFunc, Vector3<real_t> const&>;
static_assert( std::is_invocable_r_v<std::vector<real_t>, InitFunc, Cell const&> || UseCellCenter );
for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt ) for( auto blockIt = blocks_->begin(); blockIt != blocks_->end(); ++blockIt )
{ {
auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ ); auto pdfField = blockIt->template getData<PdfField_T>( pdfFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( pdfField ); WALBERLA_ASSERT_NOT_NULLPTR( pdfField )
const auto level = blocks_->getLevel(*blockIt);
const auto dx = blocks_->dx(level);
for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt ) for( auto cellIt = pdfField->beginWithGhostLayerXYZ(); cellIt != pdfField->end(); ++cellIt )
{ {
Cell globalCell( cellIt.cell() ); Cell globalCell( cellIt.cell() );
blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt ); blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt );
auto coords = getCoordinates<UseCellCenter>( globalCell, dx );
const std::vector<real_t> densityAndVelocity = func( globalCell );
WALBERLA_ASSERT_EQUAL( densityAndVelocity.size(), 4 ); const std::vector<real_t> densityAndVelocity = func( coords );
WALBERLA_ASSERT_EQUAL( densityAndVelocity.size(), 4 )
const real_t density( densityAndVelocity[0] ); const real_t density( densityAndVelocity[0] );
const Vector3<real_t> velocity( densityAndVelocity[1], densityAndVelocity[2], densityAndVelocity[3] ); const Vector3<real_t> velocity( densityAndVelocity[1], densityAndVelocity[2], densityAndVelocity[3] );
......
...@@ -77,7 +77,7 @@ void test() ...@@ -77,7 +77,7 @@ void test()
uint_t(14)); uint_t(14));
blockforest::BlockForestEvaluation evaluation(sbf->getBlockForest()); blockforest::BlockForestEvaluation evaluation(sbf->getBlockForest());
WALBERLA_LOG_INFO_ON_ROOT("BlockForest:\n" << evaluation.toString()); WALBERLA_LOG_INFO_ON_ROOT("BlockForest:\n" << evaluation.toString())
// auto originalFieldId = field::addToStorage< FieldType >( sbf, "OriginalField", 0.0, field::zyxf, uint_t(3), false, // auto originalFieldId = field::addToStorage< FieldType >( sbf, "OriginalField", 0.0, field::zyxf, uint_t(3), false,
// None, Empty ); // None, Empty );
...@@ -107,7 +107,7 @@ void test() ...@@ -107,7 +107,7 @@ void test()
auto readIt = readField->begin(); auto readIt = readField->begin();
for (auto origIt = originalField->begin(); origIt != originalField->end(); ++origIt, ++readIt) for (auto origIt = originalField->begin(); origIt != originalField->end(); ++origIt, ++readIt)
WALBERLA_CHECK_IDENTICAL(*origIt, *readIt); WALBERLA_CHECK_IDENTICAL(*origIt, *readIt)
} }
} }
......
...@@ -261,19 +261,19 @@ static void test() { ...@@ -261,19 +261,19 @@ static void test() {
for( uint_t i = 0; i != size; ++i ) for( uint_t i = 0; i != size; ++i )
{ {
const real_t recv = byteArrayToReal< real_t >( buffer, i * ( sizeof(real_t) + 3 ) ); const real_t recv = byteArrayToReal< real_t >( buffer, i * ( sizeof(real_t) + 3 ) );
WALBERLA_CHECK( realIsIdentical( recv, send[i] ) ); WALBERLA_CHECK( realIsIdentical( recv, send[i] ) )
} }
} }
WALBERLA_MPI_WORLD_BARRIER(); WALBERLA_MPI_WORLD_BARRIER()
BlockForest bforest( uint_c( MPIManager::instance()->rank() ), sforest, true ); BlockForest bforest( uint_c( MPIManager::instance()->rank() ), sforest, true );
BlockForest fforest_1( uint_c( MPIManager::instance()->rank() ), "blockforest.sav", false, true ); // all processes read the same file BlockForest fforest_1( uint_c( MPIManager::instance()->rank() ), "blockforest.sav", false, true ); // all processes read the same file
WALBERLA_CHECK_EQUAL( bforest, fforest_1 ); WALBERLA_CHECK_EQUAL( bforest, fforest_1 )
BlockForest fforest_2( uint_c( MPIManager::instance()->rank() ), "blockforest.sav", true, true ); // only the root process reads the file BlockForest fforest_2( uint_c( MPIManager::instance()->rank() ), "blockforest.sav", true, true ); // only the root process reads the file
WALBERLA_CHECK_EQUAL( bforest, fforest_2 ); WALBERLA_CHECK_EQUAL( bforest, fforest_2 )
SUID level1( "Level_1" ); SUID level1( "Level_1" );
SUID level2( "Level_2" ); SUID level2( "Level_2" );
...@@ -295,154 +295,154 @@ static void test() { ...@@ -295,154 +295,154 @@ static void test() {
if( block->getLevel() == 0 ) { if( block->getLevel() == 0 ) {
WALBERLA_CHECK( block->getState().empty() ); WALBERLA_CHECK( block->getState().empty() )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) ); WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) ); WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) ); WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) ); WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataOfType<int>( data2 ) ); WALBERLA_CHECK( !block->isDataOfType<int>( data2 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) ); WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<BlockDataID>( data2 ) ); WALBERLA_CHECK( !block->isDataClassOrSubclassOf<BlockDataID>( data2 ) )
} }
else if( block->getLevel() == 1 ) { else if( block->getLevel() == 1 ) {
WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) ); WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) ); WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) ); WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) ); WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) ); WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataOfType<SUID>( data2 ) ); WALBERLA_CHECK( !block->isDataOfType<SUID>( data2 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) ); WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<double>( data2 ) ); WALBERLA_CHECK( !block->isDataClassOrSubclassOf<double>( data2 ) )
} }
else if( block->getLevel() == 2 ) { else if( block->getLevel() == 2 ) {
WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) ); WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) ); WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data2 ) ); WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) ); WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data2 ) ); WALBERLA_CHECK( !block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
} }
else if( block->getLevel() == 3 ) { else if( block->getLevel() == 3 ) {
WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) ); WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data1 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data1 )), uint_c(23) ); WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data1 )), uint_c(23) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) ); WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) )
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfSameType( data1, data2 ) ); WALBERLA_CHECK( block->isDataOfSameType( data1, data2 ) )
} }
else if( block->getLevel() == 4 ) { else if( block->getLevel() == 4 ) {
WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) ); WALBERLA_CHECK_EQUAL( block->getState().size(), uint_c(1) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< int >( data1 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< int >( data1 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< int >( data1 )), uint_c(42) ); WALBERLA_CHECK_EQUAL( *(block->getData< int >( data1 )), uint_c(42) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) ); WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) ); WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) )
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) ); WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( !block->isDataOfSameType( data1, data2 ) ); WALBERLA_CHECK( !block->isDataOfSameType( data1, data2 ) )
const Base* base = block->getData< Base >( data3 ); const Base* base = block->getData< Base >( data3 );
WALBERLA_CHECK_EQUAL( base->override(), 1 ); WALBERLA_CHECK_EQUAL( base->override(), 1 )
WALBERLA_CHECK_EQUAL( base->func(), 2 ); WALBERLA_CHECK_EQUAL( base->func(), 2 )
WALBERLA_CHECK( block->isDataOfType<Base>( data3 ) ); WALBERLA_CHECK( block->isDataOfType<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataOfType<Derived>( data3 ) ); WALBERLA_CHECK( !block->isDataOfType<Derived>( data3 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data3 ) ); WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data3 ) ); WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data3 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data3 ) ); WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Base>( data3 ) ); WALBERLA_CHECK( !block->isDataSubclassOf<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data3 ) ); WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<int>( data3 ) ); WALBERLA_CHECK( !block->isDataSubclassOf<int>( data3 ) )
base = block->getData< Base >( data4 ); base = block->getData< Base >( data4 );
const Derived* derived = block->getData< Derived >( data4 ); const Derived* derived = block->getData< Derived >( data4 );
WALBERLA_CHECK_EQUAL( base->override(), 1 ); WALBERLA_CHECK_EQUAL( base->override(), 1 )
WALBERLA_CHECK_EQUAL( base->func(), 20 ); WALBERLA_CHECK_EQUAL( base->func(), 20 )
WALBERLA_CHECK_EQUAL( derived->override(), 10 ); WALBERLA_CHECK_EQUAL( derived->override(), 10 )