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

Added CUDA switch.

parent 7d7e266e
No related branches found
No related tags found
1 merge request!1Hamilton jacobi
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <TNL/Meshes/Grid.h> #include <TNL/Meshes/Grid.h>
#include <TNL/Functions/MeshFunction.h> #include <TNL/Functions/MeshFunction.h>
#include <TNL/Devices/Cuda.h>
using namespace TNL; using namespace TNL;
...@@ -36,8 +37,8 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > ...@@ -36,8 +37,8 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > >
InterfaceMapType& interfaceMap ); InterfaceMapType& interfaceMap );
template< typename MeshEntity > template< typename MeshEntity >
void updateCell( MeshFunctionType& u, __cuda_callable__ void updateCell( MeshFunctionType& u,
const MeshEntity& cell ); const MeshEntity& cell );
}; };
...@@ -61,9 +62,9 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > > ...@@ -61,9 +62,9 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >
InterfaceMapType& interfaceMap ); InterfaceMapType& interfaceMap );
template< typename MeshEntity > template< typename MeshEntity >
void updateCell( MeshFunctionType& u, __cuda_callable__ void updateCell( MeshFunctionType& u,
const MeshEntity& cell, const MeshEntity& cell,
const RealType velocity = 1.0 ); const RealType velocity = 1.0 );
}; };
template< typename Real, template< typename Real,
...@@ -85,9 +86,9 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ...@@ -85,9 +86,9 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >
InterfaceMapType& interfaceMap ); InterfaceMapType& interfaceMap );
template< typename MeshEntity > template< typename MeshEntity >
void updateCell( MeshFunctionType& u, __cuda_callable__ void updateCell( MeshFunctionType& u,
const MeshEntity& cell, const MeshEntity& cell,
const RealType velocity = 1.0); const RealType velocity = 1.0);
/*Real sort( Real a, Real b, Real c, /*Real sort( Real a, Real b, Real c,
const RealType& ha, const RealType& ha,
......
...@@ -71,137 +71,143 @@ solve( const MeshPointer& mesh, ...@@ -71,137 +71,143 @@ solve( const MeshPointer& mesh,
IndexType iteration( 0 ); IndexType iteration( 0 );
while( iteration < this->maxIterations ) while( iteration < this->maxIterations )
{ {
if( std::is_same< DeviceType, Devices::Host >::value )
for( cell.getCoordinates().y() = 0;
cell.getCoordinates().y() < mesh->getDimensions().y();
cell.getCoordinates().y()++ )
{ {
for( cell.getCoordinates().x() = 0; for( cell.getCoordinates().y() = 0;
cell.getCoordinates().x() < mesh->getDimensions().x(); cell.getCoordinates().y() < mesh->getDimensions().y();
cell.getCoordinates().x()++ ) cell.getCoordinates().y()++ )
{
for( cell.getCoordinates().x() = 0;
cell.getCoordinates().x() < mesh->getDimensions().x();
cell.getCoordinates().x()++ )
{
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
//aux.save( "aux-1.tnl" );
for( cell.getCoordinates().y() = 0;
cell.getCoordinates().y() < mesh->getDimensions().y();
cell.getCoordinates().y()++ )
{
for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
cell.getCoordinates().x() >= 0 ;
cell.getCoordinates().x()-- )
{
//std::cerr << "2 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
//aux.save( "aux-2.tnl" );
for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
cell.getCoordinates().y() >= 0 ;
cell.getCoordinates().y()-- )
{ {
cell.refresh(); for( cell.getCoordinates().x() = 0;
if( ! interfaceMap( cell ) ) cell.getCoordinates().x() < mesh->getDimensions().x();
this->updateCell( aux, cell ); cell.getCoordinates().x()++ )
{
//std::cerr << "3 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
} }
}
//aux.save( "aux-1.tnl" );
for( cell.getCoordinates().y() = 0; //aux.save( "aux-3.tnl" );
cell.getCoordinates().y() < mesh->getDimensions().y();
cell.getCoordinates().y()++ ) for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
{ cell.getCoordinates().y() >= 0;
for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1; cell.getCoordinates().y()-- )
cell.getCoordinates().x() >= 0 ;
cell.getCoordinates().x()-- )
{ {
//std::cerr << "2 -> "; for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1;
cell.refresh(); cell.getCoordinates().x() >= 0 ;
if( ! interfaceMap( cell ) ) cell.getCoordinates().x()-- )
this->updateCell( aux, cell ); {
//std::cerr << "4 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
} }
}
//aux.save( "aux-2.tnl" );
for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1; //aux.save( "aux-4.tnl" );
cell.getCoordinates().y() >= 0 ;
cell.getCoordinates().y()-- ) /*for( cell.getCoordinates().x() = 0;
cell.getCoordinates().x() < mesh->getDimensions().y();
cell.getCoordinates().x()++ )
{ {
for( cell.getCoordinates().y() = 0;
cell.getCoordinates().y() < mesh->getDimensions().x();
cell.getCoordinates().y()++ )
{
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
aux.save( "aux-5.tnl" );
for( cell.getCoordinates().x() = 0; for( cell.getCoordinates().x() = 0;
cell.getCoordinates().x() < mesh->getDimensions().x(); cell.getCoordinates().x() < mesh->getDimensions().y();
cell.getCoordinates().x()++ ) cell.getCoordinates().x()++ )
{
//std::cerr << "3 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
//aux.save( "aux-3.tnl" );
for( cell.getCoordinates().y() = mesh->getDimensions().y() - 1;
cell.getCoordinates().y() >= 0;
cell.getCoordinates().y()-- )
{ {
for( cell.getCoordinates().x() = mesh->getDimensions().x() - 1; for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1;
cell.getCoordinates().y() >= 0 ;
cell.getCoordinates().y()-- )
{
//std::cerr << "2 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
aux.save( "aux-6.tnl" );
for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
cell.getCoordinates().x() >= 0 ; cell.getCoordinates().x() >= 0 ;
cell.getCoordinates().x()-- ) cell.getCoordinates().x()-- )
{ {
//std::cerr << "4 -> "; for( cell.getCoordinates().y() = 0;
cell.refresh(); cell.getCoordinates().y() < mesh->getDimensions().x();
if( ! interfaceMap( cell ) ) cell.getCoordinates().y()++ )
this->updateCell( aux, cell ); {
//std::cerr << "3 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
} }
} aux.save( "aux-7.tnl" );
//aux.save( "aux-4.tnl" ); for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
cell.getCoordinates().x() >= 0;
/*for( cell.getCoordinates().x() = 0; cell.getCoordinates().x()-- )
cell.getCoordinates().x() < mesh->getDimensions().y();
cell.getCoordinates().x()++ )
{
for( cell.getCoordinates().y() = 0;
cell.getCoordinates().y() < mesh->getDimensions().x();
cell.getCoordinates().y()++ )
{ {
cell.refresh(); for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1;
if( ! interfaceMap( cell ) ) cell.getCoordinates().y() >= 0 ;
this->updateCell( aux, cell ); cell.getCoordinates().y()-- )
} {
} //std::cerr << "4 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
aux.save( "aux-5.tnl" ); this->updateCell( aux, cell );
}
for( cell.getCoordinates().x() = 0; }*/
cell.getCoordinates().x() < mesh->getDimensions().y(); }
cell.getCoordinates().x()++ ) if( std::is_same< DeviceType, Devices::Cuda >::value )
{ {
for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1; // TODO: CUDA code
cell.getCoordinates().y() >= 0 ;
cell.getCoordinates().y()-- )
{
//std::cerr << "2 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
} }
aux.save( "aux-6.tnl" );
for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
cell.getCoordinates().x() >= 0 ;
cell.getCoordinates().x()-- )
{
for( cell.getCoordinates().y() = 0;
cell.getCoordinates().y() < mesh->getDimensions().x();
cell.getCoordinates().y()++ )
{
//std::cerr << "3 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}
aux.save( "aux-7.tnl" );
for( cell.getCoordinates().x() = mesh->getDimensions().y() - 1;
cell.getCoordinates().x() >= 0;
cell.getCoordinates().x()-- )
{
for( cell.getCoordinates().y() = mesh->getDimensions().x() - 1;
cell.getCoordinates().y() >= 0 ;
cell.getCoordinates().y()-- )
{
//std::cerr << "4 -> ";
cell.refresh();
if( ! interfaceMap( cell ) )
this->updateCell( aux, cell );
}
}*/
iteration++; iteration++;
} }
......
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