diff --git a/src/functions/tnlConstantFunction.h b/src/functions/tnlConstantFunction.h index 67920376c3c241524a6deab53f1bcb427d0f1326..2c6254c5c98377ef744cf71eec2eca677c2729c9 100644 --- a/src/functions/tnlConstantFunction.h +++ b/src/functions/tnlConstantFunction.h @@ -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(); diff --git a/src/functions/tnlTestFunction.h b/src/functions/tnlTestFunction.h index e8cd3c9ee5a83de48f72b01f7a953e8f37d2b673..8a06a3e714e947dad48e77d22cef8e8027b9326d 100644 --- a/src/functions/tnlTestFunction.h +++ b/src/functions/tnlTestFunction.h @@ -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_ */ diff --git a/src/implementation/functions/tnlTestFunction_impl.h b/src/implementation/functions/tnlTestFunction_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..9d8316346eb5ce36680334972e384ba0e9d24e36 --- /dev/null +++ b/src/implementation/functions/tnlTestFunction_impl.h @@ -0,0 +1,97 @@ +/*************************************************************************** + 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_ */