Loading src/Tools/tnl-init.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ /* See Copyright Notice in tnl/Copyright */ #ifdef HAVE_MPI #define USE_MPI #endif #include "tnl-init.h" #include <TNL/File.h> Loading @@ -17,6 +21,8 @@ #include <TNL/Meshes/DummyMesh.h> #include <TNL/Meshes/Grid.h> #include <TNL/mpi-supp.h> using namespace TNL; void setupConfig( Config::ConfigDescription& config ) Loading Loading @@ -45,6 +51,10 @@ void setupConfig( Config::ConfigDescription& config ) int main( int argc, char* argv[] ) { #ifdef USE_MPI MPI::Init(argc,argv); #endif Config::ParameterContainer parameters; Config::ConfigDescription conf_desc; Loading @@ -69,5 +79,10 @@ int main( int argc, char* argv[] ) } if( ! resolveMeshType( parsedMeshType, parameters ) ) return EXIT_FAILURE; #ifdef USE_MPI MPI::Finalize(); #endif return EXIT_SUCCESS; } src/Tools/tnl-init.h +27 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include <TNL/FileName.h> #include <TNL/Functions/MeshFunction.h> #include <TNL/Meshes/DistributedGrid.h> #include <TNL/Meshes/DistributedGridIO.h> using namespace TNL; template< typename MeshType, Loading @@ -28,11 +31,28 @@ template< typename MeshType, int zDiff > bool renderFunction( const Config::ParameterContainer& parameters ) { #ifdef USE_MPI //suppose global mesh loaded from file - EXPLOSIVE CODE SharedPointer< MeshType > globalMeshPointer; String meshFile = parameters.getParameter< String >( "mesh" ); std::cout << "+ -> Loading mesh from " << meshFile << " ... " << std::endl; if( ! globalMeshPointer->load( meshFile ) ) return false; typename Meshes::DistributedGrid<MeshType>::CoordinatesType overlap; overlap.setValue(1); Meshes::DistributedGrid<MeshType> distrgrid(*globalMeshPointer,overlap); SharedPointer< MeshType > meshPointer; distrgrid.SetupGrid(*meshPointer); #else SharedPointer< MeshType > meshPointer; String meshFile = parameters.getParameter< String >( "mesh" ); std::cout << "+ -> Loading mesh from " << meshFile << " ... " << std::endl; if( ! meshPointer->load( meshFile ) ) return false; #endif typedef Functions::TestFunction< MeshType::getMeshDimension(), RealType > FunctionType; typedef SharedPointer< FunctionType, typename MeshType::DeviceType > FunctionPointer; Loading Loading @@ -87,8 +107,15 @@ bool renderFunction( const Config::ParameterContainer& parameters ) } else std::cout << "+ -> Writing the function to " << outputFile << " ... " << std::endl; #ifdef USE_MPI File file; file.open( outputFile+convertToString(MPI::COMM_WORLD.Get_rank()), IOMode::write ); Meshes::DistributedGridIO<MeshFunctionType> ::save(file, *meshFunction ); file.close(); #else if( ! meshFunction->save( outputFile) ) return false; #endif time += tau; step ++; } Loading Loading
src/Tools/tnl-init.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ /* See Copyright Notice in tnl/Copyright */ #ifdef HAVE_MPI #define USE_MPI #endif #include "tnl-init.h" #include <TNL/File.h> Loading @@ -17,6 +21,8 @@ #include <TNL/Meshes/DummyMesh.h> #include <TNL/Meshes/Grid.h> #include <TNL/mpi-supp.h> using namespace TNL; void setupConfig( Config::ConfigDescription& config ) Loading Loading @@ -45,6 +51,10 @@ void setupConfig( Config::ConfigDescription& config ) int main( int argc, char* argv[] ) { #ifdef USE_MPI MPI::Init(argc,argv); #endif Config::ParameterContainer parameters; Config::ConfigDescription conf_desc; Loading @@ -69,5 +79,10 @@ int main( int argc, char* argv[] ) } if( ! resolveMeshType( parsedMeshType, parameters ) ) return EXIT_FAILURE; #ifdef USE_MPI MPI::Finalize(); #endif return EXIT_SUCCESS; }
src/Tools/tnl-init.h +27 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,9 @@ #include <TNL/FileName.h> #include <TNL/Functions/MeshFunction.h> #include <TNL/Meshes/DistributedGrid.h> #include <TNL/Meshes/DistributedGridIO.h> using namespace TNL; template< typename MeshType, Loading @@ -28,11 +31,28 @@ template< typename MeshType, int zDiff > bool renderFunction( const Config::ParameterContainer& parameters ) { #ifdef USE_MPI //suppose global mesh loaded from file - EXPLOSIVE CODE SharedPointer< MeshType > globalMeshPointer; String meshFile = parameters.getParameter< String >( "mesh" ); std::cout << "+ -> Loading mesh from " << meshFile << " ... " << std::endl; if( ! globalMeshPointer->load( meshFile ) ) return false; typename Meshes::DistributedGrid<MeshType>::CoordinatesType overlap; overlap.setValue(1); Meshes::DistributedGrid<MeshType> distrgrid(*globalMeshPointer,overlap); SharedPointer< MeshType > meshPointer; distrgrid.SetupGrid(*meshPointer); #else SharedPointer< MeshType > meshPointer; String meshFile = parameters.getParameter< String >( "mesh" ); std::cout << "+ -> Loading mesh from " << meshFile << " ... " << std::endl; if( ! meshPointer->load( meshFile ) ) return false; #endif typedef Functions::TestFunction< MeshType::getMeshDimension(), RealType > FunctionType; typedef SharedPointer< FunctionType, typename MeshType::DeviceType > FunctionPointer; Loading Loading @@ -87,8 +107,15 @@ bool renderFunction( const Config::ParameterContainer& parameters ) } else std::cout << "+ -> Writing the function to " << outputFile << " ... " << std::endl; #ifdef USE_MPI File file; file.open( outputFile+convertToString(MPI::COMM_WORLD.Get_rank()), IOMode::write ); Meshes::DistributedGridIO<MeshFunctionType> ::save(file, *meshFunction ); file.close(); #else if( ! meshFunction->save( outputFile) ) return false; #endif time += tau; step ++; } Loading