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

Fixes ambigous AddToStorage Functions

parent 0fe3a5ca
Pipeline #38623 failed with stages
in 5 minutes and 55 seconds
......@@ -103,29 +103,20 @@ template< typename GhostLayerField_T, typename BlockStorage_T, class Enable = vo
struct AddToStorage
{
using Value_T = typename GhostLayerField_T::value_type;
using InitFunction_T = std::function< void ( GhostLayerField_T * field, IBlock * const block ) >;
using CalculateFunction_T = std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) >;
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 bool /*alwaysInitialize*/, const InitFunction_T & initFunction,
const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize,
const CalculateFunction_T 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 );
return blocks->addBlockData( dataHandling, identifier, requiredSelectors, incompatibleSelectors );
}
};
template< typename GhostLayerField_T, typename BlockStorage_T >
......@@ -134,11 +125,14 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T,
! std::is_same< GhostLayerField_T, FlagField< typename GhostLayerField_T::value_type > >::value >::type >
{
using Value_T = typename GhostLayerField_T::value_type;
using InitFunction_T = std::function< void ( GhostLayerField_T * field, IBlock * const block ) >;
using CalculateFunction_T = std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) >;
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 bool alwaysInitialize, const InitFunction_T & initFunction,
const Set<SUID> & requiredSelectors, const Set<SUID> & incompatibleSelectors,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize = defaultSize,
const CalculateFunction_T calculateSize = defaultSize,
const shared_ptr< field::FieldAllocator<Value_T> > alloc = nullptr)
{
if( alwaysInitialize )
......@@ -155,7 +149,8 @@ struct AddToStorage< GhostLayerField_T, BlockStorage_T,
} // namespace internal
template< typename GhostLayerField_T, typename BlockStorage_T >
template< typename GhostLayerField_T, typename BlockStorage_T, typename = std::enable_if_t<GhostLayerField_T::OLD>>
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
const typename GhostLayerField_T::value_type & initValue = typename GhostLayerField_T::value_type(),
......@@ -171,8 +166,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
alwaysInitialize, initFunction, requiredSelectors, incompatibleSelectors );
}
template< typename GhostLayerField_T, typename BlockStorage_T >
template< typename GhostLayerField_T, typename BlockStorage_T>
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
const uint_t fSize,
......@@ -189,7 +183,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
alwaysInitialize, initFunction, requiredSelectors, incompatibleSelectors );
}
template< typename GhostLayerField_T, typename BlockStorage_T >
template< typename GhostLayerField_T, typename BlockStorage_T, typename = std::enable_if_t<GhostLayerField_T::OLD>>
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
const typename GhostLayerField_T::value_type & initValue,
......@@ -221,7 +215,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
}
template< typename GhostLayerField_T, typename BlockStorage_T >
template< typename GhostLayerField_T, typename BlockStorage_T, typename = std::enable_if_t<GhostLayerField_T::OLD>>
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize,
......@@ -262,7 +256,7 @@ BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
}
template< typename GhostLayerField_T, typename BlockStorage_T >
template< typename GhostLayerField_T, typename BlockStorage_T, typename = std::enable_if_t<GhostLayerField_T::OLD> >
BlockDataID addToStorage( const shared_ptr< BlockStorage_T > & blocks,
const std::string & identifier,
const std::function< Vector3< uint_t > ( const shared_ptr< StructuredBlockStorage > &, IBlock * const ) > calculateSize,
......
......@@ -42,13 +42,13 @@ int main( int argc, char ** argv )
1.0, // dx
oneBlockPerProcess
);
typedef GhostLayerField<cell_idx_t> MyField;
BlockDataID fieldID = field::addToStorage<MyField>( blocks, "Field", 3 );
using Field_T = GhostLayerField<real_t>;
BlockDataID fieldID = field::addToStorage<Field_T>( blocks, "Field", 3 );
for( auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt )
{
MyField * field = blockIt->getData<MyField>( fieldID );
Field_T * field = blockIt->getData<Field_T>( fieldID );
for( auto cellIt = field->beginXYZ(); cellIt != field->end(); ++cellIt )
{
......@@ -61,13 +61,13 @@ int main( int argc, char ** argv )
}
MyField gatheredField(0,0,0,0,0);
Field_T gatheredField(0,0,0,0,0);
CellInterval boundingBox = blocks->getDomainCellBB();
boundingBox.min()[ 1 ] = 10;
boundingBox.max()[ 1 ] = 29;
auto targetRank = MPIManager::instance()->numProcesses() -1;
field::gather<MyField>( gatheredField, blocks, fieldID, boundingBox, targetRank );
field::gather<Field_T>( gatheredField, blocks, fieldID, boundingBox, targetRank );
WALBERLA_EXCLUSIVE_WORLD_SECTION( targetRank )
{
......@@ -80,7 +80,7 @@ int main( int argc, char ** argv )
}
return 0;
return EXIT_SUCCESS;
}
}
......
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