Commit 8277447c authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Merge branch 'master' into wagnandr/facedoffunction

parents 83988939 e2ca9545
......@@ -30,6 +30,10 @@ template < typename value_t >
class P2P1TaylorHoodBlockFunction : public BlockFunction< value_t >
{
public:
template < typename VType >
using FunctionType = P2P1TaylorHoodBlockFunction< VType >;
P2P1TaylorHoodBlockFunction( const std::string& name,
const std::shared_ptr< PrimitiveStorage >& storage,
size_t minLevel,
......
......@@ -30,6 +30,10 @@ template < typename ValueType >
class DGFunction : public FaceDoFFunction< ValueType >
{
public:
typedef ValueType valueType;
template < typename VType >
using FunctionType = DGFunction< VType >;
DGFunction( const std::string& name, const std::shared_ptr< PrimitiveStorage >& storage, uint_t minLevel, uint_t maxLevel )
: FaceDoFFunction< ValueType >( name, storage, minLevel, maxLevel )
......
......@@ -37,6 +37,11 @@ template < typename ValueType >
class FaceDoFFunction : public Function< FaceDoFFunction< ValueType > >
{
public:
typedef ValueType valueType;
template < typename VType >
using FunctionType = FaceDoFFunction< VType >;
FaceDoFFunction( const std::string& name, const std::shared_ptr< PrimitiveStorage >& storage, uint_t minLevel, uint_t maxLevel )
: FaceDoFFunction( name, storage, minLevel, maxLevel, BoundaryCondition::create0123BC() )
{}
......
......@@ -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,13 @@ class BlockFunction
} );
return subFuncVec;
}
};
// Special version of numberOfLocalDoFs for GenericFunctions
template < typename value_t >
inline uint_t numberOfLocalDoFs( const BlockFunction< value_t >& func, const uint_t& level )
{
return func.getNumberOfLocalDoFs( level );
}
} // namespace hyteg
......@@ -182,6 +182,13 @@ inline uint_t numberOfLocalDoFs< P2P2StokesFunctionTag >( const PrimitiveStorage
return ( primitiveStorage.hasGlobalCells() ? 4 : 3 ) * numberOfLocalDoFs< P2FunctionTag >( primitiveStorage, level );
}
/// variant of numberOfLocalDoFs that works on a function object
template < typename func_t >
inline uint_t numberOfLocalDoFs( const func_t& func, const uint_t& level )
{
return numberOfLocalDoFs< typename func_t::Tag >( *( func.getStorage() ), level );
}
template < typename FunctionTag_T >
inline uint_t numberOfGlobalDoFs( const PrimitiveStorage& primitiveStorage,
const uint_t& level,
......
......@@ -36,7 +36,13 @@ class FunctionWrapper final : public GenericFunction< typename FunctionTrait< fu
public:
typedef typename FunctionTrait< func_t >::ValueType value_t;
typedef typename FunctionTrait< func_t >::Tag Tag;
typedef func_t FunctionType;
// is this really helpful, as it is not templated?
// typedef func_t FunctionType;
// how about this instead:
using WrappedFuncType = func_t;
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_;
FunctionWrapper() = delete;
......@@ -156,8 +162,16 @@ class FunctionWrapper final : public GenericFunction< typename FunctionTrait< fu
wrappedFunc_->copyFrom( other.template unwrap< func_t >(), level, localPrimitiveIDsToRank, otherPrimitiveIDsToRank );
};
void enumerate( uint_t level ) const { wrappedFunc_->enumerate( level ); };
void enumerate( uint_t level, value_t& offset ) const { wrappedFunc_->enumerate( level, offset ); };
uint_t getNumberOfLocalDoFs( uint_t level ) const
{
auto storage = wrappedFunc_->getStorage();
return numberOfLocalDoFs< typename FunctionTrait< WrappedFuncType >::Tag >( *storage, level );
}
private:
std::unique_ptr< func_t > wrappedFunc_;
};
......
......@@ -69,6 +69,8 @@ class GenericFunction
virtual functionTraits::FunctionKind getFunctionKind() const = 0;
virtual uint_t getNumberOfLocalDoFs( uint_t level ) const = 0;
virtual std::shared_ptr< PrimitiveStorage > getStorage() const = 0;
virtual void multElementwise( const std::vector< std::reference_wrapper< const GenericFunction< value_t > > >& functions,
......@@ -120,7 +122,16 @@ class GenericFunction
this->setBoundaryCondition( other.getBoundaryCondition() );
};
virtual void enumerate( uint_t level ) const = 0;
virtual void enumerate( uint_t level, value_t& offset ) const = 0;
};
// Special version of numberOfLocalDoFs for GenericFunctions
template < typename value_t >
inline uint_t numberOfLocalDoFs( const GenericFunction< value_t >& func, const uint_t& level )
{
return func.getNumberOfLocalDoFs( level );
}
} // namespace hyteg
......@@ -49,9 +49,7 @@ class PETScVector
const DoFType& flag = All,
const std::string& name = "Vec",
const MPI_Comm& petscCommunicator = walberla::mpi::MPIManager::instance()->comm() )
: PETScVector( numberOfLocalDoFs< typename FunctionType< ValueType >::Tag >( *function.getStorage(), level ),
name,
petscCommunicator )
: PETScVector( numberOfLocalDoFs( function, level ), name, petscCommunicator )
{
createVectorFromFunction( function, numerator, level, flag );
}
......
......@@ -39,6 +39,10 @@ template < typename value_t >
class TestBlockFunction : public BlockFunction< value_t >
{
public:
template < typename VType >
using FunctionType = TestBlockFunction< VType >;
TestBlockFunction( const std::string& name,
const std::shared_ptr< PrimitiveStorage >& storage,
size_t minLevel,
......
......@@ -528,6 +528,9 @@ template < typename value_t >
class P1CahnHilliardFunction : public BlockFunction< value_t >
{
public:
template < typename VType >
using FunctionType = P1CahnHilliardFunction< VType >;
P1CahnHilliardFunction( const std::string& name,
const std::shared_ptr< PrimitiveStorage >& storage,
size_t minLevel,
......
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