Commit f52815a3 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Simplifies implementation of BlockFunction::getNumberOfLocalDoFs()

The previous implementation relied on directly using the templated
free function numberOfLocalDoFs(). In order to call the correct one
a switch statement was used based on the FunctionKind of the
corresponding sub-function.

Consequently we would need to update this code piece for every new
type of sub-function that we want to use.

The new implementation is directly using
GenericFunction::getNumberOfLocalDoFs().
parent 2b3d27c9
Pipeline #33789 passed with stages
in 97 minutes and 12 seconds
......@@ -239,32 +239,9 @@ class BlockFunction
uint_t getNumberOfLocalDoFs( uint_t level ) const
{
uint_t nDoFs = 0;
const PrimitiveStorage& storage = *( this->getStorage() );
for ( uint_t k = 0; k < subFunc_.size(); ++k )
{
switch ( subFunc_[k]->getFunctionKind() )
{
case functionTraits::P1_FUNCTION:
nDoFs += numberOfLocalDoFs< P1FunctionTag >( storage, level );
break;
case functionTraits::P2_FUNCTION:
nDoFs += numberOfLocalDoFs< P2FunctionTag >( storage, level );
break;
case functionTraits::P1_VECTOR_FUNCTION:
nDoFs += numberOfLocalDoFs< P1VectorFunctionTag >( storage, level );
break;
case functionTraits::P2_VECTOR_FUNCTION:
nDoFs += numberOfLocalDoFs< P2VectorFunctionTag >( storage, level );
break;
case functionTraits::EDGE_DOF_FUNCTION:
nDoFs += numberOfLocalDoFs< EdgeDoFFunctionTag >( storage, level );
break;
case functionTraits::DG_FUNCTION:
nDoFs += numberOfLocalDoFs< VertexDoFFunctionTag >( storage, level );
break;
default:
WALBERLA_ABORT( "Blockfunction::getNumberOfLocalDoFs() encountered unsupported FunctionKind!" );
}
nDoFs += subFunc_[k]->getNumberOfLocalDoFs( level );
}
return nDoFs;
}
......@@ -302,7 +279,6 @@ class BlockFunction
} );
return subFuncVec;
}
};
// Special version of numberOfLocalDoFs for GenericFunctions
......
......@@ -41,7 +41,7 @@ class FunctionWrapper final : public GenericFunction< typename FunctionTrait< fu
// typedef func_t FunctionType;
// how about this instead:
using WrappedFuncType = func_t;
template< typename VType >
template < typename VType >
using WrappedFuncKind = typename WrappedFuncType::template FunctionType< VType >;
/// No need for this one, if we do not implement a setter method for wrappedFunc_;
......@@ -168,21 +168,10 @@ class FunctionWrapper final : public GenericFunction< typename FunctionTrait< fu
uint_t getNumberOfLocalDoFs( uint_t level ) const
{
return numberOfLocalDoFs< typename FunctionType::Tag >( *( getStorage() ), level );
auto storage = wrappedFunc_->getStorage();
return numberOfLocalDoFs< typename FunctionTrait< WrappedFuncType >::Tag >( *storage, level );
}
/// conversion to/from linear algebra representation
/// @{
#if 0
#ifdef HYTEG_BUILD_WITH_PETSC
void toVector( const P2VectorFunction< PetscInt >& numerator,
const std::shared_ptr< VectorProxy >& vec,
uint_t level,
DoFType flag );
/// @}
#endif
#endif
private:
std::unique_ptr< func_t > wrappedFunc_;
};
......
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