Commit 0fe3a5ca authored by Markus Holzer's avatar Markus Holzer
Browse files

Adapted more functions

parent 356b1788
Pipeline #38616 failed with stages
in 7 minutes and 49 seconds
......@@ -298,10 +298,11 @@ namespace field {
const uint_t xs = Field<T>::xSize() + 2 * uint_c( numGhostLayers );
const uint_t ys = Field<T>::ySize() + 2 * uint_c( numGhostLayers );
const uint_t zs = Field<T>::zSize() + 2 * uint_c( numGhostLayers );
const uint_t fs = Field<T>::fSize();
return const_iterator( this,
-numGhostLayers,-numGhostLayers,-numGhostLayers,0,
xs, ys, zs );
return const_iterator( this,
-numGhostLayers, -numGhostLayers, -numGhostLayers, 0,
xs, ys, zs, fs );
}
......
......@@ -22,7 +22,6 @@
#include "core/DataTypes.h"
#include "core/debug/TestSubsystem.h"
#include "core/logging/Logging.h"
#include "core/mpi/Environment.h"
#include "core/mpi/MPIManager.h"
#include "core/mpi/MPIWrapper.h"
......@@ -43,8 +42,8 @@ class FieldRandomizer
{
public:
template< typename T, uint_t fSize >
void operator()( Field< T, fSize > & field )
template< typename T >
void operator()( Field< T > & field )
{
std::uniform_real_distribution< T > distribution;
......@@ -54,8 +53,8 @@ public:
}
}
template< typename T, uint_t fSize >
void operator()( GhostLayerField< T, fSize > & field )
template< typename T >
void operator()( GhostLayerField< T > & field )
{
std::uniform_real_distribution< T > distribution;
......@@ -75,7 +74,7 @@ private:
template< typename SourceField, typename TargetField >
void testFullCopy( const SourceField & src, TargetField & dst )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
MPI_Datatype srcType = mpiDatatype( src );
MPI_Datatype dstType = mpiDatatype( dst );
......@@ -83,11 +82,11 @@ void testFullCopy( const SourceField & src, TargetField & dst )
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( src != dst );
WALBERLA_CHECK( src != dst )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( src == dst );
WALBERLA_CHECK( src == dst )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -96,7 +95,7 @@ void testFullCopy( const SourceField & src, TargetField & dst )
template< typename SourceField, typename TargetField >
void testOctantCopy( const SourceField & src, TargetField & dst )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
const CellInterval fullInterval = src.xyzSize();
......@@ -115,7 +114,7 @@ void testOctantCopy( const SourceField & src, TargetField & dst )
CellInterval( xMid + cell_idx_t(1), yMid + cell_idx_t(1), zMid + cell_idx_t(1), fullInterval.xMax(), fullInterval.yMax(), fullInterval.zMax() )
};
WALBERLA_CHECK( src != dst );
WALBERLA_CHECK( src != dst )
for( auto it = octants; it != octants + 8; ++it )
{
......@@ -131,16 +130,16 @@ void testOctantCopy( const SourceField & src, TargetField & dst )
MPI_Type_free( &dstType );
}
WALBERLA_CHECK( src == dst );
WALBERLA_CHECK( src == dst )
}
template< typename SourceField, typename TargetField >
void testSingleFCopy( const SourceField & src, TargetField & dst )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
WALBERLA_CHECK( src != dst );
WALBERLA_CHECK( src != dst )
for( uint_t f = 0; f < src.fSize(); ++f )
{
......@@ -157,16 +156,17 @@ void testSingleFCopy( const SourceField & src, TargetField & dst )
}
WALBERLA_CHECK( src == dst );
WALBERLA_CHECK( src == dst )
}
template< typename SourceField, typename TargetField >
void testSlicedFCopy( const SourceField & src, TargetField & dst )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
std::set<cell_idx_t> evenFs, oddFs;
std::set<cell_idx_t> evenFs;
std::set<cell_idx_t> oddFs;
for( cell_idx_t f = 0; f < cell_idx_c( src.fSize() ); ++f )
{
......@@ -176,7 +176,7 @@ void testSlicedFCopy( const SourceField & src, TargetField & dst )
oddFs.insert( f );
}
WALBERLA_CHECK( src != dst );
WALBERLA_CHECK( src != dst )
MPI_Datatype srcType = mpiDatatypeSliceXYZ( src, src.xyzSize(), evenFs );
MPI_Datatype dstType = mpiDatatypeSliceXYZ( dst, dst.xyzSize(), evenFs );
......@@ -201,18 +201,18 @@ void testSlicedFCopy( const SourceField & src, TargetField & dst )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
WALBERLA_CHECK( src == dst );
WALBERLA_CHECK( src == dst )
}
template< typename SourceField, typename TargetField >
void testIntervalCopy( const SourceField & src, TargetField & dst, const CellInterval & interval, const cell_idx_t fBeg, const cell_idx_t fEnd )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.set( numeric_cast< typename SourceField::value_type >( 0 ) );
WALBERLA_CHECK( src != dst );
WALBERLA_CHECK( src != dst )
MPI_Datatype srcType = mpiDatatypeSliceXYZ( src, interval, fBeg, fEnd );
MPI_Datatype dstType = mpiDatatypeSliceXYZ( dst, interval, fBeg, fEnd );
......@@ -231,12 +231,12 @@ void testIntervalCopy( const SourceField & src, TargetField & dst, const CellInt
if( interval.contains( *it ) )
{
for( cell_idx_t f = fBeg; f <= fEnd; ++f )
WALBERLA_CHECK_IDENTICAL( src.get( *it, f ), dst.get( *it, f ) );
WALBERLA_CHECK_IDENTICAL( src.get( *it, f ), dst.get( *it, f ) )
}
else
{
for( cell_idx_t f = fBeg; f <= fEnd; ++f )
WALBERLA_CHECK_IDENTICAL( dst.get( *it, f ), numeric_cast< typename SourceField::value_type >( 0 ) );
WALBERLA_CHECK_IDENTICAL( dst.get( *it, f ), numeric_cast< typename SourceField::value_type >( 0 ) )
}
}
}
......@@ -304,7 +304,7 @@ void runTests( SourceField & srcField, TargetField & dstField )
template< typename SourceField, typename TargetField >
void testFullCopyGL( const SourceField & src, TargetField & dst )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.setWithGhostLayer( 0.0 );
......@@ -314,11 +314,11 @@ void testFullCopyGL( const SourceField & src, TargetField & dst )
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( !std::equal( src.beginWithGhostLayer(), src.end(), dst.beginWithGhostLayer() ) );
WALBERLA_CHECK( !std::equal( src.beginWithGhostLayer(), src.end(), dst.beginWithGhostLayer() ) )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( std::equal( src.beginWithGhostLayer(), src.end(), dst.beginWithGhostLayer() ) );
WALBERLA_CHECK( std::equal( src.beginWithGhostLayer(), src.end(), dst.beginWithGhostLayer() ) )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -327,7 +327,7 @@ void testFullCopyGL( const SourceField & src, TargetField & dst )
template< typename SourceField, typename TargetField >
void testPartialCopyGL( const SourceField & src, TargetField & dst, uint_t numberOfGhostLayers )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.setWithGhostLayer( 0.0 );
......@@ -337,16 +337,16 @@ void testPartialCopyGL( const SourceField & src, TargetField & dst, uint_t numbe
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( !std::equal( src.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ), src.end(), dst.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ) ) );
WALBERLA_CHECK( !std::equal( src.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ), src.end(), dst.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ) ) )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( std::equal( src.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ), src.end(), dst.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ) ) );
WALBERLA_CHECK( std::equal( src.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ), src.end(), dst.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ) ) )
std::fill( dst.beginWithGhostLayer( cell_idx_c( numberOfGhostLayers ) ), dst.end(), typename TargetField::value_type( 0.0 ) );
for( auto it = dst.beginWithGhostLayer(); it != dst.end(); ++it )
WALBERLA_CHECK_IDENTICAL( *it, 0.0 );
WALBERLA_CHECK_IDENTICAL( *it, 0.0 )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -357,7 +357,7 @@ void testPartialCopyGL( const SourceField & src, TargetField & dst, uint_t numbe
template< typename SourceField, typename TargetField >
void testFullCopyGLOnly( const SourceField & src, TargetField & dst, const stencil::Direction dir, const bool fullSlice )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.setWithGhostLayer( 0.0 );
......@@ -367,16 +367,16 @@ void testFullCopyGLOnly( const SourceField & src, TargetField & dst, const stenc
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( !std::equal( src.beginGhostLayerOnly( dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( dir, fullSlice ) ) );
WALBERLA_CHECK( !std::equal( src.beginGhostLayerOnly( dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( dir, fullSlice ) ) )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( std::equal( src.beginGhostLayerOnly( dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( dir, fullSlice ) ) );
WALBERLA_CHECK( std::equal( src.beginGhostLayerOnly( dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( dir, fullSlice ) ) )
std::fill( dst.beginGhostLayerOnly( dir, fullSlice ), dst.end(), typename TargetField::value_type( 0.0 ) );
for( auto it = dst.beginWithGhostLayer(); it != dst.end(); ++it )
WALBERLA_CHECK_IDENTICAL( *it, 0.0 );
WALBERLA_CHECK_IDENTICAL( *it, 0.0 )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -385,7 +385,7 @@ void testFullCopyGLOnly( const SourceField & src, TargetField & dst, const stenc
template< typename SourceField, typename TargetField >
void testPartialCopyGLOnly( const SourceField & src, TargetField & dst, const uint_t thickness, const stencil::Direction dir, const bool fullSlice )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.setWithGhostLayer( 0.0 );
......@@ -395,16 +395,16 @@ void testPartialCopyGLOnly( const SourceField & src, TargetField & dst, const ui
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( !std::equal( src.beginGhostLayerOnly( thickness, dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( thickness, dir, fullSlice ) ) );
WALBERLA_CHECK( !std::equal( src.beginGhostLayerOnly( thickness, dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( thickness, dir, fullSlice ) ) )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( std::equal( src.beginGhostLayerOnly( thickness, dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( thickness, dir, fullSlice ) ) );
WALBERLA_CHECK( std::equal( src.beginGhostLayerOnly( thickness, dir, fullSlice ), src.end(), dst.beginGhostLayerOnly( thickness, dir, fullSlice ) ) )
std::fill( dst.beginGhostLayerOnly( thickness, dir, fullSlice ), dst.end(), typename TargetField::value_type( 0.0 ) );
for( auto it = dst.beginWithGhostLayer(); it != dst.end(); ++it )
WALBERLA_CHECK_IDENTICAL( *it, 0.0 );
WALBERLA_CHECK_IDENTICAL( *it, 0.0 )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -414,7 +414,7 @@ void testPartialCopyGLOnly( const SourceField & src, TargetField & dst, const ui
template< typename SourceField, typename TargetField >
void testCopySliceBeforeGL( const SourceField & src, TargetField & dst, const uint_t thickness, const stencil::Direction dir, const bool fullSlice )
{
WALBERLA_ASSERT( src.hasSameSize( dst ) );
WALBERLA_ASSERT( src.hasSameSize( dst ) )
dst.setWithGhostLayer( 0.0 );
......@@ -424,16 +424,16 @@ void testCopySliceBeforeGL( const SourceField & src, TargetField & dst, const ui
MPI_Type_commit( &srcType );
MPI_Type_commit( &dstType );
WALBERLA_CHECK( !std::equal( src.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ), src.end(), dst.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ) ) );
WALBERLA_CHECK( !std::equal( src.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ), src.end(), dst.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ) ) )
MPI_Sendrecv( const_cast<typename SourceField::value_type *>( src.data() ), 1, srcType, 0, 0, dst.data(), 1, dstType, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE );
WALBERLA_CHECK( std::equal( src.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ), src.end(), dst.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ) ) );
WALBERLA_CHECK( std::equal( src.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ), src.end(), dst.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ) ) )
std::fill( dst.beginSliceBeforeGhostLayer( dir, cell_idx_c( thickness ), fullSlice ), dst.end(), typename TargetField::value_type( 0.0 ) );
for( auto it = dst.beginWithGhostLayer(); it != dst.end(); ++it )
WALBERLA_CHECK_IDENTICAL( *it, 0.0 );
WALBERLA_CHECK_IDENTICAL( *it, 0.0 )
MPI_Type_free( &srcType );
MPI_Type_free( &dstType );
......@@ -476,8 +476,8 @@ void runGhostLayerFieldTests( SourceField & srcField, TargetField & dstField )
template< typename T, uint_t fSize >
void runTests( const Vector3<uint_t> & size, field::Layout layout, const shared_ptr< field::FieldAllocator<T> > & srcFieldAllocator, const shared_ptr< field::FieldAllocator<T> > & dstFieldAllocator )
{
field::Field< T, fSize > srcField( size[0], size[1], size[2], 23.0, layout, srcFieldAllocator );
field::Field< T, fSize > dstField( size[0], size[1], size[2], 42.0, layout, dstFieldAllocator );
field::Field< T > srcField( size[0], size[1], size[2], fSize, 23.0, layout, srcFieldAllocator );
field::Field< T > dstField( size[0], size[1], size[2], fSize, 42.0, layout, dstFieldAllocator );
FieldRandomizer randomizer;
randomizer( srcField );
......@@ -486,8 +486,8 @@ void runTests( const Vector3<uint_t> & size, field::Layout layout, const shared_
for( uint_t numGhostLayers = 1; numGhostLayers <= 3; ++numGhostLayers )
{
field::GhostLayerField< T, fSize > srcGhostLayerField( size[0], size[1], size[2], numGhostLayers, 23.0, layout, srcFieldAllocator );
field::GhostLayerField< T, fSize > dstGhostLayerField( size[0], size[1], size[2], numGhostLayers, 42.0, layout, dstFieldAllocator );
field::GhostLayerField< T > srcGhostLayerField( size[0], size[1], size[2], fSize, numGhostLayers, 23.0, layout, srcFieldAllocator );
field::GhostLayerField< T > dstGhostLayerField( size[0], size[1], size[2], fSize, numGhostLayers, 42.0, layout, dstFieldAllocator );
randomizer( srcGhostLayerField );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment