Skip to content
Snippets Groups Projects
Commit 74b2a34b authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Refactoring the eikonal solver.

parent 8e9cde1d
No related branches found
No related tags found
No related merge requests found
...@@ -44,48 +44,47 @@ template< typename MeshReal, ...@@ -44,48 +44,47 @@ template< typename MeshReal,
typename Index > typename Index >
class upwindEikonalScheme< tnlGrid< 1,MeshReal, Device, MeshIndex >, Real, Index > class upwindEikonalScheme< tnlGrid< 1,MeshReal, Device, MeshIndex >, Real, Index >
{ {
public:
public: typedef Real RealType;
typedef Real RealType; typedef Device DeviceType;
typedef Device DeviceType; typedef Index IndexType;
typedef Index IndexType; typedef tnlGrid< 1, Real, Device, Index > MeshType;
typedef tnlGrid< 1, Real, Device, Index > MeshType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType;
typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::CoordinatesType CoordinatesType;
typedef typename MeshType::CoordinatesType CoordinatesType;
static tnlString getType();
static tnlString getType();
template< typename PreimageFunction, typename MeshEntity >
template< typename PreimageFunction, typename MeshEntity > __cuda_callable__
__cuda_callable__ Real operator()( const PreimageFunction& u,
Real operator()( const PreimageFunction& u, const MeshEntity& entity,
const MeshEntity& entity, const RealType& signU ) const
const RealType& signU ) const
{
const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1 >();
const typename MeshEntity::template NeighbourEntities< 1 >& neighbourEntities = entity.getNeighbourEntities();
const RealType& u_c = u[ entity.getIndex() ];
const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1 >() ];
const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1 >() ];
if( signU > 0.0 )
{
const RealType& xf = negativePart( ( u_e - u_c ) * hx_inv );
const RealType& xb = positivePart( ( u_c - u_w ) * hx_inv );
return sqrt( xf * xf + xb * xb );
}
else if( signU < 0.0 )
{
const RealType& xf = negativePart( ( u_c - u_w ) * hx_inv );
const RealType& xb = positivePart( ( u_e - u_c ) * hx_inv );
return sqrt( xf * xf + xb * xb );
}
else
{ {
return 0.0; const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1 >();
} const typename MeshEntity::template NeighbourEntities< 1 >& neighbourEntities = entity.getNeighbourEntities();
};
const RealType& u_c = u[ entity.getIndex() ];
const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1 >() ];
const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1 >() ];
if( signU > 0.0 )
{
const RealType& xf = negativePart( ( u_e - u_c ) * hx_inv );
const RealType& xb = positivePart( ( u_c - u_w ) * hx_inv );
return sqrt( xf * xf + xb * xb );
}
else if( signU < 0.0 )
{
const RealType& xf = negativePart( ( u_c - u_w ) * hx_inv );
const RealType& xb = positivePart( ( u_e - u_c ) * hx_inv );
return sqrt( xf * xf + xb * xb );
}
else
{
return 0.0;
}
};
}; };
/**** /****
...@@ -98,51 +97,50 @@ template< typename MeshReal, ...@@ -98,51 +97,50 @@ template< typename MeshReal,
typename Index > typename Index >
class upwindEikonalScheme< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index > class upwindEikonalScheme< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
{ {
public:
public: typedef Real RealType;
typedef Real RealType; typedef Device DeviceType;
typedef Device DeviceType; typedef Index IndexType;
typedef Index IndexType; typedef tnlGrid< 2, Real, Device, Index > MeshType;
typedef tnlGrid< 2, Real, Device, Index > MeshType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType;
typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef typename MeshType::CoordinatesType CoordinatesType;
typedef typename MeshType::CoordinatesType CoordinatesType;
static tnlString getType();
static tnlString getType();
template< typename PreimageFunction, typename MeshEntity >
template< typename PreimageFunction, typename MeshEntity > __cuda_callable__
__cuda_callable__ Real operator()( const PreimageFunction& u,
Real operator()( const PreimageFunction& u, const MeshEntity& entity,
const MeshEntity& entity, const RealType& signU ) const
const RealType& signU ) const {
{ const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1, 0 >();
const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hy_inv = entity.getMesh().template getSpaceStepsProducts< 0, -1 >();
const RealType& hy_inv = entity.getMesh().template getSpaceStepsProducts< 0, -1 >();
const typename MeshEntity::template NeighbourEntities< 2 >& neighbourEntities = entity.getNeighbourEntities();
const typename MeshEntity::template NeighbourEntities< 2 >& neighbourEntities = entity.getNeighbourEntities(); const RealType& u_c = u[ entity.getIndex() ];
const RealType& u_c = u[ entity.getIndex() ]; const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1, 0 >() ];
const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1, 0 >() ]; const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1, 0 >() ];
const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1, 0 >() ]; const RealType& u_n = u[ neighbourEntities.template getEntityIndex< 0, 1 >() ];
const RealType& u_n = u[ neighbourEntities.template getEntityIndex< 0, 1 >() ]; const RealType& u_s = u[ neighbourEntities.template getEntityIndex< 0, -1 >() ];
const RealType& u_s = u[ neighbourEntities.template getEntityIndex< 0, -1 >() ]; if( signU > 0.0 )
if( signU > 0.0 ) {
{ const RealType xf = negativePart( ( u_e - u_c ) * hx_inv );
const RealType xf = negativePart( ( u_e - u_c ) * hx_inv ); const RealType xb = positivePart( ( u_c - u_w ) * hx_inv );
const RealType xb = positivePart( ( u_c - u_w ) * hx_inv ); const RealType yf = negativePart( ( u_n - u_c ) * hy_inv );
const RealType yf = negativePart( ( u_n - u_c ) * hy_inv ); const RealType yb = positivePart( ( u_c - u_s ) * hy_inv );
const RealType yb = positivePart( ( u_c - u_s ) * hy_inv ); return sqrt( xf * xf + xb * xb + yf * yf + yb * yb );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb ); }
else if( signU < 0.0 )
{
const RealType xf = positivePart( ( u_e - u_c ) * hx_inv );
const RealType xb = negativePart( ( u_c - u_w ) * hx_inv );
const RealType yf = positivePart( ( u_n - u_c ) * hy_inv );
const RealType yb = negativePart( ( u_c - u_s ) * hy_inv );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb );
}
else
return 0.0;
} }
else if( signU < 0.0 )
{
const RealType xf = positivePart( ( u_e - u_c ) * hx_inv );
const RealType xb = negativePart( ( u_c - u_w ) * hx_inv );
const RealType yf = positivePart( ( u_n - u_c ) * hy_inv );
const RealType yb = negativePart( ( u_c - u_s ) * hy_inv );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb );
}
else
return 0.0;
}
}; };
/**** /****
...@@ -156,59 +154,59 @@ template< typename MeshReal, ...@@ -156,59 +154,59 @@ template< typename MeshReal,
class upwindEikonalScheme< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index > class upwindEikonalScheme< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
{ {
public: public:
typedef Real RealType; typedef Real RealType;
typedef Device DeviceType; typedef Device DeviceType;
typedef Index IndexType; typedef Index IndexType;
typedef tnlGrid< 3, Real, Device, Index > MeshType; typedef tnlGrid< 3, Real, Device, Index > MeshType;
typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType; typedef tnlVector< RealType, DeviceType, IndexType> DofVectorType;
typedef typename MeshType::CoordinatesType CoordinatesType; typedef typename MeshType::CoordinatesType CoordinatesType;
static tnlString getType(); static tnlString getType();
template< typename PreimageFunction, typename MeshEntity > template< typename PreimageFunction, typename MeshEntity >
__cuda_callable__ __cuda_callable__
Real operator()( const PreimageFunction& u, Real operator()( const PreimageFunction& u,
const MeshEntity& entity, const MeshEntity& entity,
const RealType& signU ) const const RealType& signU ) const
{
const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >();
const RealType& hy_inv = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >();
const RealType& hz_inv = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >();
const typename MeshEntity::template NeighbourEntities< 3 >& neighbourEntities = entity.getNeighbourEntities();
const RealType& u_c = u[ entity.getIndex() ];
const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1, 0, 0 >() ];
const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1, 0, 0 >() ];
const RealType& u_n = u[ neighbourEntities.template getEntityIndex< 0, 1, 0 >() ];
const RealType& u_s = u[ neighbourEntities.template getEntityIndex< 0, -1, 0 >() ];
const RealType& u_t = u[ neighbourEntities.template getEntityIndex< 0, 0, 1 >() ];
const RealType& u_b = u[ neighbourEntities.template getEntityIndex< 0, 0, -1 >() ];
if( signU > 0.0 )
{
const RealType xf = negativePart( ( u_e - u_c ) * hx_inv );
const RealType xb = positivePart( ( u_c - u_w ) * hx_inv );
const RealType yf = negativePart( ( u_n - u_c ) * hy_inv );
const RealType yb = positivePart( ( u_c - u_s ) * hy_inv );
const RealType zf = negativePart( ( u_t - u_c ) * hz_inv );
const RealType zb = positivePart( ( u_c - u_b ) * hz_inv );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb + zf * zf + zb * zb );
}
else if( signU < 0.0 )
{ {
const RealType xf = positivePart( ( u_e - u_c ) * hx_inv ); const RealType& hx_inv = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >();
const RealType xb = negativePart( ( u_c - u_w ) * hx_inv ); const RealType& hy_inv = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >();
const RealType yf = positivePart( ( u_n - u_c ) * hy_inv ); const RealType& hz_inv = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >();
const RealType yb = negativePart( ( u_c - u_s ) * hy_inv );
const RealType zf = positivePart( ( u_t - u_c ) * hz_inv ); const typename MeshEntity::template NeighbourEntities< 3 >& neighbourEntities = entity.getNeighbourEntities();
const RealType zb = negativePart( ( u_c - u_b ) * hz_inv ); const RealType& u_c = u[ entity.getIndex() ];
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb + zf * zf + zb * zb ); const RealType& u_e = u[ neighbourEntities.template getEntityIndex< 1, 0, 0 >() ];
} const RealType& u_w = u[ neighbourEntities.template getEntityIndex< -1, 0, 0 >() ];
else const RealType& u_n = u[ neighbourEntities.template getEntityIndex< 0, 1, 0 >() ];
return 0.0; const RealType& u_s = u[ neighbourEntities.template getEntityIndex< 0, -1, 0 >() ];
}; const RealType& u_t = u[ neighbourEntities.template getEntityIndex< 0, 0, 1 >() ];
const RealType& u_b = u[ neighbourEntities.template getEntityIndex< 0, 0, -1 >() ];
if( signU > 0.0 )
{
const RealType xf = negativePart( ( u_e - u_c ) * hx_inv );
const RealType xb = positivePart( ( u_c - u_w ) * hx_inv );
const RealType yf = negativePart( ( u_n - u_c ) * hy_inv );
const RealType yb = positivePart( ( u_c - u_s ) * hy_inv );
const RealType zf = negativePart( ( u_t - u_c ) * hz_inv );
const RealType zb = positivePart( ( u_c - u_b ) * hz_inv );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb + zf * zf + zb * zb );
}
else if( signU < 0.0 )
{
const RealType xf = positivePart( ( u_e - u_c ) * hx_inv );
const RealType xb = negativePart( ( u_c - u_w ) * hx_inv );
const RealType yf = positivePart( ( u_n - u_c ) * hy_inv );
const RealType yb = negativePart( ( u_c - u_s ) * hy_inv );
const RealType zf = positivePart( ( u_t - u_c ) * hz_inv );
const RealType zb = negativePart( ( u_c - u_b ) * hz_inv );
return sqrt( xf * xf + xb * xb + yf * yf + yb * yb + zf * zf + zb * zb );
}
else
return 0.0;
};
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment