Commit 3c0bb9eb authored by Vít Hanousek's avatar Vít Hanousek
Browse files

Merge branch 'mpi-explosive' of jlk.fjfi.cvut.cz:mmg/tnl-dev into mpi-explosive

parents ad9d82ef c0bcc471
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 )

+10 −9
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ void configSetup( Config::ConfigDescription& config )
   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[] )
+37 −13
Original line number Diff line number Diff line
@@ -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;
@@ -50,15 +51,26 @@ bool setupGrid( const Config::ParameterContainer& parameters )
      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 << " .... ";

      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;
+16 −4
Original line number Diff line number Diff line
@@ -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 ) )
   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;