Commit c152dc04 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Refactoring.

parent 11dfa47a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ class DistributedMesh<Grid< 1, RealType, Device, Index >>
           }  
       } 
       
       void SetupGrid( GridType& grid)
       void setupGrid( GridType& grid)
       {
           TNL_ASSERT_TRUE(isSet,"DistributedGrid is not set, but used by SetupGrid");
           grid.setOrigin(localorigin);
+1 −1
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ class DistributedMesh<Grid< 2, RealType, Device, Index >>
                      
       }
       
       void SetupGrid( GridType& grid)
       void setupGrid( GridType& grid)
       {
           TNL_ASSERT_TRUE(isSet,"DistributedGrid is not set, but used by SetupGrid");
           grid.setOrigin(localorigin);
+1 −1
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ class DistributedMesh<Grid< 3, RealType, Device, Index >>
           }                     
       }
       
       void SetupGrid( GridType& grid)
       void setupGrid( GridType& grid)
       {
           TNL_ASSERT_TRUE(isSet,"DistributedGrid is not set, but used by SetupGrid");
           grid.setOrigin(localorigin);
+32 −19
Original line number Diff line number Diff line
@@ -111,29 +111,33 @@ bool resolveMeshType( const String& fileName_,
}

// TODO: reorganize
template< typename CommunicatorType, typename MeshConfig, typename Device >
template< typename CommunicatorType,
          typename MeshConfig,
          typename Device >
bool
loadMesh( const String& fileName_, Mesh< MeshConfig, Device >& mesh, DistributedMeshes::DistributedMesh<Mesh< MeshConfig, Device >> &distributedMesh )
loadMesh( const String& fileName,
          Mesh< MeshConfig, Device >& mesh,
          DistributedMeshes::DistributedMesh< Mesh< MeshConfig, Device > > &distributedMesh )
{
   if(CommunicatorType::isDistributed())
   {
       std::cerr << "Distributed Mesh si not suported yet, only Distributed Grid is supported.";
       std::cerr << "Distributed Mesh is not supported yet, only Distributed Grid is supported.";
       return false;
   }

   std::cout << "Loading mesh from file " << fileName_ << " ..." << std::endl;
   std::string fileName( fileName_.getString() );
   std::cout << "Loading mesh from file " << fileName << " ..." << std::endl;
   std::string fileName_( fileName.getString() );
   bool status = true;

   if( ends_with( fileName, ".tnl" ) )
      status = mesh.load( fileName_ );
   else if( ends_with( fileName, ".ng" ) ) {
   if( ends_with( fileName_, ".tnl" ) )
      status = mesh.load( fileName );
   else if( ends_with( fileName_, ".ng" ) ) {
      Readers::NetgenReader reader;
      status = reader.readMesh( fileName_, mesh );
      status = reader.readMesh( fileName, mesh );
   }
   else if( ends_with( fileName, ".vtk" ) ) {
   else if( ends_with( fileName_, ".vtk" ) ) {
      Readers::VTKReader reader;
      status = reader.readMesh( fileName_, mesh );
      status = reader.readMesh( fileName, mesh );
   }
   else {
      std::cerr << "File '" << fileName << "' has unknown extension. Supported extensions are '.tnl', '.vtk' and '.ng'." << std::endl;
@@ -142,7 +146,7 @@ loadMesh( const String& fileName_, Mesh< MeshConfig, Device >& mesh, Distributed

   if( ! status )
   {
      std::cerr << "I am not able to load the mesh from the file " << fileName_ << ". "
      std::cerr << "I am not able to load the mesh from the file " << fileName << ". "
                   "Perhaps the mesh stored in the file is not supported by the mesh "
                   "passed to the loadMesh function? The mesh type is "
                << mesh.getType() << std::endl;
@@ -151,13 +155,16 @@ loadMesh( const String& fileName_, Mesh< MeshConfig, Device >& mesh, Distributed
   return true;
}

template<typename CommunicatorType, typename MeshConfig >
template< typename CommunicatorType,
          typename MeshConfig >
bool
loadMesh( const String& fileName, Mesh< MeshConfig, Devices::Cuda >& mesh, DistributedMeshes::DistributedMesh<Mesh< MeshConfig, Devices::Cuda >> &distributedMesh )
loadMesh( const String& fileName,
          Mesh< MeshConfig, Devices::Cuda >& mesh,
          DistributedMeshes::DistributedMesh< Mesh< MeshConfig, Devices::Cuda > >& distributedMesh )
{
   if(CommunicatorType::isDistributed())
   {
       std::cerr << "Distributed Mesh si not suported yet, only Distributed Grid is supported.";
       std::cerr << "Distributed Mesh is not supported yet, only Distributed Grid is supported.";
       return false;
   }

@@ -168,9 +175,15 @@ loadMesh( const String& fileName, Mesh< MeshConfig, Devices::Cuda >& mesh, Distr
   return true;
}

template<typename CommunicatorType, int Dimension, typename Real, typename Device, typename Index >
template< typename CommunicatorType,
          int Dimension,
          typename Real,
          typename Device,
          typename Index >
bool
loadMesh( const String& fileName, Grid< Dimension, Real, Device, Index >& mesh, DistributedMeshes::DistributedMesh<Grid< Dimension, Real, Device, Index >> &distributedMesh)
loadMesh( const String& fileName,
          Grid< Dimension, Real, Device, Index >& mesh,
          DistributedMeshes::DistributedMesh< Grid< Dimension, Real, Device, Index > > &distributedMesh )
{

   if( CommunicatorType::isDistributed() )
@@ -188,7 +201,7 @@ loadMesh( const String& fileName, Grid< Dimension, Real, Device, Index >& mesh,
       typename Meshes::DistributedMeshes::DistributedMesh<Grid< Dimension, Real, Device, Index >>::CoordinatesType overlap;
       overlap.setValue(1);
       distributedMesh.template setGlobalGrid<CommunicatorType>(globalGrid,overlap);
       distributedMesh.SetupGrid(mesh);
       distributedMesh.setupGrid(mesh);
       return true;
   }
   else
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ setup( const Config::ParameterContainer& parameters,
   const String& meshFile = parameters.getParameter< String >( "mesh" );
   if( ! Meshes::loadMesh<typename Problem::CommunicatorType>( meshFile, *meshPointer, distrMesh ) )
      return false;
   
   /****
    * Setup the problem
    */
Loading