Commit 77cb8284 authored by Markus Holzer's avatar Markus Holzer
Browse files

More specialisation

parent 2754a384
Pipeline #38594 failed with stages
in 3 minutes and 59 seconds
......@@ -102,12 +102,25 @@ namespace internal {
template< typename GhostLayerField_T, typename BlockStorage_T, class Enable = void >
struct AddToStorage
{
using Value_T = typename GhostLayerField_T::value_type;
static BlockDataID add( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, const uint_t fSize,
const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers,
const bool /*alwaysInitialize*/, const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction,
const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize,
const shared_ptr< field::FieldAllocator<Value_T> > alloc = nullptr)
{
auto dataHandling = walberla::make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout, calculateSize, alloc );
dataHandling->addInitializationFunction( initFunction );
return blocks->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors );
}
static BlockDataID add( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier,
const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers,
const bool /*alwaysInitialize*/, const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction,
const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize,
const shared_ptr< field::FieldAllocator<Value_T> > alloc = nullptr)
{
auto dataHandling = walberla::make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, nrOfGhostLayers, initValue, layout, calculateSize, alloc );
dataHandling->addInitializationFunction( initFunction );
......@@ -120,6 +133,7 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T,
typename std::enable_if< ( std::is_integral< typename GhostLayerField_T::value_type >::value || std::is_floating_point< typename GhostLayerField_T::value_type >::value ) &&
! std::is_same< GhostLayerField_T, FlagField< typename GhostLayerField_T::value_type > >::value >::type >
{
using Value_T = typename GhostLayerField_T::value_type;
static BlockDataID add( const shared_ptr< BlockStorage_T > & blocks, const std::string & identifier, const uint_t fSize,
const typename GhostLayerField_T::value_type & initValue, const Layout layout, const uint_t nrOfGhostLayers,
const bool alwaysInitialize, const std::function< void ( GhostLayerField_T * field, IBlock * const block ) > & initFunction,
......@@ -129,11 +143,11 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T,
{
if( alwaysInitialize )
{
auto dataHandling = walberla::make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout, calculateSize );
auto dataHandling = walberla::make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout, calculateSize, alloc );
dataHandling->addInitializationFunction( initFunction );
return blocks->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors );
}
auto dataHandling = walberla::make_shared< field::DefaultBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout, calculateSize );
auto dataHandling = walberla::make_shared< field::DefaultBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout, calculateSize, alloc );
dataHandling->addInitializationFunction( initFunction );
return blocks->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors );
}
......@@ -142,7 +156,6 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T,
} // namespace internal
template< typename GhostLayerField_T, typename BlockStorage_T >
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
......@@ -156,8 +169,8 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const Set<SUID> & requiredSelectors = Set<SUID>::emptySet(),
const Set<SUID> & incompatibleSelectors = Set<SUID>::emptySet())
{
return internal::AddToStorage< GhostLayerField_T, BlockStorage_T >::add( blocks, identifier, fSize, initValue, layout, nrOfGhostLayers,
alwaysInitialize, initFunction, requiredSelectors, incompatibleSelectors );
return internal::AddToStorage< GhostLayerField_T, BlockStorage_T >::add( blocks, identifier, fSize, initValue, layout, nrOfGhostLayers,
alwaysInitialize, initFunction, requiredSelectors, incompatibleSelectors );
}
......@@ -307,7 +320,7 @@ struct Creator : public domain_decomposition::BlockDataCreator< GhostLayerField_
domain_decomposition::BlockDataCreator< GhostLayerField_T >( shared_ptr< field::DefaultBlockDataHandling< GhostLayerField_T > >(),
identifier, requiredSelectors, incompatibleSelectors )
{
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, nrOfGhostLayers, initValue, layout );
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout );
dataHandling->addInitializationFunction( initFunction );
this->dataHandling_ = dataHandling;
......@@ -349,13 +362,13 @@ struct Creator< GhostLayerField_T,
{
if( alwaysInitialize )
{
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, nrOfGhostLayers, initValue, layout );
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout );
dataHandling->addInitializationFunction( initFunction );
this->dataHandling_ = dataHandling;
}
else
{
auto dataHandling = make_shared< field::DefaultBlockDataHandling< GhostLayerField_T > >( blocks, nrOfGhostLayers, initValue, layout );
auto dataHandling = make_shared< field::DefaultBlockDataHandling< GhostLayerField_T > >( blocks, fSize, nrOfGhostLayers, initValue, layout );
dataHandling->addInitializationFunction( initFunction );
this->dataHandling_ = dataHandling;
}
......@@ -394,13 +407,13 @@ struct Creator< FlagField<T> > : public domain_decomposition::BlockDataCreator<
{
if( alwaysInitialize )
{
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< FlagField<T> > >( blocks, nrOfGhostLayers );
auto dataHandling = make_shared< field::AlwaysInitializeBlockDataHandling< FlagField<T> > >( blocks, uint_t(1), nrOfGhostLayers );
dataHandling->addInitializationFunction( initFunction );
this->dataHandling_ = dataHandling;
}
else
{
auto dataHandling = make_shared< field::DefaultBlockDataHandling< FlagField<T> > >( blocks, nrOfGhostLayers );
auto dataHandling = make_shared< field::DefaultBlockDataHandling< FlagField<T> > >( blocks, uint_t(1), nrOfGhostLayers );
dataHandling->addInitializationFunction( initFunction );
this->dataHandling_ = dataHandling;
}
......
......@@ -395,6 +395,7 @@ class Field<T, fSize_> : public Field<T> {
Field(Field<T> field)
: Field<T>::Field(field)
{}
static const uint_t F_SIZE = fSize_;
typedef typename std::conditional<VectorTrait<T>::F_SIZE!=0,
Field<typename VectorTrait<T>::OutputType, VectorTrait<T>::F_SIZE*fSize_>,
......
......@@ -229,6 +229,8 @@ class GhostLayerField<T, fSize_> : public GhostLayerField<T> {
: GhostLayerField<T>::GhostLayerField(field)
{}
static const uint_t F_SIZE = fSize_;
typedef typename std::conditional<VectorTrait<T>::F_SIZE!=0,
GhostLayerField<typename VectorTrait<T>::OutputType, VectorTrait<T>::F_SIZE*fSize_>,
GhostLayerField<T, fSize_>>::type FlattenedField;
......
......@@ -333,10 +333,10 @@ namespace internal
template< typename GhostLayerField_T >
inline GhostLayerField_T * allocate( const uint_t x, const uint_t y, const uint_t z, const uint_t fSize, const uint_t gl,
const typename GhostLayerField_T::value_type & v, Layout l,
const typename GhostLayerField_T::value_type & initValue, Layout l,
const shared_ptr< field::FieldAllocator<typename GhostLayerField_T::value_type> > & alloc=nullptr)
{
return new GhostLayerField_T(x,y,z,fSize,gl,v,l, alloc);
return new GhostLayerField_T(x, y, z, fSize, gl, initValue, l, alloc);
}
template<>
inline FlagField<uint8_t> * allocate( const uint_t x, const uint_t y, const uint_t z, const uint_t /*fSize*/, const uint_t gl, const uint8_t &, Layout,
......
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