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

Merge branch 'hamilton-jacobi' into 'develop'

Hamilton jacobi

See merge request !12
parents a13675de e7217db4
No related branches found
No related tags found
1 merge request!12Hamilton jacobi
Showing
with 0 additions and 5897 deletions
set( tnl_narrow_band_SOURCES
# MainBuildConfig.h
# tnlNarrowBand2D_impl.h
# tnlNarrowBand.h
# narrowBandConfig.h
main.cpp)
IF( BUILD_CUDA )
CUDA_ADD_EXECUTABLE(narrow-band main.cu)
ELSE( BUILD_CUDA )
ADD_EXECUTABLE(narrow-band main.cpp)
ENDIF( BUILD_CUDA )
target_link_libraries (narrow-band tnl )
INSTALL( TARGETS narrow-band
RUNTIME DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
#INSTALL( FILES ${tnl_narrow_band_SOURCES}
# DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/narrow-band )
/***************************************************************************
MainBuildConfig.h - description
-------------------
begin : Jul 7, 2014
copyright : (C) 2014 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef MAINBUILDCONFIG_H_
#define MAINBUILDCONFIG_H_
#include <solvers/tnlBuildConfigTags.h>
class MainBuildConfig
{
public:
static void print() {std::cerr << "MainBuildConfig" <<std::endl; }
};
/****
* Turn off support for float and long double.
*/
template<> struct tnlConfigTagReal< MainBuildConfig, float > { enum { enabled = false }; };
template<> struct tnlConfigTagReal< MainBuildConfig, long double > { enum { enabled = false }; };
/****
* Turn off support for short int and long int indexing.
*/
template<> struct tnlConfigTagIndex< MainBuildConfig, short int >{ enum { enabled = false }; };
template<> struct tnlConfigTagIndex< MainBuildConfig, long int >{ enum { enabled = false }; };
/****
* Use of tnlGrid is enabled for allowed dimensions and Real, Device and Index types.
*/
template< int Dimensions, typename Real, typename Device, typename Index >
struct tnlConfigTagMesh< MainBuildConfig, tnlGrid< Dimensions, Real, Device, Index > >
{ enum { enabled = tnlConfigTagDimensions< MainBuildConfig, Dimensions >::enabled &&
tnlConfigTagReal< MainBuildConfig, Real >::enabled &&
tnlConfigTagDevice< MainBuildConfig, Device >::enabled &&
tnlConfigTagIndex< MainBuildConfig, Index >::enabled }; };
/****
* Please, chose your preferred time discretisation here.
*/
template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlExplicitTimeDiscretisationTag >{ enum { enabled = true }; };
template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlSemiImplicitTimeDiscretisationTag >{ enum { enabled = false}; };
template<> struct tnlConfigTagTimeDiscretisation< MainBuildConfig, tnlImplicitTimeDiscretisationTag >{ enum { enabled = false }; };
/****
* Only the Runge-Kutta-Merson solver is enabled by default.
*/
template<> struct tnlConfigTagExplicitSolver< MainBuildConfig, tnlExplicitEulerSolverTag >{ enum { enabled = false }; };
#endif /* MAINBUILDCONFIG_H_ */
/***************************************************************************
main.cpp - description
-------------------
begin : Oct 15 , 2015
copyright : (C) 2015 by Tomas Sobotik
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "main.h"
/***************************************************************************
main.cpp - description
-------------------
begin : Oct 15 , 2015
copyright : (C) 2015 by Tomas Sobotik
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "main.h"
/***************************************************************************
main.h - description
-------------------
begin : Oct 15 , 2015
copyright : (C) 2015 by Tomas Sobotik
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "MainBuildConfig.h"
//for HOST versions:
//#include "tnlNarrowBand.h"
//for DEVICE versions:
#include "tnlNarrowBand_CUDA.h"
#include "narrowBandConfig.h"
#include <solvers/tnlBuildConfigTags.h>
#include <mesh/tnlGrid.h>
#include <core/tnlDevice.h>
#include <time.h>
#include <ctime>
typedef MainBuildConfig BuildConfig;
int main( int argc, char* argv[] )
{
time_t start;
time_t stop;
time(&start);
std::clock_t start2= std::clock();
Config::ParameterContainer parameters;
tnlConfigDescription configDescription;
narrowBandConfig< BuildConfig >::configSetup( configDescription );
if( ! parseCommandLine( argc, argv, configDescription, parameters ) )
return false;
const int& dim = parameters.getParameter< int >( "dim" );
if(dim == 2)
{
tnlNarrowBand<tnlGrid<2,double,TNL::Devices::Host, int>, double, int> solver;
if(!solver.init(parameters))
{
cerr << "Solver failed to initialize." <<std::endl;
return EXIT_FAILURE;
}
TNL_CHECK_CUDA_DEVICE;
std::cout << "-------------------------------------------------------------" <<std::endl;
std::cout << "Starting solver..." <<std::endl;
solver.run();
}
// else if(dim == 3)
// {
// tnlNarrowBand<tnlGrid<3,double,TNL::Devices::Host, int>, double, int> solver;
// if(!solver.init(parameters))
// {
// cerr << "Solver failed to initialize." <<std::endl;
// return EXIT_FAILURE;
// }
// TNL_CHECK_CUDA_DEVICE;
// std::cout << "-------------------------------------------------------------" <<std::endl;
// std::cout << "Starting solver..." <<std::endl;
// solver.run();
// }
else
{
std::cerr << "Unsupported number of dimensions: " << dim << "!" <<std::endl;
return EXIT_FAILURE;
}
time(&stop);
std::cout << "Solver stopped..." <<std::endl;
std::cout <<std::endl;
std::cout << "Running time was: " << difftime(stop,start) << " .... " << (std::clock() - start2) / (double)(CLOCKS_PER_SEC) <<std::endl;
return EXIT_SUCCESS;
}
/***************************************************************************
narrowBandConfig.h - description
-------------------
begin : Oct 15, 2015
copyright : (C) 2015 by Tomas Sobotik
email :
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef NARROWBANDCONFIG_H_
#define NARROWBANDCONFIG_H_
#include <config/tnlConfigDescription.h>
template< typename ConfigTag >
class narrowBandConfig
{
public:
static void configSetup( tnlConfigDescription& config )
{
config.addDelimiter( "Narrow Band Solver solver settings:" );
config.addEntry < String > ( "problem-name", "This defines particular problem.", "fast-sweeping" );
config.addRequiredEntry < String > ( "initial-condition", "Initial condition for solver");
config.addRequiredEntry < int > ( "dim", "Dimension of problem.");
config.addRequiredEntry < double > ( "tau", "Time step.");
config.addRequiredEntry < double > ( "final-time", "Final time.");
config.addEntry < String > ( "mesh", "Name of mesh.", "mesh.tnl" );
config.addEntry < String > ( "exact-input", "Are the function values near the curve equal to the SDF? (yes/no)", "no" );
}
};
#endif /* NARROWBANDCONFIG_H_ */
/***************************************************************************
tnlNarrowBand.h - description
-------------------
begin : Oct 15 , 2015
copyright : (C) 2015 by Tomas Sobotik
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TNLNARROWBAND_H_
#define TNLNARROWBAND_H_
#include <TNL/Config/ParameterContainer.h>
#include <TNL/Containers/Vector.h>
#include <TNL/Containers/StaticVector.h>
#include <functions/tnlMeshFunction.h>
#include <TNL/Devices/Host.h>
#include <mesh/tnlGrid.h>
#include <mesh/grids/tnlGridEntity.h>
#include <limits.h>
#include <core/tnlDevice.h>
#include <ctime>
#ifdef HAVE_OPENMP
#include <omp.h>
#endif
template< typename Mesh,
typename Real,
typename Index >
class tnlNarrowBand
{};
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real,
typename Index >
class tnlNarrowBand< tnlGrid< 2,MeshReal, Device, MeshIndex >, Real, Index >
{
public:
typedef Real RealType;
typedef Device DeviceType;
typedef Index IndexType;
typedef tnlGrid< 2, Real, Device, Index > MeshType;
typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
typedef typename MeshType::CoordinatesType CoordinatesType;
tnlNarrowBand();
static String getType();
bool init( const Config::ParameterContainer& parameters );
bool initGrid();
bool run();
//for single core version use this implementation:
void updateValue(const Index i, const Index j);
//for parallel version use this one instead:
// void updateValue(const Index i, const Index j, DofVectorType* grid);
void setupSquare1000(Index i, Index j);
void setupSquare1100(Index i, Index j);
void setupSquare1010(Index i, Index j);
void setupSquare1001(Index i, Index j);
void setupSquare1110(Index i, Index j);
void setupSquare1101(Index i, Index j);
void setupSquare1011(Index i, Index j);
void setupSquare1111(Index i, Index j);
void setupSquare0000(Index i, Index j);
void setupSquare0100(Index i, Index j);
void setupSquare0010(Index i, Index j);
void setupSquare0001(Index i, Index j);
void setupSquare0110(Index i, Index j);
void setupSquare0101(Index i, Index j);
void setupSquare0011(Index i, Index j);
void setupSquare0111(Index i, Index j);
Real fabsMin(const Real x, const Real y);
protected:
MeshType Mesh;
bool exactInput;
tnlMeshFunction<MeshType> dofVector, dofVector2;
DofVectorType data;
RealType h;
tnlGridEntity< MeshType, 2, tnlGridEntityNoStencilStorage > Entity;
#ifdef HAVE_OPENMP
// omp_lock_t* gridLock;
#endif
};
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real,
typename Index >
class tnlNarrowBand< tnlGrid< 3,MeshReal, Device, MeshIndex >, Real, Index >
{
public:
typedef Real RealType;
typedef Device DeviceType;
typedef Index IndexType;
typedef tnlGrid< 3, Real, Device, Index > MeshType;
typedef TNL::Containers::Vector< RealType, DeviceType, IndexType> DofVectorType;
typedef typename MeshType::CoordinatesType CoordinatesType;
tnlNarrowBand();
static String getType();
bool init( const Config::ParameterContainer& parameters );
bool initGrid();
bool run();
//for single core version use this implementation:
void updateValue(const Index i, const Index j, const Index k);
//for parallel version use this one instead:
// void updateValue(const Index i, const Index j, DofVectorType* grid);
Real fabsMin(const Real x, const Real y);
protected:
MeshType Mesh;
bool exactInput;
tnlMeshFunction<MeshType> dofVector, dofVector2;
DofVectorType data;
RealType h;
tnlGridEntity< MeshType, 3, tnlGridEntityNoStencilStorage > Entity;
#ifdef HAVE_OPENMP
// omp_lock_t* gridLock;
#endif
};
//for single core version use this implementation:
#include "tnlNarrowBand2D_impl.h"
//for parallel version use this one instead:
// #include "tnlNarrowBand2D_openMP_impl.h"
#include "tnlNarrowBand3D_impl.h"
#endif /* TNLNARROWBAND_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
set( tnl_fast_sweeping_map_SOURCES
# MainBuildConfig.h
# tnlFastSweepingMap2D_impl.h
# tnlFastSweepingMap.h
# fastSweepingMapConfig.h
main.cpp)
IF( BUILD_CUDA )
CUDA_ADD_EXECUTABLE(fast-sweeping-map main.cu)
ELSE( BUILD_CUDA )
ADD_EXECUTABLE(fast-sweeping-map main.cpp)
ENDIF( BUILD_CUDA )
target_link_libraries (fast-sweeping-map tnl )
INSTALL( TARGETS fast-sweeping-map
RUNTIME DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
#INSTALL( FILES ${tnl_fast_sweeping_map_SOURCES}
# DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/fast-sweeping-map )
/***************************************************************************
main.cpp - description
-------------------
begin : Oct 15 , 2015
copyright : (C) 2015 by Tomas Sobotik
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "main.h"
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