Commit 204f7f1d authored by Matouš Fencl's avatar Matouš Fencl Committed by Tomáš Oberhuber

2D and 3D solvers extended with MPI (3D has issue on biggest mesh)

parent df7abcac
#!/bin/bash
device="host"
dimensions="2D 3D"
#dimensions="3D"
#dimensions="2D 3D"
dimensions="2D"
sizes1D="16 32 64 128 256 512 1024 2048 4096"
#sizes1D="256"
sizes2D="16 32 64 128 256 512 1024"
#sizes2D="8"
sizes3D="16 32 64 128 256"
sizes2D="16 32 64 128 256 512 1024 2048 4096"
#sizes2D="16"
sizes3D="8 16 32 64 128 256"
#sizes3D="128 256"
testFunctions="paraboloid"
#testFunctions="sin-wave-sdf"
#testFunctions="sin-bumps-sdf"
snapshotPeriod=0.1
finalTime=1.5
solverName="tnl-direct-eikonal-solver"
#solverName="gdb --args tnl-direct-eikonal-solver-dbg --catch-exceptions no"
#
realType="double"
#mpiRun="mpirun -np 4 -oversubscribe "
mpiRun=""
## CAREFULL: If you set LocalCopy of MPI, you have to start with mpiRun even tnl-init
## This isnt problem with MpiIO.
## CAREFULL: For smoothly calculated error, you have to choose the right output function which
## is for both MpiIO, LocalCopy different.
solverName=${mpiRun}"tnl-direct-eikonal-solver"
#solverName="gdb --args "${mpiRun}"tnl-direct-eikonal-solver-dbg --catch-exceptions no --mpi-gdb-debug false"
#scale=2.0
#finalSdf="aux-0.tnl aux-1.tnl"
finalSdf="aux-final.tnl"
setupTestFunction()
{
......@@ -22,16 +36,17 @@ setupTestFunction()
# then
origin=-1.0
proportions=2.0
# origin=-1.0
# proportions=2.0
amplitude=1.0
waveLength=0.2
waveLengthX=0.2
waveLengthY=0.2
waveLengthZ=0.2
wavesNumber=3.0
wavesNumberX=0.5
wavesNumberY=2.0
waveLength=0.4
waveLengthX=0.5
waveLengthY=0.5
waveLengthZ=0.5
wavesNumber=1.25
wavesNumberX=0.5 wavesNumberY=2.0
wavesNumberZ=3.0
phase=0.1
phase=-1.5
phaseX=0.0
phaseY=0.0
phaseZ=0.0
......@@ -44,6 +59,7 @@ setupGrid()
{
dimensions=$1
gridSize=$2
#scale=$3
tnl-grid-setup --dimensions ${dimensions} \
--origin-x ${origin} \
--origin-y ${origin} \
......@@ -53,47 +69,51 @@ setupGrid()
--proportions-z ${proportions} \
--size-x ${gridSize} \
--size-y ${gridSize} \
--size-z ${gridSize}
--real-type ${realType} \
--size-z ${gridSize}
#$((2*${gridSize}))
}
setInitialCondition()
{
testFunction=$1
tnl-init --test-function ${testFunction} \
--output-file initial-u.tnl \
--amplitude ${amplitude} \
--wave-length ${waveLength} \
--wave-length-x ${waveLengthX} \
--wave-length-y ${waveLengthY} \
--wave-length-z ${waveLengthZ} \
--waves-number ${wavesNumber} \
--waves-number-x ${wavesNumberX} \
--waves-number-y ${wavesNumberY} \
--waves-number-z ${wavesNumberZ} \
--phase ${phase} \
--phase-x ${phaseX} \
--phase-y ${phaseY} \
--phase-z ${phaseZ} \
--sigma ${sigma} \
--radius ${radius}
--real-type ${realType} \
--output-file initial-u.tnl \
--amplitude ${amplitude} \
--wave-length ${waveLength} \
--wave-length-x ${waveLengthX} \
--wave-length-y ${waveLengthY} \
--wave-length-z ${waveLengthZ} \
--waves-number ${wavesNumber} \
--waves-number-x ${wavesNumberX} \
--waves-number-y ${wavesNumberY} \
--waves-number-z ${wavesNumberZ} \
--phase ${phase} \
--phase-x ${phaseX} \
--phase-y ${phaseY} \
--phase-z ${phaseZ} \
--sigma ${sigma} \
--radius ${radius}
tnl-init --test-function ${testFunction}-sdf \
--output-file exact-u.tnl \
--amplitude ${amplitude} \
--wave-length ${waveLength} \
--wave-length-x ${waveLengthX} \
--wave-length-y ${waveLengthY} \
--wave-length-z ${waveLengthZ} \
--waves-number ${wavesNumber} \
--waves-number-x ${wavesNumberX} \
--waves-number-y ${wavesNumberY} \
--waves-number-z ${wavesNumberZ} \
--phase ${phase} \
--phase-x ${phaseX} \
--phase-y ${phaseY} \
--phase-z ${phaseZ} \
--sigma ${sigma} \
--radius ${radius}
tnl-init --test-function ${testFunction}-sdf \
--real-type ${realType} \
--output-file exact-u.tnl \
--amplitude ${amplitude} \
--wave-length ${waveLength} \
--wave-length-x ${waveLengthX} \
--wave-length-y ${waveLengthY} \
--wave-length-z ${waveLengthZ} \
--waves-number ${wavesNumber} \
--waves-number-x ${wavesNumberX} \
--waves-number-y ${wavesNumberY} \
--waves-number-z ${wavesNumberZ} \
--phase ${phase} \
--phase-x ${phaseZ} \
--phase-y ${phaseZ} \
--phase-z ${phaseZ} \
--sigma ${sigma} \
--radius ${radius} \
}
......@@ -111,17 +131,22 @@ solve()
--min-iterations 20 \
--convergence-residue 1.0e-12 \
--snapshot-period ${snapshotPeriod} \
--real-type ${realType} \
--final-time ${finalTime}
}
computeError()
{
for sweep in ${finalSdf}
do
tnl-diff --mesh mesh.tnl \
--input-files aux-final.tnl exact-u.tnl \
--input-files exact-u.tnl u-00000.tnl \
--mode sequence \
--snapshot-period ${snapshotPeriod} \
--output-file errors.txt \
--write-difference yes
#aux-final.tnl \
done
}
runTest()
......
......@@ -62,12 +62,15 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 2, Real, Device, Index > >
typedef Functions::MeshFunction< MeshType > MeshFunctionType;
typedef Functions::MeshFunction< MeshType, 2, bool > InterfaceMapType;
typedef TNL::Containers::Array< int, Device, IndexType > ArrayContainer;
typedef Containers::StaticVector< 2, Index > StaticVector;
using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;
void initInterface( const MeshFunctionPointer& input,
MeshFunctionPointer& output,
InterfaceMapPointer& interfaceMap );
InterfaceMapPointer& interfaceMap,
StaticVector vLower, StaticVector vUpper );
template< typename MeshEntity >
__cuda_callable__ bool updateCell( MeshFunctionType& u,
......@@ -101,15 +104,17 @@ class tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > >
typedef Functions::MeshFunction< MeshType > MeshFunctionType;
typedef Functions::MeshFunction< MeshType, 3, bool > InterfaceMapType;
typedef TNL::Containers::Array< int, Device, IndexType > ArrayContainer;
typedef Containers::StaticVector< 3, Index > StaticVector;
using MeshFunctionPointer = Pointers::SharedPointer< MeshFunctionType >;
using InterfaceMapPointer = Pointers::SharedPointer< InterfaceMapType >;
void initInterface( const MeshFunctionPointer& input,
MeshFunctionPointer& output,
InterfaceMapPointer& interfaceMap );
InterfaceMapPointer& interfaceMap,
StaticVector vLower, StaticVector vUpper );
template< typename MeshEntity >
__cuda_callable__ void updateCell( MeshFunctionType& u,
__cuda_callable__ bool updateCell( MeshFunctionType& u,
const MeshEntity& cell,
const RealType velocity = 1.0);
......@@ -154,6 +159,10 @@ template< typename Real, typename Device, typename Index >
__global__ void DeepCopy( const Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& aux,
Functions::MeshFunction< Meshes::Grid< 2, Real, Device, Index > >& helpFunc, int copy, int k );
template< typename Real, typename Device, typename Index >
__global__ void DeepCopy( const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& aux,
Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& helpFunc, int copy, int k );
template < typename Index >
__global__ void CudaParallelReduc( TNL::Containers::ArrayView< int, Devices::Cuda, Index > BlockIterDevice,
TNL::Containers::ArrayView< int, Devices::Cuda, Index > dBlock, int nBlocks );
......@@ -171,7 +180,8 @@ __global__ void CudaInitCaller( const Functions::MeshFunction< Meshes::Grid< 2,
template < typename Real, typename Device, typename Index >
__global__ void CudaInitCaller3d( const Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& input,
Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index > >& output,
Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap );
Functions::MeshFunction< Meshes::Grid< 3, Real, Device, Index >, 3, bool >& interfaceMap,
Containers::StaticVector< 3, Index > vLower, Containers::StaticVector< 3, Index > vUpper );
template < int sizeSArray, typename Real, typename Device, typename Index >
__global__ void CudaUpdateCellCaller( tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > ptr,
......
......@@ -123,8 +123,7 @@ setInitialCondition( const Config::ParameterContainer& parameters,
{
this->bindDofs( dofs );
String inputFile = parameters.getParameter< String >( "input-file" );
this->initialData->setMesh( this->getMesh() );
std::cout<<"setInitialCondition" <<std::endl;
this->initialData->setMesh( this->getMesh() );
if( CommunicatorType::isDistributed() )
{
std::cout<<"Nodes Distribution: " << initialData->getMesh().getDistributedMesh()->printProcessDistr() << std::endl;
......@@ -191,20 +190,9 @@ bool
tnlDirectEikonalProblem< Mesh, Communicator, Anisotropy, Real, Index >::
solve( DofVectorPointer& dofs )
{
std::cout << "We are in solve()." << std::endl;
FastSweepingMethod< MeshType, Communicator,AnisotropyType > fsm;
fsm.solve( this->getMesh(), u, anisotropy, initialData );
/*int i = Communicators::MpiCommunicator::GetRank( Communicators::MpiCommunicator::AllGroup );
const MeshPointer msh = this->getMesh();
if( i == 0 && msh->getMeshDimension() == 2 )
{
for( int k = 0; k < 9; k++ ){
for( int l = 0; l < msh->getDimensions().x(); l++ )
printf("%.2f\t",(*initialData)[ k * msh->getDimensions().x() + l ] );
printf("\n");
}
}*/
makeSnapshot();
return true;
}
......@@ -14,6 +14,7 @@
#include <TNL/Functions/Analytic/Constant.h>
#include <TNL/Pointers/SharedPointer.h>
#include "tnlDirectEikonalMethodsBase.h"
#define ForDebug false // false <=> off
template< typename Mesh,
......@@ -132,8 +133,11 @@ class FastSweepingMethod< Meshes::Grid< 3, Real, Device, Index >, Communicator,
typedef Index IndexType;
typedef Anisotropy AnisotropyType;
typedef tnlDirectEikonalMethodsBase< Meshes::Grid< 3, Real, Device, Index > > BaseType;
typedef Communicator CommunicatorType;
using MeshPointer = Pointers::SharedPointer< MeshType >;
using AnisotropyPointer = Pointers::SharedPointer< AnisotropyType, DeviceType >;
using MPI = Communicators::MpiCommunicator;
using typename BaseType::InterfaceMapType;
using typename BaseType::MeshFunctionType;
......
......@@ -109,7 +109,7 @@ solve( const MeshPointer& mesh,
dim3 blockSize( cudaBlockSize );
dim3 gridSize( numBlocksX );
tnlDirectEikonalMethodsBase< Meshes::Grid< 1, Real, Device, Index > > ptr;
BaseType ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment