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

Modifying TNL tools for LBM.

parent 7481e64f
No related branches found
No related tags found
No related merge requests found
......@@ -178,7 +178,7 @@ if( WITH_CUDA STREQUAL "yes" )
endif()
endif()
endif()
set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES )
set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; ${CUDA_ARCH} -D_FORCE_INLINES -lineinfo )
# TODO: this is necessary only due to a bug in cmake
set( CUDA_ADD_LIBRARY_OPTIONS -shared )
......
......@@ -27,15 +27,16 @@ void configSetup( Config::ConfigDescription& config )
config.addEntry < String >( "index-type", "Type for the indexing of the grid elements." ,"int" );
config.addEntryEnum < String >( "int" );
config.addEntryEnum < String >( "long-int" );
config.addEntry < double > ( "origin-x", "The x-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "origin-y", "The y-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "origin-z", "The z-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "proportions-x", "The proportions of the grid along the x axis.", 1.0 );
config.addEntry < double > ( "proportions-y", "The proportions of the grid along the y axis.", 1.0 );
config.addEntry < double > ( "proportions-z", "The proportions of the grid along the z axis.", 1.0 );
config.addEntry < int > ( "size-x", "Number of elements along the x axis." );
config.addEntry < int > ( "size-y", "Number of elements along the y axis." );
config.addEntry < int > ( "size-z", "Number of elements along the z axis." );
config.addEntry < double > ( "origin-x", "The x-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "origin-y", "The y-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "origin-z", "The z-coordinate of the origin.", 0.0 );
config.addEntry < double > ( "proportions-x", "The proportions of the grid along the x axis.", 1.0 );
config.addEntry < double > ( "proportions-y", "The proportions of the grid along the y axis.", 1.0 );
config.addEntry < double > ( "proportions-z", "The proportions of the grid along the z axis.", 1.0 );
config.addEntry < int > ( "size-x", "Number of elements along the x axis." );
config.addEntry < int > ( "size-y", "Number of elements along the y axis." );
config.addEntry < int > ( "size-z", "Number of elements along the z axis." );
config.addEntry < bool > ( "equal-space-steps", "All space steps will be equivalent.", false );
}
int main( int argc, char* argv[] )
......
......@@ -13,6 +13,7 @@
#include <TNL/Config/ParameterContainer.h>
#include <TNL/Meshes/Grid.h>
#include <TNL/terminal-colors.h>
using namespace TNL;
......@@ -27,8 +28,6 @@ bool setupGrid( const Config::ParameterContainer& parameters )
RealType originX = parameters. getParameter< double >( "origin-x" );
RealType proportionsX = parameters. getParameter< double >( "proportions-x" );
IndexType sizeX = parameters. getParameter< int >( "size-x" );
std::cout << "Setting dimensions to ... " << sizeX << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
typedef Meshes::Grid< 1, RealType, Devices::Host, IndexType > GridType;
typedef typename GridType::PointType PointType;
......@@ -36,6 +35,8 @@ bool setupGrid( const Config::ParameterContainer& parameters )
GridType grid;
grid.setDomain( PointType( originX ), PointType( proportionsX ) );
grid.setDimensions( CoordinatesType( sizeX ) );
std::cout << "Setting dimensions to ... " << sizeX << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
if( ! grid.save( outputFile ) )
{
std::cerr << "[ FAILED ] " << std::endl;
......@@ -44,21 +45,32 @@ bool setupGrid( const Config::ParameterContainer& parameters )
}
if( dimensions == 2 )
{
RealType originX = parameters. getParameter< double >( "origin-x" );
RealType originY = parameters. getParameter< double >( "origin-y" );
RealType proportionsX = parameters. getParameter< double >( "proportions-x" );
RealType proportionsY = parameters. getParameter< double >( "proportions-y" );
IndexType sizeX = parameters. getParameter< int >( "size-x" );
IndexType sizeY = parameters. getParameter< int >( "size-y" );
std::cout << "Setting dimensions to ... " << sizeX << "x" << sizeY << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
RealType originX = parameters.getParameter< double >( "origin-x" );
RealType originY = parameters.getParameter< double >( "origin-y" );
RealType proportionsX = parameters.getParameter< double >( "proportions-x" );
RealType proportionsY = parameters.getParameter< double >( "proportions-y" );
IndexType sizeX = parameters.getParameter< int >( "size-x" );
IndexType sizeY = parameters.getParameter< int >( "size-y" );
typedef Meshes::Grid< 2, RealType, Devices::Host, IndexType > GridType;
typedef typename GridType::PointType PointType;
typedef typename GridType::CoordinatesType CoordinatesType;
GridType grid;
grid.setDomain( PointType( originX, originY ), PointType( proportionsX, proportionsY ) );
grid.setDimensions( CoordinatesType( sizeX, sizeY ) );
if( parameters.getParameter< bool >( "equal-space-steps" ) )
{
if( grid.getSpaceSteps().x() != grid.getSpaceSteps().y() )
{
double h = min( grid.getSpaceSteps().x(), grid.getSpaceSteps().y() );
grid.setSpaceSteps( PointType( h, h ) );
std::cout << red << "Adjusting grid space steps to " << grid.getSpaceSteps()
<< " and grid proportions to " << grid.getProportions() << "." << reset << std::endl;
}
}
std::cout << "Setting dimensions to ... " << grid.getDimensions() << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
if( ! grid.save( outputFile ) )
{
std::cerr << "[ FAILED ] " << std::endl;
......@@ -76,8 +88,6 @@ bool setupGrid( const Config::ParameterContainer& parameters )
IndexType sizeX = parameters. getParameter< int >( "size-x" );
IndexType sizeY = parameters. getParameter< int >( "size-y" );
IndexType sizeZ = parameters. getParameter< int >( "size-z" );
std::cout << "Setting dimensions to ... " << sizeX << "x" << sizeY << "x" << sizeZ << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
typedef Meshes::Grid< 3, RealType, Devices::Host, IndexType > GridType;
typedef typename GridType::PointType PointType;
......@@ -85,6 +95,20 @@ bool setupGrid( const Config::ParameterContainer& parameters )
GridType grid;
grid.setDomain( PointType( originX, originY, originZ ), PointType( proportionsX, proportionsY, proportionsZ ) );
grid.setDimensions( CoordinatesType( sizeX, sizeY, sizeZ ) );
if( parameters.getParameter< bool >( "equal-space-steps" ) )
{
if( grid.getSpaceSteps().x() != grid.getSpaceSteps().y() ||
grid.getSpaceSteps().x() != grid.getSpaceSteps().z() )
{
double h = min( grid.getSpaceSteps().x(), min( grid.getSpaceSteps().y(), grid.getSpaceSteps().z() ) );
grid.setSpaceSteps( PointType( h, h, h ) );
std::cout << red << "Adjusting grid space steps to " << grid.getSpaceSteps()
<< " and grid proportions to " << grid.getProportions() << "." << reset << std::endl;
}
}
std::cout << "Setting dimensions to ... " << grid.getDimensions() << std::endl;
std::cout << "Writing the grid to the file " << outputFile << " .... ";
if( ! grid.save( outputFile ) )
{
std::cerr << "[ FAILED ] " << std::endl;
......
......@@ -28,6 +28,10 @@ void configSetup( Config::ConfigDescription& config )
config.addList < String >( "input-files", "Input .tnl files for conversion to images." );
config.addEntry < String >( "image-format", "Output images file format.", "pgm" );
config.addEntry < String >( "mesh-file", "Mesh file.", "mesh.tnl" );
config.addEntry < String >( "real-type", "Output mesh function real type.", "double" );
config.addEntryEnum < String >( "float" );
config.addEntryEnum < String >( "double" );
config.addEntryEnum < String >( "long-double" );
config.addEntry < bool > ( "one-mesh-file", "Generate only one mesh file. All the images dimensions must be the same.", true );
config.addEntry < int > ( "roi-top", "Top (smaller number) line of the region of interest.", -1 );
config.addEntry < int > ( "roi-bottom", "Bottom (larger number) line of the region of interest.", -1 );
......@@ -36,14 +40,14 @@ void configSetup( Config::ConfigDescription& config )
config.addEntry < bool > ( "verbose", "Set the verbosity of the program.", true );
}
template< typename Real >
bool processImages( const Config::ParameterContainer& parameters )
{
const Containers::List< String >& inputImages = parameters.getParameter< Containers::List< String > >( "input-images" );
String meshFile = parameters.getParameter< String >( "mesh-file" );
bool verbose = parameters.getParameter< bool >( "verbose" );
using GridType = Meshes::Grid< 2, double, Devices::Host, int >;
using GridType = Meshes::Grid< 2, Real, Devices::Host, int >;
using GridPointer = SharedPointer< GridType >;
using MeshFunctionType = Functions::MeshFunction< GridType >;
GridPointer grid;
......@@ -218,8 +222,16 @@ int main( int argc, char* argv[] )
configDescription.printUsage( argv[ 0 ] );
return EXIT_FAILURE;
}
if( parameters.checkParameter( "input-images" ) && ! processImages( parameters ) )
return EXIT_FAILURE;
if( parameters.checkParameter( "input-images" ) )
{
const String& realType = parameters.getParameter< String >( "real-type" );
if( realType == "float" && ! processImages< float >( parameters ) )
return EXIT_FAILURE;
if( realType == "double" && ! processImages< double >( parameters ) )
return EXIT_FAILURE;
if( realType == "long double" && ! processImages< long double >( parameters ) )
return EXIT_FAILURE;
}
if( parameters.checkParameter( "input-files" ) && ! processTNLFiles( parameters ) )
return EXIT_FAILURE;
......
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