Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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 )
/***************************************************************************
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;
}
};
/***************************************************************************
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 );
}
};
/***************************************************************************
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;
};
/***************************************************************************
ExpBump.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 Sign : 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;
else
if( aux < 0.0 )
return -1.0;
return 0.0;
}
};
/***************************************************************************
SmoothHeaviside.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 SmoothHeaviside : public Functions::Domain< Function::getDomainDimenions(),
Function::getDomainTyep() >
{
public:
typedef typename Function::RealType RealType;
typedef Containers::StaticVector< Function::getDomainDimenions(),
RealType > VertexType;
SmoothHeaviside()
: sharpness( 1.0 )
void setSharpness( const RealType& sharpness )
{
this->sharpness = sharpness;
}
__cuda_callable__
const RealType getShaprness() const
{
return this->sharpness;
}
__cuda_callable__
RealType operator()( const Function& function,
const VertexType& vertex,
const RealType& time = 0 ) const
{
const RealType aux = function( vertex );
return 1.0 / ( 1.0 + exp( -2.0 * sharpness * aux ) )
}
protected:
RealType sharpness;
};
ADD_SUBDIRECTORY( Analytic )
ADD_SUBDIRECTORY( diffusion )
ADD_SUBDIRECTORY( euler )
ADD_SUBDIRECTORY( interpolants )
......
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