Commit 352c9274 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Adding analytic operators for basic transformations:

 - sign
 - Heaviside
 - smooth Heaviside
 - shift
 - rotation
parent 73b8074f
Loading
Loading
Loading
Loading
+3 −22
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ setInitialCondition( const Config::ParameterContainer& parameters,
   const RealType& size = parameters.getParameter< double >( "realSize" ) / ::pow(count, 1.0/dimensions);
   const String& beginChoice = parameters.getParameter< String >( "begin" );
   std::cout << beginChoice << " " << dimensions << "   " << size << "   " << count << "   "<< 1/dimensions << std::endl;
   getchar();
   //getchar();
   if (beginChoice == "sin_square")
      {
	   double constantFunction;
@@ -166,8 +166,8 @@ setInitialCondition( const Config::ParameterContainer& parameters,
		};
     };
   //setting velocity field
   std::cout << *dofs << std::endl;
   getchar();
   //std::cout << *dofs << std::endl;
   //getchar();
   /*const String& initialConditionFile = parameters.getParameter< String >( "initial-condition" );
   if( ! dofs.load( initialConditionFile ) )
   {
@@ -316,25 +316,6 @@ assemblyLinearSystem( const RealType& time,
                      DofVectorPointer& b,
                      MeshDependentDataPointer& meshDependentData )
{
   /*LinearSystemAssembler< Mesh,
                             MeshFunctionType,
                             DifferentialOperator,
                             BoundaryCondition,
                             RightHandSide,
                             BackwardTimeDiscretisation,
                             Matrix,
                             DofVectorType > systemAssembler;

   MeshFunction< Mesh > u( mesh, _u );
   systemAssembler.template assembly< typename Mesh::Cell >( time,
                                                             tau,
                                                             mesh,
                                                             this->differentialOperator,
                                                             this->boundaryCondition,
                                                             this->rightHandSide,
                                                             u,
                                                             matrix,
                                                             b );*/
}

} // namespace TNL
+10 −0
Original line number Diff line number Diff line
SET( headers Sign.h
             Heaviside.h
             SmoothHeaviside.h
             Shift.h
             Rotation.h )

SET( CURRENT_DIR ${CMAKE_SOURCE_DIR}/src/TNL/Operators/Analytic )

   
INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/TNL/Operators/Analytic )
+41 −0
Original line number Diff line number Diff line
/***************************************************************************
                          Heaviside.h  -  description
                             -------------------
    begin                : Feb 6, 2017
    copyright            : (C) 2017 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 Heaviside : public Functions::Domain< Function::getDomainDimenions(), 
                                            Function::getDomainTyep() >
{
   public:
      
      typedef typename Function::RealType RealType;
      typedef Containers::StaticVector< Function::getDomainDimenions(), 
                                        RealType > VertexType;
      
      __cuda_callable__
      RealType operator()( const Function& function,
                           const VertexType& vertex,
                           const RealType& time = 0 ) const
      {
         const RealType aux = function( vertex );
         if( aux > 0.0 )
            return 1.0;
         return 0.0;
      }
};
+68 −0
Original line number Diff line number Diff line
/***************************************************************************
                          Rotation.h  -  description
                             -------------------
    begin                : Feb 6, 2017
    copyright            : (C) 2017 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 Real,
          int Dimensions >
class RotationBase
{
   public:
      typedef Real RealType;
      typedef Containers::StaticVector< Dimenions, RealType > VertexType;
      
      RotationBase() : center( 0.0 ) {};
      
      void setCenter( const VertexType& center )
      {
         this->center = center;
      }
      
      __cuda_callable__
      const VertexType& getCenter() const
      {
         return this->center;
      }
      
   protected:
      
      VertexType center;
};
   
template< typename Function,
          int Dimensions = Function::getDomainDimenions() >
class Rotation;

template< typename Function, 1 >
class Rotation: public Functions::Domain< Function::getDomainDimenions(), 
                                          Function::getDomainType() >
{
   public:
      
      typedef typename Function::RealType RealType;
      typedef Containers::StaticVector< Function::getDomainDimenions(), 
                                        RealType > VertexType;
      
      __cuda_callable__
      RealType operator()( const Function& function,
                           const VertexType& vertex,
                           const RealType& time = 0 ) const
      {
         return function( vertex );
      }
};
+56 −0
Original line number Diff line number Diff line
/***************************************************************************
                          Shift.h  -  description
                             -------------------
    begin                : Feb 6, 2017
    copyright            : (C) 2017 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 Shift : public Functions::Domain< Function::getDomainDimenions(), 
                                        Function::getDomainTyep() >
{
   public:
      
      typedef typename Function::RealType RealType;
      typedef Containers::StaticVector< Function::getDomainDimenions(), 
                                        RealType > VertexType;
      
      
      Shift() : shift( 0.0 ) {};
      
      void setShift( const VertexType& vertex )
      {
         this->shift = shift;
      }
      
      __cuda_callable__
      const VertexType& getShift() const
      {
         return this->shift;
      }
      
      __cuda_callable__
      RealType operator()( const Function& function,
                           const VertexType& vertex,
                           const RealType& time = 0 ) const
      {
         return function( vertex + shift );
      }
      
   protected:
      
      VerexType shift;
};
Loading