Loading src/TNL/Meshes/Readers/PVTIReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,12 @@ public: : XMLVTK( fileName ), communicator( std::move( communicator ) ) {} void setCommunicator( const MPI::Comm& communicator ) { this->communicator = communicator; } void detectMesh() override { Loading src/TNL/Meshes/Readers/PVTUReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,12 @@ public: : XMLVTK( fileName ), communicator( std::move( communicator ) ) {} void setCommunicator( const MPI::Comm& communicator ) { this->communicator = communicator; } void detectMesh() override { Loading src/TNL/Meshes/TypeResolver/resolveDistributedMeshType.h +6 −2 Original line number Diff line number Diff line Loading @@ -19,13 +19,17 @@ resolveDistributedMeshType( Functor&& functor, const std::string& fileName, cons template< typename ConfigTag, typename Device, typename Functor > bool resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat = "auto" ); resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat = "auto", const MPI::Comm& communicator = MPI_COMM_WORLD ); template< typename Mesh > bool loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh, const std::string& fileName, const std::string& fileFormat = "auto" ); const std::string& fileFormat = "auto", const MPI::Comm& communicator = MPI_COMM_WORLD ); } // namespace Meshes } // namespace TNL Loading src/TNL/Meshes/TypeResolver/resolveDistributedMeshType.hpp +18 −8 Original line number Diff line number Diff line Loading @@ -32,17 +32,26 @@ resolveDistributedMeshType( Functor&& functor, const std::string& fileName, cons template< typename ConfigTag, typename Device, typename Functor > bool resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat ) resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat, const MPI::Comm& communicator ) { auto wrapper = [ & ]( Readers::MeshReader& reader, auto&& mesh ) -> bool { using MeshType = std::decay_t< decltype( mesh ) >; std::cout << "Loading a mesh from the file " << fileName << " ..." << std::endl; try { if( reader.getMeshType() == "Meshes::DistributedMesh" ) dynamic_cast< Readers::PVTUReader& >( reader ).loadMesh( mesh ); else if( reader.getMeshType() == "Meshes::DistributedGrid" ) dynamic_cast< Readers::PVTIReader& >( reader ).loadMesh( mesh ); if( reader.getMeshType() == "Meshes::DistributedMesh" ) { auto& pvtu = dynamic_cast< Readers::PVTUReader& >( reader ); pvtu.setCommunicator( communicator ); pvtu.loadMesh( mesh ); } else if( reader.getMeshType() == "Meshes::DistributedGrid" ) { auto& pvti = dynamic_cast< Readers::PVTIReader& >( reader ); pvti.setCommunicator( communicator ); pvti.loadMesh( mesh ); } else throw std::runtime_error( "Unknown type of a distributed mesh: " + reader.getMeshType() ); } Loading @@ -59,7 +68,8 @@ template< typename Mesh > bool loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh, const std::string& fileName, const std::string& fileFormat ) const std::string& fileFormat, const MPI::Comm& communicator ) { namespace fs = std::experimental::filesystem; std::string format = fileFormat; Loading @@ -71,12 +81,12 @@ loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh } if( format == "pvtu" ) { Readers::PVTUReader reader( fileName ); Readers::PVTUReader reader( fileName, communicator ); reader.loadMesh( distributedMesh ); return true; } else if( format == "pvti" ) { Readers::PVTIReader reader( fileName ); Readers::PVTIReader reader( fileName, communicator ); reader.loadMesh( distributedMesh ); return true; } Loading Loading
src/TNL/Meshes/Readers/PVTIReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,12 @@ public: : XMLVTK( fileName ), communicator( std::move( communicator ) ) {} void setCommunicator( const MPI::Comm& communicator ) { this->communicator = communicator; } void detectMesh() override { Loading
src/TNL/Meshes/Readers/PVTUReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,12 @@ public: : XMLVTK( fileName ), communicator( std::move( communicator ) ) {} void setCommunicator( const MPI::Comm& communicator ) { this->communicator = communicator; } void detectMesh() override { Loading
src/TNL/Meshes/TypeResolver/resolveDistributedMeshType.h +6 −2 Original line number Diff line number Diff line Loading @@ -19,13 +19,17 @@ resolveDistributedMeshType( Functor&& functor, const std::string& fileName, cons template< typename ConfigTag, typename Device, typename Functor > bool resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat = "auto" ); resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat = "auto", const MPI::Comm& communicator = MPI_COMM_WORLD ); template< typename Mesh > bool loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh, const std::string& fileName, const std::string& fileFormat = "auto" ); const std::string& fileFormat = "auto", const MPI::Comm& communicator = MPI_COMM_WORLD ); } // namespace Meshes } // namespace TNL Loading
src/TNL/Meshes/TypeResolver/resolveDistributedMeshType.hpp +18 −8 Original line number Diff line number Diff line Loading @@ -32,17 +32,26 @@ resolveDistributedMeshType( Functor&& functor, const std::string& fileName, cons template< typename ConfigTag, typename Device, typename Functor > bool resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat ) resolveAndLoadDistributedMesh( Functor&& functor, const std::string& fileName, const std::string& fileFormat, const MPI::Comm& communicator ) { auto wrapper = [ & ]( Readers::MeshReader& reader, auto&& mesh ) -> bool { using MeshType = std::decay_t< decltype( mesh ) >; std::cout << "Loading a mesh from the file " << fileName << " ..." << std::endl; try { if( reader.getMeshType() == "Meshes::DistributedMesh" ) dynamic_cast< Readers::PVTUReader& >( reader ).loadMesh( mesh ); else if( reader.getMeshType() == "Meshes::DistributedGrid" ) dynamic_cast< Readers::PVTIReader& >( reader ).loadMesh( mesh ); if( reader.getMeshType() == "Meshes::DistributedMesh" ) { auto& pvtu = dynamic_cast< Readers::PVTUReader& >( reader ); pvtu.setCommunicator( communicator ); pvtu.loadMesh( mesh ); } else if( reader.getMeshType() == "Meshes::DistributedGrid" ) { auto& pvti = dynamic_cast< Readers::PVTIReader& >( reader ); pvti.setCommunicator( communicator ); pvti.loadMesh( mesh ); } else throw std::runtime_error( "Unknown type of a distributed mesh: " + reader.getMeshType() ); } Loading @@ -59,7 +68,8 @@ template< typename Mesh > bool loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh, const std::string& fileName, const std::string& fileFormat ) const std::string& fileFormat, const MPI::Comm& communicator ) { namespace fs = std::experimental::filesystem; std::string format = fileFormat; Loading @@ -71,12 +81,12 @@ loadDistributedMesh( DistributedMeshes::DistributedMesh< Mesh >& distributedMesh } if( format == "pvtu" ) { Readers::PVTUReader reader( fileName ); Readers::PVTUReader reader( fileName, communicator ); reader.loadMesh( distributedMesh ); return true; } else if( format == "pvti" ) { Readers::PVTIReader reader( fileName ); Readers::PVTIReader reader( fileName, communicator ); reader.loadMesh( distributedMesh ); return true; } Loading