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

New try

parent a9923132
Pipeline #38608 failed with stages
in 6 minutes and 50 seconds
......@@ -120,10 +120,10 @@ namespace field {
virtual void resize( uint_t xSize, uint_t ySize, uint_t zSize, uint_t fSize );
Field<T> * clone() const;
Field<T> * cloneUninitialized() const;
Field<T> * cloneShallowCopy() const;
FlattenedField * flattenedShallowCopy() const;
virtual Field<T> * clone() const;
virtual Field<T> * cloneUninitialized() const;
virtual Field<T> * cloneShallowCopy() const;
virtual FlattenedField * flattenedShallowCopy() const;
//@}
//****************************************************************************************************************
......@@ -272,7 +272,7 @@ namespace field {
//** Slicing ****************************************************************************************************
/*! \name Slicing */
//@{
Field<T> * getSlicedField( const CellInterval & interval ) const;
virtual Field<T> * getSlicedField( const CellInterval & interval ) const;
virtual void slice ( const CellInterval & interval );
virtual void shiftCoordinates( cell_idx_t cx, cell_idx_t cy, cell_idx_t cz );
//@}
......@@ -422,6 +422,36 @@ class Field<T, fSize_> : public Field<T> {
Field<T>::resize(xSize, ySize, zSize, fSize_);
}
template<typename ...Args>
Field<T, fSize_> * getSlicedField( const CellInterval & interval ) const
{
return dynamic_cast<Field<T, fSize_>* > (Field<T>::getSlicedField( interval ));
}
template<typename ...Args>
Field<T, fSize_> * clone()
{
return dynamic_cast<Field<T, fSize_>* > (Field<T>::clone());
}
template<typename ...Args>
Field<T, fSize_> * cloneUninitialized()
{
return dynamic_cast<Field<T, fSize_>* > (Field<T>::cloneUninitialized());
}
template<typename ...Args>
Field<T, fSize_> * cloneShallowCopy()
{
return dynamic_cast<Field<T, fSize_>* > (Field<T>::cloneShallowCopy());
}
template<typename ...Args>
FlattenedField* flattenedShallowCopy()
{
return dynamic_cast<FlattenedField* > (Field<T>::flattenedShallowCopy());
}
};
......
......@@ -99,15 +99,15 @@ class GhostLayerField<T> : public Field<T>
uint_t nrGhostLayers, const Layout& layout = zyxf,
const shared_ptr< FieldAllocator< T > >& alloc = shared_ptr< FieldAllocator< T > >());
virtual void resize(uint_t xSize, uint_t ySize, uint_t zSize, uint_t _fSize) override;
void resize(uint_t xSize, uint_t ySize, uint_t zSize, uint_t _fSize) override;
void resize(uint_t xSize, uint_t ySize, uint_t zSize, uint_t _fSize, uint_t gl);
using Field< T >::resize;
inline GhostLayerField< T >* clone() const;
inline GhostLayerField< T >* cloneUninitialized() const;
inline GhostLayerField< T >* cloneShallowCopy() const;
inline FlattenedField* flattenedShallowCopy() const;
inline GhostLayerField< T >* clone() const override;
inline GhostLayerField< T >* cloneUninitialized() const override;
inline GhostLayerField< T >* cloneShallowCopy() const override;
inline FlattenedField* flattenedShallowCopy() const override;
//@}
//****************************************************************************************************************
......@@ -193,7 +193,7 @@ class GhostLayerField<T> : public Field<T>
//** Slicing ****************************************************************************************************
/*! \name Slicing */
//@{
GhostLayerField< T >* getSlicedField(const CellInterval& interval) const;
GhostLayerField< T >* getSlicedField(const CellInterval& interval) const override;
void slice(const CellInterval& interval) override;
void shiftCoordinates(cell_idx_t cx, cell_idx_t cy, cell_idx_t cz) override;
//@}
......@@ -254,6 +254,30 @@ class GhostLayerField<T, fSize_> : public GhostLayerField<T> {
{
GhostLayerField<T>::resize(xSize, ySize, zSize, fSize_);
}
template<typename ...Args>
GhostLayerField<T, fSize_> * clone()
{
return dynamic_cast<GhostLayerField<T, fSize_>* > (GhostLayerField<T>::clone());
}
template<typename ...Args>
GhostLayerField<T, fSize_> * cloneUninitialized()
{
return dynamic_cast<GhostLayerField<T, fSize_>* > (GhostLayerField<T>::cloneUninitialized());
}
template<typename ...Args>
GhostLayerField<T, fSize_> * cloneShallowCopy()
{
return dynamic_cast<GhostLayerField<T, fSize_>* > (GhostLayerField<T>::cloneShallowCopy());
}
template<typename ...Args>
FlattenedField* flattenedShallowCopy()
{
return dynamic_cast<FlattenedField* > (GhostLayerField<T>::flattenedShallowCopy());
}
};
#ifdef WALBERLA_CXX_COMPILER_IS_CLANG
#pragma clang diagnostic pop
......
......@@ -32,13 +32,13 @@ namespace pde {
SweepBase::Field_T * SweepBase::getDstField( IBlock * const block, Field_T * const src )
{
WALBERLA_ASSERT_NOT_NULLPTR( block );
WALBERLA_ASSERT_NOT_NULLPTR( src );
WALBERLA_ASSERT_NOT_NULLPTR( block )
WALBERLA_ASSERT_NOT_NULLPTR( src )
if( dstFromBlockData_ )
{
Field_T * dst = block->getData< Field_T >( dst_ );
WALBERLA_ASSERT_NOT_NULLPTR( dst );
WALBERLA_ASSERT_NOT_NULLPTR( dst )
return dst;
}
......@@ -48,12 +48,12 @@ SweepBase::Field_T * SweepBase::getDstField( IBlock * const block, Field_T * con
#ifndef NDEBUG
std::fill( (*it)->beginWithGhostLayer(), (*it)->end(), std::numeric_limits< Field_T::value_type >::quiet_NaN() );
#endif
WALBERLA_ASSERT_NOT_NULLPTR( *it );
WALBERLA_ASSERT_NOT_NULLPTR( *it )
return *it;
}
Field_T * dst = src->cloneUninitialized();
WALBERLA_ASSERT_NOT_NULLPTR( dst );
WALBERLA_ASSERT_NOT_NULLPTR( dst )
// take care of proper thread<->memory assignment (first-touch allocation policy !)
WALBERLA_FOR_ALL_CELLS_INCLUDING_GHOST_LAYER_XYZ( dst,
......
......@@ -34,9 +34,6 @@
#include <iostream>
#include <set>
// TODO ///////////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO ///////////// Tests must be removed when depricated Field with templated fSize is removed ////////////////
// TODO //////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace walberla;
......@@ -322,9 +319,7 @@ void resizeTest(field::Layout layout)
WALBERLA_CHECK_EQUAL( field.yAllocSize(), 2+2*gl);
WALBERLA_CHECK_EQUAL( field.zAllocSize(), 1+2*gl);
// TODO: here the old API is violated since the constructor does not return GhostLayerField<uint_t, 3*fSize>
// TODO: but GhostLayerField<uint_t>. However this might be a corner case that nobody notices?
// TODO this was adapted ...
Field<int> * p = &field;
WALBERLA_CHECK_EQUAL( p->xSize(), 4);
WALBERLA_CHECK_EQUAL( p->ySize(), 2);
......@@ -333,7 +328,7 @@ void resizeTest(field::Layout layout)
WALBERLA_CHECK_EQUAL( p->yAllocSize(), 2+2*gl);
WALBERLA_CHECK_EQUAL( p->zAllocSize(), 1+2*gl);
p->resize(3,4,5,3);
p->resize(3,4,5, 3);
WALBERLA_CHECK_EQUAL( field.xSize(), 3);
WALBERLA_CHECK_EQUAL( field.ySize(), 4);
WALBERLA_CHECK_EQUAL( field.zSize(), 5);
......@@ -391,9 +386,8 @@ void sliceTest(field::Layout layout)
WALBERLA_CHECK_EQUAL ( counter, field.xSize() * field.ySize() * field.zSize() * fSize );
// TODO: here the old API is violated since the constructor does not return GhostLayerField<uint_t, 3*fSize>
// TODO: but GhostLayerField<uint_t>. However this might be a corner case that nobody notices?
auto sliced = shared_ptr<Field<int> > ( field.getSlicedField(sliceInterval) );
auto sliced = shared_ptr<Field<int,fSize> > ( field.getSlicedField(sliceInterval) );
WALBERLA_CHECK_EQUAL ( sliced->xSize(), sliceInterval.xSize() );
WALBERLA_CHECK_EQUAL ( sliced->ySize(), sliceInterval.ySize() );
......@@ -598,7 +592,7 @@ void flattenTest()
field( x,y,z,f )[g] = val;
}
shared_ptr<Field<uint_t>> flattened(field.flattenedShallowCopy());
shared_ptr<Field<uint_t, 3*fSize>> flattened(field.flattenedShallowCopy());
Field<uint_t, 3*fSize> cmp ( 2,2,1 );
WALBERLA_CHECK_EQUAL(cmp.xSize(), flattened->xSize());
......@@ -644,9 +638,7 @@ void ghostFlattenTest()
field( x,y,z,f )[g] = val;
}
// TODO: here the old API is violated since the constructor does not return GhostLayerField<uint_t, 3*fSize>
// TODO: but GhostLayerField<uint_t>. However this might be a corner case that nobody notices?
shared_ptr<GhostLayerField<uint_t>> flattened(field.flattenedShallowCopy());
shared_ptr<GhostLayerField<uint_t, 3*fSize>> flattened(field.flattenedShallowCopy());
GhostLayerField<uint_t, 3*fSize> cmp ( 2,2,1, 1 );
WALBERLA_CHECK_EQUAL(cmp.xSize(), flattened->xSize());
......@@ -737,6 +729,6 @@ int main( int argc, char**argv )
//swapableCompareTest();
//printerTest();
return EXIT_SUCCESS;
return 0;
}
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