Commit e6d3fbce authored by Markus Holzer's avatar Markus Holzer
Browse files

Fixed ShallowCopy

parent 59505bbc
Pipeline #38557 failed with stages
in 3 minutes and 3 seconds
......@@ -45,7 +45,7 @@ namespace field {
*******************************************************************************************************************/
template<typename T>
Field<T>::Field( )
: values_( NULL ), valuesWithOffset_( NULL ),
: values_( nullptr ), valuesWithOffset_( nullptr ),
xSize_(0), ySize_(0), zSize_(0), fSize_(0),
xAllocSize_(0), yAllocSize_(0), zAllocSize_(0), fAllocSize_(0)
{
......@@ -54,7 +54,6 @@ namespace field {
//*******************************************************************************************************************
/*!Creates an uninitialized field of given size
*
<<<<<<< HEAD
* \param xSize size of x dimension
* \param ySize size of y dimension
* \param zSize size of z dimension
......@@ -107,7 +106,7 @@ namespace field {
Field<T>::Field( uint_t _xSize, uint_t _ySize, uint_t _zSize, uint_t _fSize,
const std::vector<T> & fValues, const Layout & l,
const shared_ptr<FieldAllocator<T> > &alloc)
: values_( NULL ), valuesWithOffset_( NULL )
: values_(nullptr ), valuesWithOffset_(nullptr )
{
init(_xSize,_ySize,_zSize,_fSize,l,alloc);
set(fValues);
......@@ -130,8 +129,8 @@ namespace field {
return;
allocator_->decrementReferenceCount( values_ );
values_ = NULL;
valuesWithOffset_ = NULL;
values_ = nullptr;
valuesWithOffset_ = nullptr;
init( _xSize, _ySize, _zSize, _fSize, layout_, allocator_ );
}
......@@ -189,7 +188,7 @@ namespace field {
template<typename T>
typename Field<T>::FlattenedField * Field<T>::flattenedShallowCopyInternal() const
{
return new FlattenedField(*this) ;
return new FlattenedField(*this);
}
//*******************************************************************************************************************
......@@ -211,7 +210,7 @@ namespace field {
WALBERLA_ASSERT ( hasSameSize ( *res ) )
WALBERLA_ASSERT ( hasSameAllocSize( *res ) )
return res;
}
......@@ -279,7 +278,7 @@ namespace field {
xSize_ ( other.xSize_ ),
ySize_ ( other.ySize_ ),
zSize_ ( other.zSize_ ),
fSize_ ( other.fSize_ ),
fSize_ (VectorTrait<T2>::F_SIZE * other.fSize_),
xAllocSize_ ( other.xAllocSize_ ),
yAllocSize_ ( other.yAllocSize_ ),
zAllocSize_ ( other.zAllocSize_ ),
......
......@@ -196,7 +196,7 @@ protected:
/*! \name Shallow Copy */
//@{
FlagField(const FlagField<T> & other);
virtual Field<T> * cloneShallowCopyInternal() const;
Field<T> * cloneShallowCopyInternal() const override;
//@}
//*******************************************************************************************************************
......
......@@ -200,8 +200,8 @@ namespace field {
/*! \name Slicing */
//@{
GhostLayerField<T> * getSlicedField( const CellInterval & interval ) const;
virtual void slice ( const CellInterval & interval ) override;
virtual void shiftCoordinates( cell_idx_t cx, cell_idx_t cy, cell_idx_t cz ) override;
void slice ( const CellInterval & interval ) override;
void shiftCoordinates( cell_idx_t cx, cell_idx_t cy, cell_idx_t cz ) override;
//@}
//****************************************************************************************************************
......@@ -214,8 +214,8 @@ namespace field {
//** Shallow Copy ************************************************************************************************
/*! \name Shallow Copy */
//@{
virtual Field<T> * cloneShallowCopyInternal() const override;
virtual typename Field<T>::FlattenedField * flattenedShallowCopyInternal() const override;
Field<T> * cloneShallowCopyInternal() const override;
typename Field<T>::FlattenedField * flattenedShallowCopyInternal() const override;
GhostLayerField(const GhostLayerField<T> & other);
template <typename T2>
GhostLayerField(const GhostLayerField<T2> & other);
......
......@@ -33,9 +33,9 @@ namespace field {
{
// With 0 alignment this function makes no sense
// use normal malloc instead
WALBERLA_ASSERT_GREATER( alignment, 0 );
WALBERLA_ASSERT_GREATER( alignment, 0 )
// Tests if alignment is power of two (assuming alignment>0)
WALBERLA_ASSERT( !(alignment & (alignment - 1)) );
WALBERLA_ASSERT( !(alignment & (alignment - 1)) )
void *pa; // pointer to allocated memory
......@@ -51,7 +51,7 @@ namespace field {
// Store pointer to real allocated chunk just before usable chunk
*((void **)ptr-1)=pa;
WALBERLA_ASSERT_EQUAL( ((size_t)ptr) % alignment, 0 );
WALBERLA_ASSERT_EQUAL( ((size_t)ptr) % alignment, 0 )
return ptr;
}
......@@ -60,11 +60,11 @@ namespace field {
{
// With 0 alignment this function makes no sense
// use normal malloc instead
WALBERLA_ASSERT_GREATER( alignment, 0 );
WALBERLA_ASSERT_GREATER( alignment, 0 )
// Tests if alignment is power of two (assuming alignment>0)
WALBERLA_ASSERT( !(alignment & (alignment - 1)) );
WALBERLA_ASSERT( !(alignment & (alignment - 1)) )
WALBERLA_ASSERT_LESS( offset, alignment );
WALBERLA_ASSERT_LESS( offset, alignment )
if( offset == 0 )
return aligned_malloc( size, alignment );
......@@ -84,7 +84,7 @@ namespace field {
// Store pointer to real allocated chunk just before usable chunk
*((void **)ptr-1)=pa;
WALBERLA_ASSERT_EQUAL( ((size_t)ptr+offset) % alignment, 0 );
WALBERLA_ASSERT_EQUAL( ((size_t)ptr+offset) % alignment, 0 )
return ptr;
}
......
This diff is collapsed.
......@@ -35,8 +35,6 @@ namespace wlb = walberla;
using std::vector;
using std::string;
using std::cout;
using std::endl;
void registerTest()
{
......@@ -62,7 +60,7 @@ void registerTest()
catch( std::runtime_error & /*err*/) {
overFlow = true;
}
WALBERLA_CHECK(overFlow);
WALBERLA_CHECK(overFlow)
vector<string> names;
names.emplace_back("Flag1");
......@@ -76,10 +74,10 @@ void registerTest()
for(size_t i=0; i<names.size(); ++i)
{
WALBERLA_CHECK(ff.flagExists(names[i]));
WALBERLA_CHECK(ff.flagExists(i));
WALBERLA_CHECK_EQUAL(ff.getFlag(names[i]), 1 << i );
WALBERLA_CHECK_EQUAL( ff.getFlagUID( numeric_cast<FlagField<walberla::uint8_t>::flag_t>( 1 << i ) ), FlagUID(names[i]) );
WALBERLA_CHECK(ff.flagExists(names[i]))
WALBERLA_CHECK(ff.flagExists(i))
WALBERLA_CHECK_EQUAL(ff.getFlag(names[i]), 1 << i )
WALBERLA_CHECK_EQUAL( ff.getFlagUID( numeric_cast<FlagField<walberla::uint8_t>::flag_t>( 1 << i ) ), FlagUID(names[i]) )
}
//ff.printRegistered(cout);
......@@ -88,19 +86,19 @@ void registerTest()
void accessTest()
{
FlagField<wlb::uint8_t> ff (3,3,3,1);
WALBERLA_CHECK_EQUAL( ff.xSize(), 3 );
WALBERLA_CHECK_EQUAL( ff.xSize(), 3 )
wlb::uint8_t flag = ff.registerFlag("MyFlag");
WALBERLA_CHECK_EQUAL( ff.get(0,0,0), 0);
WALBERLA_CHECK_EQUAL( ff.get(0,0,0), 0)
ff.addFlag(0,0,0,flag);
WALBERLA_CHECK (ff.isFlagSet(0,0,0,flag));
WALBERLA_CHECK (ff.isFlagSet(0,0,0,flag))
ff.removeFlag(0,0,0,flag);
WALBERLA_CHECK (! ff.isFlagSet(0,0,0,flag) );
WALBERLA_CHECK (! ff.isFlagSet(0,0,0,flag) )
WALBERLA_CHECK( ff.get(0,0,0) == 0);
WALBERLA_CHECK( ff.get(0,0,0) == 0)
}
void iteratorTest()
......@@ -112,7 +110,7 @@ void iteratorTest()
addFlag(i, flag);
for( auto i = ff.begin(); i != ff.end(); ++i )
WALBERLA_CHECK( isFlagSet(i, flag) );
WALBERLA_CHECK( isFlagSet(i, flag) )
}
void shallowCopyTest()
......@@ -124,11 +122,11 @@ void shallowCopyTest()
ff.registerFlag("FirstFlag");
shared_ptr< FField > sliced = shared_ptr< FField > ( ff.getSlicedField(CellInterval(0,1,0,2,2,2)) );
WALBERLA_CHECK_NOT_NULLPTR( sliced );
WALBERLA_CHECK_NOT_NULLPTR( sliced )
sliced->registerFlag("SecondFlag");
WALBERLA_CHECK( ff.flagExists("SecondFlag") );
WALBERLA_CHECK( ff.flagExists("SecondFlag") )
// Test deep copy
......@@ -141,10 +139,10 @@ void shallowCopyTest()
FField * f2 = f1->clone();
delete f1;
WALBERLA_CHECK( f2->flagExists( "Flag1" ) );
WALBERLA_CHECK( f2->flagExists( "Flag2" ) );
WALBERLA_CHECK( f2->isFlagSet( 0,0,0,flag1 ) );
WALBERLA_CHECK( f2->isFlagSet( 1,1,1,flag2 ) );
WALBERLA_CHECK( f2->flagExists( "Flag1" ) )
WALBERLA_CHECK( f2->flagExists( "Flag2" ) )
WALBERLA_CHECK( f2->isFlagSet( 0,0,0,flag1 ) )
WALBERLA_CHECK( f2->isFlagSet( 1,1,1,flag2 ) )
delete f2;
......@@ -186,15 +184,15 @@ void neighborhoodTest()
for( auto it = ff.begin(); it != ff.end(); ++it )
{
if (it.x() == 1 && it.y() == 1 && it.z() == 1) {
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, i) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, g) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, l) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, i) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, g) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, l) )
}
if (it.x() == 1 && it.y() == 2 && it.z() == 2) {
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q19>(it, i) );
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q19>(it, g) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, l) );
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q19>(it, i) )
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q19>(it, g) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q19>(it, l) )
}
}
......@@ -206,15 +204,15 @@ void neighborhoodTest()
for( auto it = ff.begin(); it != ff.end(); ++it )
{
if (it.x() == 1 && it.y() == 1 && it.z() == 1) {
WALBERLA_CHECK( field::isFlagInNeighborhood<stencil::D3Q27>(it, i) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, g) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, l) );
WALBERLA_CHECK( field::isFlagInNeighborhood<stencil::D3Q27>(it, i) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, g) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, l) )
}
if (it.x() == 2 && it.y() == 2 && it.z() == 2) {
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q27>(it, i) );
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q27>(it, g) );
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, l) );
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q27>(it, i) )
WALBERLA_CHECK( !isFlagInNeighborhood<stencil::D3Q27>(it, g) )
WALBERLA_CHECK( isFlagInNeighborhood<stencil::D3Q27>(it, l) )
}
}
......
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