Commit 7ac9c3e5 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Add numberOfGlobalDoFs() for Generic- and BlockFunctions

For similar reasons as explained in [11449739] we introduce a variant of
numberOfGlobalDoFs() that requires a function object.
parent 9add4f33
......@@ -249,6 +249,18 @@ class BlockFunction
return nDoFs;
}
uint_t getNumberOfGlobalDoFs( uint_t level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false ) const
{
uint_t nDoFs = 0;
for ( uint_t k = 0; k < subFunc_.size(); ++k )
{
nDoFs += subFunc_[k]->getNumberOfGlobalDoFs( level, communicator, onRootOnly );
}
return nDoFs;
}
void enumerate( uint_t level ) const
{
uint_t counterDoFs = getNumberOfLocalDoFs( level );
......@@ -284,11 +296,22 @@ class BlockFunction
}
};
// Special version of numberOfLocalDoFs for GenericFunctions
// Special version of numberOfLocalDoFs for BlockFunctions
template < typename value_t >
inline uint_t numberOfLocalDoFs( const BlockFunction< value_t >& func, const uint_t& level )
{
return func.getNumberOfLocalDoFs( level );
}
// Special version of numberOfGlobalDoFs for BlockFunctions
template < typename value_t >
inline uint_t numberOfGlobalDoFs( const BlockFunction< value_t >& func,
const uint_t& level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false )
{
return func.getNumberOfGlobalDoFs( level, communicator, onRootOnly );
}
} // namespace hyteg
......@@ -207,6 +207,16 @@ inline uint_t numberOfGlobalDoFs( const PrimitiveStorage& primitiveStorage,
}
}
/// variant of numberOfGlobalDoFs that works on a function object
template < typename func_t >
inline uint_t numberOfGlobalDoFs( const func_t& func,
const uint_t& level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false )
{
return numberOfGlobalDoFs< typename func_t::Tag >( *( func.getStorage() ), level, communicator, onRootOnly );
}
template < typename FunctionTag_T >
inline uint_t minNumberOfLocalDoFs( const PrimitiveStorage& primitiveStorage, const uint_t& level )
{
......
......@@ -184,6 +184,14 @@ class FunctionWrapper final : public GenericFunction< typename FunctionTrait< fu
return numberOfLocalDoFs< typename FunctionTrait< WrappedFuncType >::Tag >( *storage, level );
}
uint_t getNumberOfGlobalDoFs( uint_t level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false ) const
{
auto storage = wrappedFunc_->getStorage();
return numberOfGlobalDoFs< typename FunctionTrait< WrappedFuncType >::Tag >( *storage, level, communicator, onRootOnly );
}
#ifdef HYTEG_BUILD_WITH_PETSC
/// conversion to/from linear algebra representation
/// @{
......
......@@ -73,6 +73,10 @@ class GenericFunction
virtual uint_t getNumberOfLocalDoFs( uint_t level ) const = 0;
virtual uint_t getNumberOfGlobalDoFs( uint_t level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false ) const = 0;
virtual std::shared_ptr< PrimitiveStorage > getStorage() const = 0;
virtual void multElementwise( const std::vector< std::reference_wrapper< const GenericFunction< value_t > > >& functions,
......@@ -151,4 +155,14 @@ inline uint_t numberOfLocalDoFs( const GenericFunction< value_t >& func, const u
return func.getNumberOfLocalDoFs( level );
}
// Special version of numberOfLocalDoFs for GenericFunctions
template < typename value_t >
inline uint_t numberOfGlobalDoFs( const GenericFunction< value_t >& func,
const uint_t& level,
const MPI_Comm& communicator = walberla::mpi::MPIManager::instance()->comm(),
const bool& onRootOnly = false )
{
return func.getNumberOfGlobalDoFs( level, communicator, onRootOnly );
}
} // namespace hyteg
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