Commit 5910a5e8 authored by Jakub Klinkovský's avatar Jakub Klinkovský

Reimplemented getType() function using typeid operator and removed useless getType() methods

Fixes #46
parent 203ee514
#include <iostream>
#include <TNL/param-types.h>
#include <TNL/TypeInfo.h>
#include <TNL/Object.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
......@@ -13,24 +13,12 @@ class MyArray : public Object
{
public:
using HostType = MyArray< Value, Devices::Host >;
static String getType()
{
return "MyArray< " + TNL::getType< Value >() + ", " + TNL::getType< Device >() + " >";
}
String getTypeVirtual() const
{
return getType();
}
static String getSerializationType()
{
return HostType::getType();
return "MyArray< " + TNL::getType< Value >() + ", " + getType< Devices::Host >() + " >";
}
String getSerializationTypeVirtual() const
virtual String getSerializationTypeVirtual() const override
{
return getSerializationType();
}
......@@ -47,11 +35,11 @@ int main()
Object* cudaArrayPtr = &cudaArray;
// Object types
cout << "HostArray type is " << HostArray::getType() << endl;
cout << "hostArrayPtr type is " << hostArrayPtr->getTypeVirtual() << endl;
cout << "HostArray type is " << getType< HostArray >() << endl;
cout << "hostArrayPtr type is " << getType( *hostArrayPtr ) << endl;
cout << "CudaArray type is " << CudaArray::getType() << endl;
cout << "cudaArrayPtr type is " << cudaArrayPtr->getTypeVirtual() << endl;
cout << "CudaArray type is " << getType< CudaArray >() << endl;
cout << "cudaArrayPtr type is " << getType( *cudaArrayPtr ) << endl;
// Object serialization types
cout << "HostArray serialization type is " << HostArray::getSerializationType() << endl;
......@@ -60,4 +48,3 @@ int main()
cout << "CudaArray serialization type is " << CudaArray::getSerializationType() << endl;
cout << "cudaArrayPtr serialization type is " << cudaArrayPtr->getSerializationTypeVirtual() << endl;
}
......@@ -109,7 +109,7 @@ benchmarkSpMV( Benchmark & benchmark,
CudaVector deviceVector, deviceVector2;
// create benchmark group
const std::vector< String > parsedType = parseObjectType( HostMatrix::getType() );
const std::vector< String > parsedType = parseObjectType( getType< HostMatrix >() );
#ifdef HAVE_CUDA
benchmark.createHorizontalGroup( parsedType[ 0 ], 2 );
#else
......
......@@ -33,8 +33,6 @@ class BenchmarkLaplace< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In
typedef Functions::MeshFunction< MeshType > MeshFunctionType;
enum { Dimension = MeshType::getMeshDimension() };
static String getType();
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
Real operator()( const MeshFunction& u,
......@@ -81,8 +79,6 @@ class BenchmarkLaplace< Meshes::Grid< 2,MeshReal, Device, MeshIndex >, Real, Ind
typedef Functions::MeshFunction< MeshType > MeshFunctionType;
enum { Dimension = MeshType::getMeshDimension() };
static String getType();
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
Real operator()( const MeshFunction& u,
......@@ -144,8 +140,6 @@ class BenchmarkLaplace< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind
typedef Functions::MeshFunction< MeshType > MeshFunctionType;
enum { Dimension = MeshType::getMeshDimension() };
static String getType();
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
Real operator()( const MeshFunction& u,
......
......@@ -4,21 +4,6 @@
/****
* 1D problem
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real,
typename Index >
String
BenchmarkLaplace< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
return String( "BenchmarkLaplace< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshReal,
typename Device,
typename MeshIndex,
......@@ -108,21 +93,6 @@ setMatrixElements( const RealType& time,
/****
* 2D problem
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real,
typename Index >
String
BenchmarkLaplace< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
return String( "BenchmarkLaplace< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshReal,
typename Device,
typename MeshIndex,
......@@ -288,21 +258,6 @@ setMatrixElements( const RealType& time,
/****
* 3D problem
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real,
typename Index >
String
BenchmarkLaplace< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
return String( "BenchmarkLaplace< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshReal,
typename Device,
typename MeshIndex,
......
......@@ -40,8 +40,6 @@ class HeatEquationBenchmarkProblem:
using typename BaseType::DofVectorPointer;
HeatEquationBenchmarkProblem();
static String getType();
String getPrologHeader() const;
......
......@@ -16,18 +16,6 @@
template< typename Mesh,
typename BoundaryCondition,
typename RightHandSide,
typename DifferentialOperator,
typename Communicator >
String
HeatEquationBenchmarkProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator, Communicator >::
getType()
{
return String( "HeatEquationBenchmarkProblem< " ) + Mesh :: getType() + " >";
}
template< typename Mesh,
typename BoundaryCondition,
typename RightHandSide,
......
......@@ -78,10 +78,6 @@ class Meshes::Grid< 2, Real, Device, Index > : public tnlObject
Grid();
static String getType();
String getTypeVirtual() const;
static String getSerializationType();
virtual String getSerializationTypeVirtual() const;
......@@ -212,29 +208,13 @@ Meshes::Grid< 2, Real, Device, Index > :: Grid()
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getType()
String Meshes::Grid< 2, Real, Device, Index > :: getSerializationType()
{
return String( "Meshes::Grid< " ) +
convertToString( getMeshDimension() ) + ", " +
String( ::getType< RealType >() ) + ", " +
String( Device :: getDeviceType() ) + ", " +
String( ::getType< IndexType >() ) + " >";
}
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getTypeVirtual() const
{
return this->getType();
}
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getSerializationType()
{
return HostType::getType();
getType< RealType >() + ", " +
getType< Devices::Host >() + ", " +
getType< IndexType >() + " >";
};
template< typename Real,
......@@ -854,10 +834,6 @@ class Meshes::Grid< 2, Real, Device, Index > : public tnlObject
Grid();
static String getType();
String getTypeVirtual() const;
static String getSerializationType();
virtual String getSerializationTypeVirtual() const;
......@@ -977,29 +953,13 @@ Meshes::Grid< 2, Real, Device, Index > :: Grid()
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getType()
String Meshes::Grid< 2, Real, Device, Index > :: getSerializationType()
{
return String( "Meshes::Grid< " ) +
convertToString( getMeshDimension() ) + ", " +
String( ::getType< RealType >() ) + ", " +
String( Device :: getDeviceType() ) + ", " +
String( ::getType< IndexType >() ) + " >";
}
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getTypeVirtual() const
{
return this->getType();
}
template< typename Real,
typename Device,
typename Index >
String Meshes::Grid< 2, Real, Device, Index > :: getSerializationType()
{
return HostType::getType();
getType< RealType >() + ", " +
getType< Devices::Host >() + ", " +
getType< IndexType >() + " >";
};
template< typename Real,
......
......@@ -38,8 +38,6 @@ class Euler : public Solvers::ODE::ExplicitSolver< Problem, SolverMonitor >
Euler();
static String getType();
static void configSetup( Config::ConfigDescription& config,
const String& prefix = "" );
......
......@@ -32,14 +32,6 @@ Euler< Problem, SolverMonitor >::Euler()
{
};
template< typename Problem, typename SolverMonitor >
String Euler< Problem, SolverMonitor >::getType()
{
return String( "Euler< " ) +
Problem :: getType() +
String( " >" );
};
template< typename Problem, typename SolverMonitor >
void Euler< Problem, SolverMonitor >::configSetup( Config::ConfigDescription& config,
const String& prefix )
......
......@@ -35,8 +35,6 @@ class Merson : public Solvers::ODE::ExplicitSolver< Problem, SolverMonitor >
Merson();
static String getType();
static void configSetup( Config::ConfigDescription& config,
const String& prefix = "" );
......
......@@ -94,14 +94,6 @@ Merson< Problem, SolverMonitor >::Merson()
}
};
template< typename Problem, typename SolverMonitor >
String Merson< Problem, SolverMonitor >::getType()
{
return String( "Merson< " ) +
Problem::getType() +
String( " >" );
};
template< typename Problem, typename SolverMonitor >
void Merson< Problem, SolverMonitor >::configSetup( Config::ConfigDescription& config,
const String& prefix )
......
......@@ -38,14 +38,6 @@ class LaxFridrichsContinuityBase
LaxFridrichsContinuityBase()
: artificialViscosity( 1.0 ){};
static String getType()
{
return String( "LaxFridrichsContinuity< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
void setTau(const Real& tau)
{
......
......@@ -36,14 +36,6 @@ class LaxFridrichsEnergyBase
LaxFridrichsEnergyBase()
: artificialViscosity( 1.0 ){};
static String getType()
{
return String( "LaxFridrichsEnergy< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
void setTau(const Real& tau)
{
this->tau = tau;
......
......@@ -46,15 +46,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -119,14 +110,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -200,14 +183,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......
......@@ -46,15 +46,6 @@ class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumY< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -108,14 +99,6 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumY< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -189,14 +172,6 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumY< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......
......@@ -46,15 +46,6 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumZ< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -108,14 +99,6 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumZ< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -169,14 +152,6 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "LaxFridrichsMomentumZ< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......
......@@ -37,14 +37,6 @@ class UpwindContinuityBase
typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer;
typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer;
static String getType()
{
return String( "UpwindContinuity< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
void setTau(const Real& tau)
{
this->tau = tau;
......
......@@ -36,14 +36,6 @@ class UpwindEnergyBase
UpwindEnergyBase()
: artificialViscosity( 1.0 ){};
static String getType()
{
return String( "UpwindEnergy< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
void setTau(const Real& tau)
{
this->tau = tau;
......
......@@ -46,15 +46,6 @@ class UpwindMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Ind
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "UpwindMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -136,14 +127,6 @@ class UpwindMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Ind
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "UpwindMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}
template< typename MeshFunction, typename MeshEntity >
__cuda_callable__
......@@ -268,14 +251,6 @@ class UpwindMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Inde
using typename BaseType::VelocityFieldType;
using typename BaseType::VelocityFieldPointer;
using BaseType::Dimensions;
static String getType()
{
return String( "UpwindMomentumX< " ) +
MeshType::getType() + ", " +
TNL::getType< Real >() + ", " +
TNL::getType< Index >() + " >";
}