Commit 46933641 authored by Andreas Wagner's avatar Andreas Wagner
Browse files

matches DGFunction add signatures to other function spaces

parent fc12c96d
......@@ -85,10 +85,13 @@ class DGFunction final : public Function< DGFunction< ValueType > >
uint_t level,
DoFType flag = All );
inline void add( const std::vector< ValueType > scalars,
const std::vector< DGFunction< ValueType >* > functions,
uint_t level,
DoFType flag = All );
inline void add( ValueType scalar, uint_t level, DoFType flag = All ) const;
inline void add( const std::vector< ValueType >& scalars,
const std::vector< std::reference_wrapper< const DGFunction< ValueType > > >& functions,
uint_t level,
DoFType flag = All ) const;
inline void enumerate( uint_t level, ValueType offset );
inline void enumerate( uint_t level );
......@@ -150,8 +153,6 @@ class DGFunction final : public Function< DGFunction< ValueType > >
uint_t level,
DoFType flag = All ) const;
void add( ValueType scalar, uint_t level, DoFType flag = All ) const;
void copyFrom( const DGFunction< ValueType >& other, const uint_t& level ) const
{
WALBERLA_ABORT( "DGFunction::copyFrom not implemented!" )
......@@ -190,14 +191,6 @@ class DGFunction final : public Function< DGFunction< ValueType > >
WALBERLA_ABORT( "DGFunction::swap not implemented!" )
}
void add( const std::vector< ValueType >& scalars,
const std::vector< std::reference_wrapper< const DGFunction< ValueType > > >& functions,
uint_t level,
DoFType flag = All ) const
{
WALBERLA_ABORT( "DGFunction::add for vector of functions not implemented!" )
}
/// @}
private:
......@@ -211,10 +204,10 @@ class DGFunction final : public Function< DGFunction< ValueType > >
};
template < typename ValueType >
void DGFunction< ValueType >::add( const std::vector< ValueType > scalars,
const std::vector< DGFunction< ValueType >* > functions,
uint_t level,
DoFType flag )
void DGFunction< ValueType >::add( const std::vector< ValueType >& scalars,
const std::vector< std::reference_wrapper< const DGFunction< ValueType > > >& functions,
uint_t level,
DoFType flag ) const
{
// Collect all source IDs in a vector
// std::vector<PrimitiveDataID<FunctionMemory< ValueType >, Vertex>> srcVertexIDs;
......@@ -225,7 +218,7 @@ void DGFunction< ValueType >::add( const std::vector< ValueType >
{
// srcVertexIDs.push_back(function->vertexDataID_);
// srcEdgeIDs.push_back(function->edgeDataID_);
srcFaceIDs.push_back( function->faceDataID_ );
srcFaceIDs.push_back( function.get().faceDataID_ );
}
for ( auto& it : this->getStorage()->getFaces() )
......
......@@ -45,10 +45,12 @@ int main( int argc, char** argv )
const uint_t maxLevel = 4;
hyteg::DGFunction< real_t > x( "x", storage, minLevel, maxLevel );
hyteg::DGFunction< real_t > y( "y", storage, minLevel, maxLevel );
hyteg::DGFunction< real_t > z( "z", storage, minLevel, maxLevel );
x.interpolate( 0., maxLevel, All );
// check adding on the whole domain
// check adding a scalar
{
WALBERLA_CHECK_FLOAT_EQUAL( x.getMinValue( maxLevel, All ), 0. );
WALBERLA_CHECK_FLOAT_EQUAL( x.getMaxValue( maxLevel, All ), 0. );
......@@ -63,5 +65,21 @@ int main( int argc, char** argv )
WALBERLA_CHECK_FLOAT_EQUAL( x.getMaxValue( maxLevel, All ), 1. );
}
// check adding a scalar
{
x.interpolate(1, maxLevel, All);
y.interpolate(2, maxLevel, All);
z.interpolate(3, maxLevel, All);
x.add( {-1., 3.}, {y, z}, maxLevel, All );
// the min/max value functions
x.communicate< hyteg::Vertex, hyteg::Edge >( maxLevel );
x.communicate< hyteg::Edge, hyteg::Face >( maxLevel );
WALBERLA_CHECK_FLOAT_EQUAL( x.getMinValue( maxLevel, All ), 8. );
WALBERLA_CHECK_FLOAT_EQUAL( x.getMaxValue( maxLevel, All ), 8. );
}
return 0;
}
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