Commit 9be3e8d2 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing the code to work nvcc.

parent d46c6604
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -103,5 +103,51 @@ class tnlMeshFunctionNormGetter< tnlMeshFunction< tnlGrid< Dimensions, MeshReal,
      }
};

/****
 * Specialization for CUDA devices
 */
template< int Dimensions,
          typename MeshReal,
          typename MeshIndex,
          int EntityDimensions >
class tnlMeshFunctionNormGetter< tnlMeshFunction< tnlGrid< Dimensions, MeshReal, tnlCuda, MeshIndex >, EntityDimensions >,
                                 tnlGrid< Dimensions, MeshReal, tnlCuda, MeshIndex > >
{
   public:
      
      typedef tnlMeshFunction< tnlGrid< Dimensions, MeshReal, tnlCuda, MeshIndex >, EntityDimensions > MeshFunctionType;
      typedef tnlGrid< Dimensions, MeshReal, tnlCuda, MeshIndex > GridType;
      typedef MeshReal MeshRealType;
      typedef tnlCuda DeviceType;
      typedef MeshIndex MeshIndexType;
      typedef typename MeshFunctionType::RealType RealType;
      typedef typename MeshFunctionType::MeshType MeshType;
      typedef typename MeshType::Face EntityType;
      
      static RealType getNorm( const MeshFunctionType& function,
                               const RealType& p )
      {
         if( EntityDimensions == Dimensions )
         {
            if( p == 1.0 )
               return function.getMesh().getCellMeasure() * function.getData().lpNorm( 1.0 );
            if( p == 2.0 )
               return sqrt( function.getMesh().getCellMeasure() ) * function.getData().lpNorm( 2.0 );
            return pow( function.getMesh().getCellMeasure(), 1.0 / p ) * function.getData().lpNorm( p );
         }
         if( EntityDimensions > 0 )
         {
            tnlAssert( false, std::cerr << "Not implemented yet." << std::endl );
         }
         
         if( p == 1.0 )
            return function.getData().lpNorm( 1.0 );
         if( p == 2.0 )
            return function.getData().lpNorm( 2.0 );
         return function.getData().lpNorm( p );
      }
};


#endif	/* TNLMESHFUNCTIONNORMGETTER_H */
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ class tnlExactDifference
      }
      
      template< typename Function >
      __cuda_callable__
      typename Function::RealType operator()( 
         const Function& function,
         const typename Function::VertexType& vertex,
+14 −0
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ class tnlFiniteDifferences<
   static_assert( YDifference != 0 || ZDifference != 0,
      "You try to use default finite difference with 'wrong' template parameters. It means that required finite difference was not implmented yet." );
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {
@@ -63,7 +65,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -88,7 +92,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -113,7 +119,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -138,7 +146,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -162,7 +172,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -186,7 +198,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
+26 −0
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ class tnlFiniteDifferences<
   static_assert( ZDifference != 0,
      "You try to use default finite difference with 'wrong' template parameters. It means that required finite difference was not implmented yet." );
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {
@@ -63,7 +65,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -85,7 +89,9 @@ class tnlFiniteDifferences<
   0, 1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -110,7 +116,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -132,7 +140,9 @@ class tnlFiniteDifferences<
   0, -1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -157,7 +167,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -179,7 +191,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -205,7 +219,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -229,7 +245,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -253,7 +271,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -277,7 +297,9 @@ class tnlFiniteDifferences<
   0 ,1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -301,7 +323,9 @@ class tnlFiniteDifferences<
   0, -1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -326,7 +350,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
+36 −0
Original line number Diff line number Diff line
@@ -32,7 +32,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -54,7 +56,9 @@ class tnlFiniteDifferences<
   0, 1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -76,7 +80,9 @@ class tnlFiniteDifferences<
   0, 0, 1 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -101,7 +107,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -123,7 +131,9 @@ class tnlFiniteDifferences<
   0, -1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__      
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -145,7 +155,9 @@ class tnlFiniteDifferences<
   0, 0, -1 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -170,7 +182,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -192,7 +206,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -214,7 +230,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -239,7 +257,9 @@ class tnlFiniteDifferences<
   1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -263,7 +283,9 @@ class tnlFiniteDifferences<
   -1, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -287,7 +309,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -311,7 +335,9 @@ class tnlFiniteDifferences<
   0, 1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -335,7 +361,9 @@ class tnlFiniteDifferences<
   0, -1, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -359,7 +387,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -383,7 +413,9 @@ class tnlFiniteDifferences<
   0, 0 ,1 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -407,7 +439,9 @@ class tnlFiniteDifferences<
   0, 0, -1 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {         
@@ -431,7 +465,9 @@ class tnlFiniteDifferences<
   0, 0, 0 >
{   
   public:
      
      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      static Real getValue( const MeshFunction& u,
                            const MeshEntity& entity )
      {