Commit 926a6320 authored by Marcus Mohr's avatar Marcus Mohr
Browse files

Extends VTKOuput support for Generic- and BlockFunctions

Commit makes VTKOutput::add() accept Generic- and BlockFunctions of
other value types than real_t.
parent 87190569
Pipeline #33762 passed with stages
in 115 minutes and 10 seconds
......@@ -83,6 +83,10 @@ void VTKDGDoFWriter::writeScalarFunction( std::ostream&
bool write2D,
vtk::DataFormat vtkDataFormat )
{
// hopefully at some point we will have DGFunctions also in 3D :)
WALBERLA_UNUSED( write2D );
vtk::openDataElement( output, typeToString< real_t >(), function.getFunctionName(), 1, vtkDataFormat );
for ( const auto& it : storage->getFaces() )
......
......@@ -73,41 +73,34 @@ void VTKOutput::add( const P2P1TaylorHoodFunction< real_t >& function )
add( function.p );
}
void VTKOutput::add( const BlockFunction< real_t >& function )
{
for ( uint_t k = 0; k < function.getNumberOfBlocks(); k++ )
{
add( function[k] );
}
}
void VTKOutput::add( const GenericFunction< real_t >& function )
template < typename value_t >
void VTKOutput::add( const GenericFunction< value_t >& function )
{
bool matchFound = false;
switch ( function.getFunctionKind() )
{
case functionTraits::P1_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< P1Function< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< P1Function< value_t > > >( function );
break;
case functionTraits::P2_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< P2Function< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< P2Function< value_t > > >( function );
break;
case functionTraits::P1_VECTOR_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< P1VectorFunction< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< P1VectorFunction< value_t > > >( function );
break;
case functionTraits::P2_VECTOR_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< P2VectorFunction< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< P2VectorFunction< value_t > > >( function );
break;
case functionTraits::EDGE_DOF_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< EdgeDoFFunction< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< EdgeDoFFunction< value_t > > >( function );
break;
case functionTraits::DG_FUNCTION:
matchFound = tryUnwrapAndAdd< FunctionWrapper< DGFunction< real_t > > >( function );
matchFound = tryUnwrapAndAdd< FunctionWrapper< DGFunction< value_t > > >( function );
break;
default:
......@@ -358,4 +351,11 @@ void VTKOutput::syncAllFunctions( const uint_t& level ) const
}
}
// -------------------------
// Explicit Instantiations
// -------------------------
template void VTKOutput::add( const GenericFunction< double >& function );
template void VTKOutput::add( const GenericFunction< int32_t >& function );
template void VTKOutput::add( const GenericFunction< int64_t >& function );
} // namespace hyteg
......@@ -112,12 +112,21 @@ class VTKOutput
dgFunctions_.push_back( function );
}
template < typename value_t >
inline void add( const BlockFunction< value_t >& function )
{
for ( uint_t k = 0; k < function.getNumberOfBlocks(); k++ )
{
add( function[k] );
}
}
template < typename value_t >
void add( const GenericFunction< value_t >& function );
void add( const P1StokesFunction< real_t >& function );
void add( const P2P1TaylorHoodFunction< real_t >& function );
void add( const GenericFunction< real_t >& function );
void add( const BlockFunction< real_t >& function );
/// Writes the VTK output only if writeFrequency > 0 and timestep % writeFrequency == 0.
/// Therefore always writes output if timestep is 0.
/// Appends the time step to the filename.
......@@ -195,8 +204,8 @@ class VTKOutput
add( function.unwrap() );
}
template < typename WrapperFunc >
bool tryUnwrapAndAdd( const GenericFunction< real_t >& function )
template < typename WrapperFunc, typename value_t >
bool tryUnwrapAndAdd( const GenericFunction< value_t >& function )
{
bool success = false;
const WrapperFunc* aux = dynamic_cast< const WrapperFunc* >( &function );
......
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