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
**********************************************************************************************************************/
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];
}
......@@ -259,7 +259,7 @@ inline Cell Cell::operator-() const
**********************************************************************************************************************/
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];
}
......
......@@ -146,11 +146,11 @@ public:
const CellIntervalIterator & operator--() { decrement(); return *this; }
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_; }
const 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_; }
private:
inline void increment();
......@@ -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 ) {
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(z), 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(z), 0 )
min_.x() += cell_idx_c(x);
min_.y() += cell_idx_c(y);
......
......@@ -31,7 +31,7 @@ namespace cell {
/// Complexity is O(N), where N == this->size()
CellInterval CellSet::boundingBox() const {
WALBERLA_ASSERT( !empty() );
WALBERLA_ASSERT( !empty() )
Set<Cell>::const_iterator beginIt = Set<Cell>::begin();
Set<Cell>::const_iterator endIt = Set<Cell>::end();
......
......@@ -99,7 +99,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{
WALBERLA_LOG_WARNING( "Error in expression for u_x\n" <<
"Error : " << parser.error() << "\n" <<
"Expression: " << ux_expr_str );
"Expression: " << ux_expr_str )
valid = false;
}
......@@ -109,7 +109,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{
WALBERLA_LOG_WARNING( "Error in expression for u_y\n" <<
"Error : " << parser.error() << "\n" <<
"Expression: " << uy_expr_str );
"Expression: " << uy_expr_str )
valid = false;
}
......@@ -119,7 +119,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{
WALBERLA_LOG_WARNING( "Error in expression for u_z\n" <<
"Error : " << parser.error() << "\n" <<
"Expression: " << uz_expr_str );
"Expression: " << uz_expr_str )
valid = false;
}
......@@ -129,7 +129,7 @@ bool ExprSystemInitFunction::parse( const Config::BlockHandle & config )
{
WALBERLA_LOG_WARNING( "Error in expression for rho\n" <<
"Error : " << parser.error() << "\n" <<
"Expression: " << rho_expr_str );
"Expression: " << rho_expr_str )
valid = false;
}
......
......@@ -32,6 +32,9 @@ namespace walberla {
namespace lbm {
namespace initializer {
template< bool UseCellCenter >
auto getCoordinates(const Cell& globalCell, const real_t dx);
template< typename LatticeModel_T >
class PdfFieldInitializer
......
......@@ -24,6 +24,27 @@ namespace walberla {
namespace lbm {
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 >
PdfFieldInitializer< LatticeModel_T >::PdfFieldInitializer( const BlockDataID & pdfFieldId, const shared_ptr<StructuredBlockForest> & blocks )
......@@ -34,18 +55,25 @@ template< typename LatticeModel_T >
template< typename InitFunc >
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 )
{
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 )
{
Cell globalCell( cellIt.cell() );
blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt );
auto coords = getCoordinates<UseCellCenter>( globalCell, dx );
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 >
template< typename InitFunc >
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 )
{
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 )
{
Cell globalCell( cellIt.cell() );
blocks_->transformBlockLocalToGlobalCell( globalCell, *blockIt );
auto coords = getCoordinates<UseCellCenter>( globalCell, dx );
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 >
template< typename InitFunc >
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 )
{
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 )
{
Cell globalCell( cellIt.cell() );
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 Vector3<real_t> velocity( densityAndVelocity[1], densityAndVelocity[2], densityAndVelocity[3] );
......
......@@ -77,7 +77,7 @@ void test()
uint_t(14));
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,
// None, Empty );
......@@ -107,7 +107,7 @@ void test()
auto readIt = readField->begin();
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() {
for( uint_t i = 0; i != size; ++i )
{
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 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
WALBERLA_CHECK_EQUAL( bforest, fforest_2 );
WALBERLA_CHECK_EQUAL( bforest, fforest_2 )
SUID level1( "Level_1" );
SUID level2( "Level_2" );
......@@ -295,154 +295,154 @@ static void test() {
if( block->getLevel() == 0 ) {
WALBERLA_CHECK( block->getState().empty() );
WALBERLA_CHECK( block->getState().empty() )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) );
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) );
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) );
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) );
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) );
WALBERLA_CHECK( !block->isDataOfType<int>( data2 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<BlockDataID>( data2 ) );
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataOfType<int>( data2 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<BlockDataID>( data2 ) )
}
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_NOT_NULLPTR( block->getData< uint_t >( data2 ) );
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) );
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c(5) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) );
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) );
WALBERLA_CHECK( !block->isDataOfType<SUID>( data2 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<double>( data2 ) );
WALBERLA_CHECK( block->isDataOfType<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataOfType<SUID>( data2 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<uint_t>( data2 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<double>( data2 ) )
}
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 >( data2 ) );
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) );
WALBERLA_CHECK( !block->isBlockDataAllocated( data2 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) );
WALBERLA_CHECK( !block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( !block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
}
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_EQUAL( *(block->getData< uint_t >( data1 )), uint_c(23) );
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) );
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) );
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data1 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data1 )), uint_c(23) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) )
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( block->isDataOfSameType( data1, data2 ) );
WALBERLA_CHECK( block->isDataOfSameType( data1, data2 ) )
}
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_EQUAL( *(block->getData< int >( data1 )), uint_c(42) );
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) );
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) );
WALBERLA_CHECK_NOT_NULLPTR( block->getData< int >( data1 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< int >( data1 )), uint_c(42) )
WALBERLA_CHECK_NOT_NULLPTR( block->getData< uint_t >( data2 ) )
WALBERLA_CHECK_EQUAL( *(block->getData< uint_t >( data2 )), uint_c( 5) )
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) );
WALBERLA_CHECK( block->isBlockDataAllocated( data1 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data2 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data3 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data4 ) )
WALBERLA_CHECK( block->isBlockDataAllocated( data5 ) )
WALBERLA_CHECK( !block->isDataOfSameType( data1, data2 ) );
WALBERLA_CHECK( !block->isDataOfSameType( data1, data2 ) )
const Base* base = block->getData< Base >( data3 );
WALBERLA_CHECK_EQUAL( base->override(), 1 );
WALBERLA_CHECK_EQUAL( base->func(), 2 );
WALBERLA_CHECK_EQUAL( base->override(), 1 )
WALBERLA_CHECK_EQUAL( base->func(), 2 )
WALBERLA_CHECK( block->isDataOfType<Base>( data3 ) );
WALBERLA_CHECK( !block->isDataOfType<Derived>( data3 ) );
WALBERLA_CHECK( block->isDataOfType<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataOfType<Derived>( data3 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data3 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data3 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data3 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data3 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Base>( data3 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data3 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<int>( data3 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<Base>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data3 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<int>( data3 ) )
base = block->getData< Base >( data4 );
const Derived* derived = block->getData< Derived >( data4 );
WALBERLA_CHECK_EQUAL( base->override(), 1 );
WALBERLA_CHECK_EQUAL( base->func(), 20 );
WALBERLA_CHECK_EQUAL( base->override(), 1 )
WALBERLA_CHECK_EQUAL( base->func(), 20 )
WALBERLA_CHECK_EQUAL( derived->override(), 10 );
WALBERLA_CHECK_EQUAL( derived->func(), 20 );
WALBERLA_CHECK_EQUAL( derived->override(), 10 )
WALBERLA_CHECK_EQUAL( derived->func(), 20 )
WALBERLA_CHECK( !block->isDataOfType<Base>( data4 ) );
WALBERLA_CHECK( block->isDataOfType<Derived>( data4 ) );
WALBERLA_CHECK( !block->isDataOfType<Base>( data4 ) )
WALBERLA_CHECK( block->isDataOfType<Derived>( data4 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data4 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Derived>( data4 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data4 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data4 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Derived>( data4 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<int>( data4 ) )
WALBERLA_CHECK( block->isDataSubclassOf<Base>( data4 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data4 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<int>( data4 ) );
WALBERLA_CHECK( block->isDataSubclassOf<Base>( data4 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data4 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<int>( data4 ) )
base = block->getData< Base >( data5 );
const SecondBase* sBase = block->getData< SecondBase >( data5 );
const Multi* multi = block->getData< Multi >( data5 );
WALBERLA_CHECK( reinterpret_cast< const void* >( base ) != reinterpret_cast< const void* >( sBase ) ) ;
WALBERLA_CHECK( reinterpret_cast< const void* >( base ) != reinterpret_cast< const void* >( sBase ) )
WALBERLA_CHECK( ( reinterpret_cast< const void* >( base ) != reinterpret_cast< const void* >( multi ) ) ||
( reinterpret_cast< const void* >( sBase ) != reinterpret_cast< const void* >( multi ) ) );
( reinterpret_cast< const void* >( sBase ) != reinterpret_cast< const void* >( multi ) ) )
WALBERLA_CHECK_EQUAL( base->override(), 1 );
WALBERLA_CHECK_EQUAL( base->func(), 2000 );
WALBERLA_CHECK_EQUAL( base->override(), 1 )
WALBERLA_CHECK_EQUAL( base->func(), 2000 )
WALBERLA_CHECK_EQUAL( sBase->override(), 100 );
WALBERLA_CHECK_EQUAL( sBase->override(), 100 )
WALBERLA_CHECK_EQUAL( multi->override(), 1000 );
WALBERLA_CHECK_EQUAL( multi->func(), 2000 );
WALBERLA_CHECK_EQUAL( multi->override(), 1000 )
WALBERLA_CHECK_EQUAL( multi->func(), 2000 )
WALBERLA_CHECK( !block->isDataOfType<Base>( data5 ) );
WALBERLA_CHECK( !block->isDataOfType<SecondBase>( data5 ) );
WALBERLA_CHECK( block->isDataOfType<Multi>( data5 ) );
WALBERLA_CHECK( !block->isDataOfType<Base>( data5 ) )
WALBERLA_CHECK( !block->isDataOfType<SecondBase>( data5 ) )
WALBERLA_CHECK( block->isDataOfType<Multi>( data5 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data5 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<SecondBase>( data5 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Multi>( data5 ) );
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data5 ) );
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Base>( data5 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<SecondBase>( data5 ) )
WALBERLA_CHECK( block->isDataClassOrSubclassOf<Multi>( data5 ) )
WALBERLA_CHECK( !block->isDataClassOrSubclassOf<Derived>( data5 ) )
WALBERLA_CHECK( block->isDataSubclassOf<Base>( data5 ) );
WALBERLA_CHECK( block->isDataSubclassOf<SecondBase>( data5 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<Multi>( data5 ) );
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data5 ) );
WALBERLA_CHECK( block->isDataSubclassOf<Base>( data5 ) )
WALBERLA_CHECK( block->isDataSubclassOf<SecondBase>( data5 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Multi>( data5 ) )
WALBERLA_CHECK( !block->isDataSubclassOf<Derived>( data5 ) )
}
}
......@@ -453,17 +453,17 @@ static void test() {
std::set< BlockID > forestBlockSet;
for( auto block = sforest.begin(); block != sforest.end(); ++block ) {
WALBERLA_CHECK_EQUAL( setupBlockSet.find( block->getId() ), setupBlockSet.end() );
WALBERLA_CHECK_EQUAL( setupBlockSet.find( block->getId() ), setupBlockSet.end() )
setupBlockSet.insert( block->getId() );
}
for( auto blockId = blockIds.begin(); blockId != blockIds.end(); ++blockId ) {
const BlockID id = *dynamic_cast< BlockID* >( blockId->get() );
WALBERLA_CHECK_EQUAL( forestBlockSet.find( id ), forestBlockSet.end() );
WALBERLA_CHECK_EQUAL( forestBlockSet.find( id ), forestBlockSet.end() )
forestBlockSet.insert( id );
}
WALBERLA_CHECK_EQUAL( setupBlockSet, forestBlockSet );
WALBERLA_CHECK_EQUAL( setupBlockSet, forestBlockSet )
}
......
......@@ -26,7 +26,6 @@
#include "core/mpi/SendBuffer.h"
#include <cstdlib>
#include <cstring>
#include <map>
#include <vector>
......@@ -69,26 +68,26 @@ static void test() {
walberla::mpi::GenericSendBuffer<uint8_t> sb;
oldId.toBuffer( sb );
WALBERLA_CHECK_EQUAL( (oldId.getUsedBytes() + oldId.getUsedBytes() * mpi::BUFFER_DEBUG_OVERHEAD) + (1 + mpi::BUFFER_DEBUG_OVERHEAD ), sb.size() );
WALBERLA_CHECK_EQUAL( (oldId.getUsedBytes() + oldId.getUsedBytes() * mpi::BUFFER_DEBUG_OVERHEAD) + (1 + mpi::BUFFER_DEBUG_OVERHEAD ), sb.size() )
for( uint_t b = branches; b-- != 0; ) {
WALBERLA_CHECK_EQUAL( id.getBranchId(), branch[b] );
WALBERLA_CHECK_EQUAL( id.getBranchId(), branch[b] )
id.removeBranchId();
}
WALBERLA_CHECK_EQUAL( id.getTreeIndex(), treeIndex );
WALBERLA_CHECK_EQUAL( id.getTreeIndex(), treeIndex )
BlockID newId( byteArray, 0, byteArray.size() );
WALBERLA_CHECK_EQUAL( oldId, newId );
WALBERLA_CHECK_EQUAL( oldId, newId )
for( uint_t b = branches; b-- != 0; ) {
WALBERLA_CHECK_EQUAL( newId.getBranchId(), branch[b] );
WALBERLA_CHECK_EQUAL( newId.getBranchId(), branch[b] )
newId.removeBranchId();
}
WALBERLA_CHECK_EQUAL( newId.getTreeIndex(), treeIndex );