Skip to content
Snippets Groups Projects
Commit e2b5c900 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing the test function.

parent b901931a
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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_ */
/***************************************************************************
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_ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment