From 0c5f7db797e86f65e3b07453360e22ef21d27a69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Oberhuber?= <oberhuber.tomas@gmail.com>
Date: Mon, 6 Feb 2017 20:05:35 +0100
Subject: [PATCH] Adding analytic operators to test function.

---
 .../Hamilton-Jacobi/CMakeLists.txt            |   2 +-
 src/TNL/Functions/TestFunction.h              | 191 +++++++-------
 src/TNL/Functions/TestFunction_impl.h         | 232 ++++++++++++++++--
 src/TNL/Operators/Analytic/CMakeLists.txt     |   1 +
 src/TNL/Operators/Analytic/Heaviside.h        |  12 +-
 src/TNL/Operators/Analytic/Identity.h         |  42 ++++
 src/TNL/Operators/Analytic/Rotation.h         |   6 +-
 src/TNL/Operators/Analytic/Shift.h            |   6 +-
 src/TNL/Operators/Analytic/Sign.h             |  14 +-
 src/TNL/Operators/Analytic/SmoothHeaviside.h  |  14 +-
 10 files changed, 388 insertions(+), 132 deletions(-)
 create mode 100644 src/TNL/Operators/Analytic/Identity.h

diff --git a/src/TNL/Experimental/Hamilton-Jacobi/CMakeLists.txt b/src/TNL/Experimental/Hamilton-Jacobi/CMakeLists.txt
index 3c15fe3315..538e5d99cc 100755
--- a/src/TNL/Experimental/Hamilton-Jacobi/CMakeLists.txt
+++ b/src/TNL/Experimental/Hamilton-Jacobi/CMakeLists.txt
@@ -1,3 +1,3 @@
 ADD_SUBDIRECTORY( Operators )
-ADD_SUBDIRECTORY( Solvers )
+#ADD_SUBDIRECTORY( Solvers )
 
diff --git a/src/TNL/Functions/TestFunction.h b/src/TNL/Functions/TestFunction.h
index 9682cd05e4..d205067025 100644
--- a/src/TNL/Functions/TestFunction.h
+++ b/src/TNL/Functions/TestFunction.h
@@ -26,113 +26,128 @@ class TestFunction : public Domain< FunctionDimensions, SpaceDomain >
 {
    protected:
 
-   enum TestFunctions{ constant,
-                       paraboloid,
-                       expBump,
-                       sinBumps,
-                       sinWave,
-           		        cylinder,
-		                 flowerpot,
-		                 twins,
-                       pseudoSquare,
-                       blob,
-   	   	           paraboloidSDF,
-   	   	           sinWaveSDF,
-   	   	           sinBumpsSDF };
-
-   enum TimeDependence { none,
-                         linear,
-                         quadratic,
-                         cosine };
+      enum TestFunctions{ constant,
+                          paraboloid,
+                          expBump,
+                          sinBumps,
+                          sinWave,
+                          cylinder,
+                          flowerpot,
+                          twins,
+                          pseudoSquare,
+                          blob,
+                          paraboloidSDF,
+                          sinWaveSDF,
+                          sinBumpsSDF };
+
+      enum TimeDependence { none,
+                            linear,
+                            quadratic,
+                            cosine };
+
+      enum Operators { identity,
+                       heaviside };
 
    public:
 
-   enum{ Dimensions = FunctionDimensions };
-   typedef Real RealType;
-   typedef Containers::StaticVector< Dimensions, Real > VertexType;
+      enum{ Dimensions = FunctionDimensions };
+      typedef Real RealType;
+      typedef Containers::StaticVector< Dimensions, Real > VertexType;
+
+      TestFunction();
+
+      static void configSetup( Config::ConfigDescription& config,
+                               const String& prefix = "" );
+
+      bool setup( const Config::ParameterContainer& parameters,
+                 const String& prefix = "" );
+
+      const TestFunction& operator = ( const TestFunction& function );
+
+   #ifdef HAVE_NOT_CXX11
+      template< int XDiffOrder,
+                int YDiffOrder,
+                int ZDiffOrder >
+   #else
+      template< int XDiffOrder = 0,
+                int YDiffOrder = 0,
+                int ZDiffOrder = 0 >
+   #endif
+      __cuda_callable__
+      Real getPartialDerivative( const VertexType& vertex,
+                                 const Real& time = 0 ) const;
+
+      __cuda_callable__
+      Real operator()( const VertexType& vertex,
+                     const Real& time = 0 ) const
+      {
+         return this->getPartialDerivative< 0, 0, 0 >( vertex, time );
+      }
+
+
+   #ifdef HAVE_NOT_CXX11
+      template< int XDiffOrder,
+                int YDiffOrder,
+                int ZDiffOrder >
+   #else
+      template< int XDiffOrder = 0,
+                int YDiffOrder = 0,
+                int ZDiffOrder = 0 >
+   #endif
+      __cuda_callable__
+      Real getTimeDerivative( const VertexType& vertex,
+                              const Real& time = 0 ) const;
 
-   TestFunction();
+   #ifdef HAVE_NOT_CXX11
+      template< typename Vertex >
+      __cuda_callable__
+      Real getTimeDerivative( const Vertex& vertex,
+                              const Real& time = 0 ) const
+      {
+         return this->getTimeDerivative< 0, 0, 0, Vertex >( vertex, time );
+      }
+   #endif
 
-   static void configSetup( Config::ConfigDescription& config,
-                            const String& prefix = "" );
+      std::ostream& print( std::ostream& str ) const;
 
-   bool setup( const Config::ParameterContainer& parameters,
-              const String& prefix = "" );
+      ~TestFunction();
 
-   const TestFunction& operator = ( const TestFunction& function );
+   protected:
 
-#ifdef HAVE_NOT_CXX11
-   template< int XDiffOrder,
-             int YDiffOrder,
-             int ZDiffOrder >
-#else
-   template< int XDiffOrder = 0,
-             int YDiffOrder = 0,
-             int ZDiffOrder = 0 >
-#endif
-   __cuda_callable__
-   Real getPartialDerivative( const VertexType& vertex,
-                              const Real& time = 0 ) const;
+      template< typename FunctionType >
+      bool setupFunction( const Config::ParameterContainer& parameters,
+                         const String& prefix = "" );
+      
+      template< typename OperatorType >
+      bool setupOperator( const Config::ParameterContainer& parameters,
+                          const String& prefix = "" );
 
-   __cuda_callable__
-   Real operator()( const VertexType& vertex,
-                  const Real& time = 0 ) const
-   {
-      return this->getPartialDerivative< 0, 0, 0 >( vertex, time );
-   }
-
-
-#ifdef HAVE_NOT_CXX11
-   template< int XDiffOrder,
-             int YDiffOrder,
-             int ZDiffOrder >
-#else
-   template< int XDiffOrder = 0,
-             int YDiffOrder = 0,
-             int ZDiffOrder = 0 >
-#endif
-   __cuda_callable__
-   Real getTimeDerivative( const VertexType& vertex,
-                           const Real& time = 0 ) const;
-
-#ifdef HAVE_NOT_CXX11
-   template< typename Vertex >
-   __cuda_callable__
-   Real getTimeDerivative( const Vertex& vertex,
-                           const Real& time = 0 ) const
-   {
-      return this->getTimeDerivative< 0, 0, 0, Vertex >( vertex, time );
-   }
-#endif
-
-   std::ostream& print( std::ostream& str ) const;
-
-   ~TestFunction();
 
-   protected:
+      template< typename FunctionType >
+      void deleteFunction();
 
-   template< typename FunctionType >
-   bool setupFunction( const Config::ParameterContainer& parameters,
-                      const String& prefix = "" );
+      template< typename OperatorType >
+      void deleteOperator();
 
-   template< typename FunctionType >
-   void deleteFunction();
+      void deleteFunctions();
 
-   void deleteFunctions();
+      template< typename FunctionType >
+      void copyFunction( const void* function );
 
-   template< typename FunctionType >
-   void copyFunction( const void* function );
+      template< typename FunctionType >
+      std::ostream& printFunction( std::ostream& str ) const;
 
-   template< typename FunctionType >
-   std::ostream& printFunction( std::ostream& str ) const;
+      void* function;
 
-   void* function;
+      void* operator_;
 
-   TestFunctions functionType;
+      TestFunctions functionType;
+      
+      Operators operatorType;
 
-   TimeDependence timeDependence;
+      TimeDependence timeDependence;
 
-   Real timeScale;
+      Real timeScale;
 
 };
 
