Loading src/functions/tnlConstantFunction.h +3 −4 Original line number Diff line number Diff line Loading @@ -21,15 +21,14 @@ #include <core/vectors/tnlStaticVector.h> template< int FunctionDimensions, typename Vertex = tnlStaticVector< FunctionDimensions, double >, typename Device = tnlHost > typename Real > class tnlConstantFunction { public: enum { Dimensions = FunctionDimensions }; typedef Vertex VertexType; typedef typename VertexType::RealType RealType; typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; tnlConstantFunction(); Loading src/functions/tnlTestFunction.h +37 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,43 @@ #define TNLTESTFUNCTION_H_ template< int FunctionDimensions, typename Real, typename Device > class tnlTestingFunction { protected: enum TestFunctions{ none, constant, expBump, sinBumps, sinWaves }; public: enum{ Dimensions = FunctionDimensions }; typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; tnlTestingFunction(); bool init( const tnlParameterContainer& parameters ); template< typename Vertex, typename Real = typename Vertex::RealType > Real getValue( const Vertex& vertex ) const; ~tnlTestingFunction(); protected: void* function; TestFunction functionType; }; #include <implementation/functions/tnlTestFunction_impl.h> #endif /* TNLTESTFUNCTION_H_ */ src/implementation/functions/tnlTestFunction_impl.h 0 → 100644 +97 −0 Original line number Diff line number Diff line /*************************************************************************** tnlTestFunction_impl.h - description ------------------- begin : Aug 3, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLTESTFUNCTION_IMPL_H_ #define TNLTESTFUNCTION_IMPL_H_ #include <functions/tnlConstantFunction.h> #include <functions/tnlExpBumpFunction.h> #include <functions/tnlSinBumpsFunction.h> #include <functions/tnlSinWavesFunction.h> template< int FunctionDimensions, typename Real, typename Device > tnlTestingFunction< FunctionDimensions, Real, Device >:: tnlTestingFunction() : function( 0 ), functionType( none ) { } template< int FunctionDimensions, typename Real, typename Device > bool tnlTestingFunction< FunctionDimensions, Real, Device >:: init( const tnlParameterContainer& parameters ) { const tnlString& testFunction = parameters.getParameter< tnlString >( "test-function" ); if( testFunction == "constant" ) { typedef tnlConstantFunction< Dimensions, Real > FunctionType; FunctionType* auxFunction = new FunctionType; if( ! auxFunction->init( parameters ) ) { delete auxFunction; return false; } functionType = constant; if( Device::DeviceType == tnlHostType ) { function = auxFunction; } if( Device::DeviceType == tnlCudaType ) { function = passToDevice( *auxFunction ); } } if( testFunction == "exp-bump" ) { } if( testFunction == "sin-bumps" ) { } if( testFunction == "sin-waves" ) { } } template< int FunctionDimensions, typename Real, typename Device > tnlTestingFunction< FunctionDimensions, Real, Device >:: ~tnlTestingFunction() { if( Device::DeviceType == tnlHostType ) { switch( functionType ) { case constant: delete ( tnlConstantFunction< Dimensions, Real> * ) function; break; } } } #endif /* TNLTESTFUNCTION_IMPL_H_ */ Loading
src/functions/tnlConstantFunction.h +3 −4 Original line number Diff line number Diff line Loading @@ -21,15 +21,14 @@ #include <core/vectors/tnlStaticVector.h> template< int FunctionDimensions, typename Vertex = tnlStaticVector< FunctionDimensions, double >, typename Device = tnlHost > typename Real > class tnlConstantFunction { public: enum { Dimensions = FunctionDimensions }; typedef Vertex VertexType; typedef typename VertexType::RealType RealType; typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; tnlConstantFunction(); Loading
src/functions/tnlTestFunction.h +37 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,43 @@ #define TNLTESTFUNCTION_H_ template< int FunctionDimensions, typename Real, typename Device > class tnlTestingFunction { protected: enum TestFunctions{ none, constant, expBump, sinBumps, sinWaves }; public: enum{ Dimensions = FunctionDimensions }; typedef Real RealType; typedef tnlStaticVector< Dimensions, Real > VertexType; tnlTestingFunction(); bool init( const tnlParameterContainer& parameters ); template< typename Vertex, typename Real = typename Vertex::RealType > Real getValue( const Vertex& vertex ) const; ~tnlTestingFunction(); protected: void* function; TestFunction functionType; }; #include <implementation/functions/tnlTestFunction_impl.h> #endif /* TNLTESTFUNCTION_H_ */
src/implementation/functions/tnlTestFunction_impl.h 0 → 100644 +97 −0 Original line number Diff line number Diff line /*************************************************************************** tnlTestFunction_impl.h - description ------------------- begin : Aug 3, 2014 copyright : (C) 2014 by Tomas Oberhuber email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef TNLTESTFUNCTION_IMPL_H_ #define TNLTESTFUNCTION_IMPL_H_ #include <functions/tnlConstantFunction.h> #include <functions/tnlExpBumpFunction.h> #include <functions/tnlSinBumpsFunction.h> #include <functions/tnlSinWavesFunction.h> template< int FunctionDimensions, typename Real, typename Device > tnlTestingFunction< FunctionDimensions, Real, Device >:: tnlTestingFunction() : function( 0 ), functionType( none ) { } template< int FunctionDimensions, typename Real, typename Device > bool tnlTestingFunction< FunctionDimensions, Real, Device >:: init( const tnlParameterContainer& parameters ) { const tnlString& testFunction = parameters.getParameter< tnlString >( "test-function" ); if( testFunction == "constant" ) { typedef tnlConstantFunction< Dimensions, Real > FunctionType; FunctionType* auxFunction = new FunctionType; if( ! auxFunction->init( parameters ) ) { delete auxFunction; return false; } functionType = constant; if( Device::DeviceType == tnlHostType ) { function = auxFunction; } if( Device::DeviceType == tnlCudaType ) { function = passToDevice( *auxFunction ); } } if( testFunction == "exp-bump" ) { } if( testFunction == "sin-bumps" ) { } if( testFunction == "sin-waves" ) { } } template< int FunctionDimensions, typename Real, typename Device > tnlTestingFunction< FunctionDimensions, Real, Device >:: ~tnlTestingFunction() { if( Device::DeviceType == tnlHostType ) { switch( functionType ) { case constant: delete ( tnlConstantFunction< Dimensions, Real> * ) function; break; } } } #endif /* TNLTESTFUNCTION_IMPL_H_ */