diff --git a/src/TNL/Functions/TestFunction_impl.h b/src/TNL/Functions/TestFunction_impl.h
index f6629600da..a560bdb116 100644
--- a/src/TNL/Functions/TestFunction_impl.h
+++ b/src/TNL/Functions/TestFunction_impl.h
@@ -32,6 +32,9 @@
 #include <TNL/Functions/Analytic/SinWaveSDF.h>
 #include <TNL/Functions/Analytic/ParaboloidSDF.h>
 
+#include <TNL/Operators/Analytic/Identity.h>
+#include <TNL/Operators/Analytic/Heaviside.h>
+
 namespace TNL {
 namespace Functions {   
 
@@ -42,6 +45,7 @@ template< int FunctionDimensions,
 TestFunction< FunctionDimensions, Real, Device >::
 TestFunction()
 : function( 0 ),
+  operator_( 0 ),
   timeDependence( none ),
   timeScale( 1.0 )
 {
@@ -69,6 +73,7 @@ configSetup( Config::ConfigDescription& config,
       config.addEntryEnum( "paraboloid-sdf" );      
       config.addEntryEnum( "sin-wave-sdf" );
       config.addEntryEnum( "sin-bumps-sdf" );
+      config.addEntryEnum( "heaviside-of-paraboloid" );
 
    config.addEntry     < double >( prefix + "constant", "Value of the constant function.", 0.0 );
    config.addEntry     < double >( prefix + "wave-length", "Wave length of the sine based test functions.", 1.0 );
@@ -131,6 +136,36 @@ setupFunction( const Config::ParameterContainer& parameters,
    return true;
 }
 
+template< int FunctionDimensions,
+          typename Real,
+          typename Device >
+   template< typename OperatorType >
+bool
+TestFunction< FunctionDimensions, Real, Device >::
+setupOperator( const Config::ParameterContainer& parameters,
+               const String& prefix )
+{
+   OperatorType* auxOperator = new OperatorType;
+   if( ! auxOperator->setup( parameters, prefix ) )
+   {
+      delete auxOperator;
+      return false;
+   }
+
+   if( std::is_same< Device, Devices::Host >::value )
+   {
+      this->operator_ = auxOperator;
+   }
+   if( std::is_same< Device, Devices::Cuda >::value )
+   {
+      this->operator_ = Devices::Cuda::passToDevice( *auxOperator );
+      delete auxOperator;
+      if( ! checkCudaDevice )
+         return false;
+   }
+   return true;
+}
+
 template< int FunctionDimensions,
           typename Real,
           typename Device >
@@ -140,6 +175,7 @@ setup( const Config::ParameterContainer& parameters,
        const String& prefix )
 {
    using namespace TNL::Functions::Analytic;
+   using namespace TNL::Operators::Analytic;
    std::cout << "Test function setup ... " << std::endl;
    const String& timeDependence =
             parameters.getParameter< String >(
@@ -158,66 +194,132 @@ setup( const Config::ParameterContainer& parameters,
    this->timeScale = parameters.getParameter< double >( prefix + "time-scale" );
 
    const String& testFunction = parameters.getParameter< String >( prefix + "test-function" );
-  std::cout << "Test function ... " << testFunction << std::endl;
+   std::cout << "Test function ... " << testFunction << std::endl;
    if( testFunction == "constant" )
    {
-      typedef Analytic::Constant< Dimensions, Real > FunctionType;
+      typedef Constant< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = constant;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "paraboloid" )
    {
       typedef Paraboloid< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = paraboloid;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }   
    if( testFunction == "exp-bump" )
    {
       typedef ExpBump< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = expBump;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "sin-bumps" )
    {
       typedef SinBumps< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = sinBumps;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "sin-wave" )
    {
       typedef SinWave< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = sinWave;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "cylinder" )
    {
       typedef Cylinder< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = cylinder;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "flowerpot" )
    {
       typedef Flowerpot< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = flowerpot;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "twins" )
    {
       typedef Twins< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = twins;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "pseudoSquare" )
    {
       typedef PseudoSquare< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = pseudoSquare;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    if( testFunction == "blob" )
    {
       typedef Blob< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
       functionType = blob;
-      return setupFunction< FunctionType >( parameters );
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
+   }
+   if( testFunction == "paraboloid-sdf" )
+   {
+      typedef ParaboloidSDF< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
+      functionType = paraboloidSDF;
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
+   }   
+   if( testFunction == "sin-bumps-sdf" )
+   {
+      typedef SinBumpsSDF< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
+      functionType = sinBumpsSDF;
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
+   }   
+   if( testFunction == "sin-wave-sdf" )
+   {
+      typedef SinWaveSDF< Dimensions, Real > FunctionType;
+      typedef Identity< FunctionType > OperatorType;
+      functionType = sinWaveSDF;
+      operatorType = identity;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
+   }
+   if( testFunction == "heaviside-of-paraboloid" )
+   {
+      typedef Paraboloid< Dimensions, Real > FunctionType;
+      typedef Heaviside< FunctionType > OperatorType;
+      functionType = paraboloid;
+      operatorType = heaviside;
+      return ( setupFunction< FunctionType >( parameters, prefix ) && 
+               setupOperator< OperatorType >( parameters, prefix ) );
    }
    std::cerr << "Unknown function " << testFunction << std::endl;
    return false;
@@ -452,6 +554,26 @@ deleteFunction()
    }
 }
 
+template< int FunctionDimensions,
+          typename Real,
+          typename Device >
+   template< typename OperatorType >
+void
+TestFunction< FunctionDimensions, Real, Device >::
+deleteOperator()
+{
+   if( std::is_same< Device, Devices::Host >::value )
+   {
+      if( operator_ )
+         delete ( OperatorType * ) operator_;
+   }
+   if( std::is_same< Device, Devices::Cuda >::value )
+   {
+      if( operator_ )
+         Devices::Cuda::freeFromDevice( ( OperatorType * ) operator_ );
+   }
+}
+
 template< int FunctionDimensions,
           typename Real,
           typename Device >
@@ -460,48 +582,104 @@ TestFunction< FunctionDimensions, Real, Device >::
 deleteFunctions()
 {
    using namespace TNL::Functions::Analytic;
+   using namespace TNL::Operators::Analytic;
    switch( functionType )
    {
       case constant:
-         deleteFunction< Constant< Dimensions, Real> >();
+      {
+         typedef Constant< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case paraboloid:
-         deleteFunction< Paraboloid< Dimensions, Real> >();
-         break;
+      {
+         typedef Paraboloid< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         if( operatorType == identity )
+            deleteOperator< Identity< FunctionType> >();
+         if( operatorType == heaviside )
+            deleteOperator< Heaviside< FunctionType> >();
+         break;
+      }
       case expBump:
-         deleteFunction< ExpBump< Dimensions, Real> >();
+      {
+         typedef ExpBump< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case sinBumps:
-         deleteFunction< SinBumps< Dimensions, Real> >();
+      {
+         typedef SinBumps< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case sinWave:
-         deleteFunction< SinWave< Dimensions, Real> >();
+      {
+         typedef SinWave< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case cylinder:
-         deleteFunction< Cylinder< Dimensions, Real> >();
+      {
+         typedef Cylinder< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case flowerpot:
-         deleteFunction< Flowerpot< Dimensions, Real> >();
+      {
+         typedef Flowerpot< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case twins:
-         deleteFunction< Twins< Dimensions, Real> >();
+      {
+         typedef Twins< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case pseudoSquare:
-         deleteFunction< PseudoSquare< Dimensions, Real> >();
+      {
+         typedef PseudoSquare< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case blob:
-         deleteFunction< Blob< Dimensions, Real> >();
+      {
+         typedef Blob< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
-
+      }
+      
       case paraboloidSDF:
-         deleteFunction< ParaboloidSDF< Dimensions, Real> >();
+      {
+         typedef ParaboloidSDF< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case sinBumpsSDF:
-         deleteFunction< SinBumpsSDF< Dimensions, Real> >();
+      {
+         typedef SinBumpsSDF< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
       case sinWaveSDF:
-         deleteFunction< SinWaveSDF< Dimensions, Real> >();
+      {
+         typedef SinWaveSDF< Dimensions, Real> FunctionType;
+         deleteFunction< FunctionType >();
+         deleteOperator< Identity< FunctionType> >();
          break;
+      }
    }
 }
 
diff --git a/src/TNL/Operators/Analytic/CMakeLists.txt b/src/TNL/Operators/Analytic/CMakeLists.txt
index 5f91292966..8cc44ea6f7 100755
--- a/src/TNL/Operators/Analytic/CMakeLists.txt
+++ b/src/TNL/Operators/Analytic/CMakeLists.txt
@@ -1,5 +1,6 @@
 SET( headers Sign.h
              Heaviside.h
+             Identity.h
              SmoothHeaviside.h
              Shift.h
              Rotation.h )
diff --git a/src/TNL/Operators/Analytic/Heaviside.h b/src/TNL/Operators/Analytic/Heaviside.h
index 75f96d78f4..aae05896b5 100644
--- a/src/TNL/Operators/Analytic/Heaviside.h
+++ b/src/TNL/Operators/Analytic/Heaviside.h
@@ -19,13 +19,13 @@ namespace Analytic {
    
    
 template< typename Function >
-class Heaviside : public Functions::Domain< Function::getDomainDimenions(), 
-                                            Function::getDomainTyep() >
+class Heaviside : public Functions::Domain< Function::getDomainDimensions(), 
+                                            Function::getDomainType() >
 {
    public:
       
       typedef typename Function::RealType RealType;
-      typedef Containers::StaticVector< Function::getDomainDimenions(), 
+      typedef Containers::StaticVector< Function::getDomainDimensions(), 
                                         RealType > VertexType;
       
       __cuda_callable__
@@ -33,9 +33,13 @@ class Heaviside : public Functions::Domain< Function::getDomainDimenions(),
                            const VertexType& vertex,
                            const RealType& time = 0 ) const
       {
-         const RealType aux = function( vertex );
+         const RealType aux = function( vertex, time );
          if( aux > 0.0 )
             return 1.0;
          return 0.0;
       }
 };
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
\ No newline at end of file
diff --git a/src/TNL/Operators/Analytic/Identity.h b/src/TNL/Operators/Analytic/Identity.h
new file mode 100644
index 0000000000..68a03c9076
--- /dev/null
+++ b/src/TNL/Operators/Analytic/Identity.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+                          Identity.h  -  description
+                             -------------------
+    begin                : Dec 5, 2013
+    copyright            : (C) 2013 by Tomas Oberhuber
+    email                : tomas.oberhuber@fjfi.cvut.cz
+ ***************************************************************************/
+
+/* See Copyright Notice in tnl/Copyright */
+
+#pragma once
+
+#include <TNL/Functions/Domain.h>
+#include <TNL/Devices/Cuda.h>
+
+namespace TNL {
+namespace Operators {
+namespace Analytic {   
+   
+   
+template< typename Function >
+class Identity : public Functions::Domain< Function::getDomainDimensions(), 
+                                           Function::getDomainType() >
+{
+   public:
+      
+      typedef typename Function::RealType RealType;
+      typedef Containers::StaticVector< Function::getDomainDimensions(), 
+                                        RealType > VertexType;
+      
+      __cuda_callable__
+      RealType operator()( const Function& function,
+                           const VertexType& vertex,
+                           const RealType& time = 0 ) const
+      {
+         return function( vertex, time );
+      }
+};
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
\ No newline at end of file
diff --git a/src/TNL/Operators/Analytic/Rotation.h b/src/TNL/Operators/Analytic/Rotation.h
index 1e4a04dd9b..fd51f6eb6b 100644
--- a/src/TNL/Operators/Analytic/Rotation.h
+++ b/src/TNL/Operators/Analytic/Rotation.h
@@ -63,6 +63,10 @@ class Rotation: public Functions::Domain< Function::getDomainDimenions(),
                            const VertexType& vertex,
                            const RealType& time = 0 ) const
       {
-         return function( vertex );
+         return function( vertex, time );
       }
 };
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
diff --git a/src/TNL/Operators/Analytic/Shift.h b/src/TNL/Operators/Analytic/Shift.h
index f23410632f..b7d761f686 100644
--- a/src/TNL/Operators/Analytic/Shift.h
+++ b/src/TNL/Operators/Analytic/Shift.h
@@ -47,10 +47,14 @@ class Shift : public Functions::Domain< Function::getDomainDimenions(),
                            const VertexType& vertex,
                            const RealType& time = 0 ) const
       {
-         return function( vertex + shift );
+         return function( vertex + shift, time );
       }
       
    protected:
       
       VerexType shift;
 };
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
diff --git a/src/TNL/Operators/Analytic/Sign.h b/src/TNL/Operators/Analytic/Sign.h
index 8ba59255b2..c5fcd612c6 100644
--- a/src/TNL/Operators/Analytic/Sign.h
+++ b/src/TNL/Operators/Analytic/Sign.h
@@ -1,8 +1,8 @@
 /***************************************************************************
-                          ExpBump.h  -  description
+                          Sign.h  -  description
                              -------------------
-    begin                : Dec 5, 2013
-    copyright            : (C) 2013 by Tomas Oberhuber
+    begin                : Feb 6, 2017
+    copyright            : (C) 2017 by Tomas Oberhuber
     email                : tomas.oberhuber@fjfi.cvut.cz
  ***************************************************************************/
 
@@ -33,12 +33,16 @@ class Sign : public Functions::Domain< Function::getDomainDimenions(),
                            const VertexType& vertex,
                            const RealType& time = 0 ) const
       {
-         const RealType aux = function( vertex );
+         const RealType aux = function( vertex, time );
          if( aux > 0.0 )
             return 1.0;
          else
             if( aux < 0.0 )
                return -1.0;
-         return 0.0;
+         return 0.0;         
       }
 };
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
diff --git a/src/TNL/Operators/Analytic/SmoothHeaviside.h b/src/TNL/Operators/Analytic/SmoothHeaviside.h
index 96d753270d..cbd72e531a 100644
--- a/src/TNL/Operators/Analytic/SmoothHeaviside.h
+++ b/src/TNL/Operators/Analytic/SmoothHeaviside.h
@@ -47,11 +47,15 @@ class SmoothHeaviside : public Functions::Domain< Function::getDomainDimenions()
                            const VertexType& vertex,
                            const RealType& time = 0 ) const
       {
-         const RealType aux = function( vertex );
-         return 1.0 / ( 1.0 + exp( -2.0 * sharpness * aux ) )
+         const RealType aux = function( vertex, time );
+         return 1.0 / ( 1.0 + exp( -2.0 * sharpness * aux ) );
       }
       
-      protected:
-         
-         RealType sharpness;
+   protected:
+
+      RealType sharpness;
 };
+
+} // namespace Analytic
+} // namespace Operators
+} // namespace TNL
-- 
GitLab