Loading examples/heat-equation/tnl-heat-equation-eoc.h +3 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,9 @@ /* See Copyright Notice in tnl/Copyright */ #ifndef TNL_HEAT_EQUATION_EOC_H_ #define TNL_HEAT_EQUATION_EOC_H_ #pragma once #define MPIIO #include <TNL/Solvers/Solver.h> #include <TNL/Solvers/FastBuildConfigTag.h> Loading Loading @@ -78,5 +79,3 @@ int main( int argc, char* argv[] ) return EXIT_FAILURE; return EXIT_SUCCESS; } #endif /* TNL_HEAT_EQUATION_EOC_H_ */ src/TNL/Communicators/MpiCommunicator.h +44 −20 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include <mpi.h> #include <TNL/String.h> #include <TNL/Logger.h> #include <TNL/Config/ConfigDescription.h> namespace TNL { Loading @@ -39,25 +40,41 @@ class MpiCommunicator inline static MPI_Datatype MPIDataType( const double* ) { return MPI_DOUBLE; }; inline static MPI_Datatype MPIDataType( const long double* ) { return MPI_LONG_DOUBLE; }; typedef MPI::Request Request; static MPI::Request NullRequest; static std::streambuf *psbuf; static std::streambuf *backup; static std::ofstream filestr; public: using Request = MPI::Request; static bool isDistributed() { return GetSize()>1; }; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) { #ifdef HAVE_MPI config.addEntry< bool >( "redirect-mpi-output", "Only process with rank 0 prints to console. Other processes are redirected to files.", true ); #endif } static void Init(int argc, char **argv,bool redirect=false) static bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) { #ifdef HAVE_MPI redirect = parameters.getParameter< bool >( "redirect-mpi-output" ); setupRedirection(); #endif return true; } static void Init(int argc, char **argv ) { #ifdef HAVE_MPI MPI::Init( argc, argv ); NullRequest=MPI::REQUEST_NULL; redirect = true; #endif } static void setupRedirection() { if(isDistributed() && redirect ) { //redirect all stdout to files, only 0 take to go to console Loading @@ -67,9 +84,9 @@ class MpiCommunicator if(MPI::COMM_WORLD.Get_rank()!=0) { std::cout<< GetRank() <<": Redirecting std::out to file" <<std::endl; String stdoutfile; stdoutfile=String( "./stdout-")+convertToString(MPI::COMM_WORLD.Get_rank())+String(".txt"); filestr.open (stdoutfile.getString()); String stdoutFile; stdoutFile=String( "./stdout-")+convertToString(MPI::COMM_WORLD.Get_rank())+String(".txt"); filestr.open (stdoutFile.getString()); psbuf = filestr.rdbuf(); std::cout.rdbuf(psbuf); } Loading Loading @@ -182,12 +199,19 @@ class MpiCommunicator } } static MPI::Request NullRequest; static std::streambuf *psbuf; static std::streambuf *backup; static std::ofstream filestr; static bool redirect; }; MPI::Request MpiCommunicator::NullRequest; std::streambuf *MpiCommunicator::psbuf; std::streambuf *MpiCommunicator::backup; std::ofstream MpiCommunicator::filestr; bool MpiCommunicator::redirect; }//namespace Communicators } // namespace TNL Loading src/TNL/Communicators/NoDistrCommunicator.h +8 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,14 @@ class NoDistrCommunicator typedef int Request; static Request NullRequest; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; static bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) { return true; } static void Init(int argc, char **argv, bool redirect=false) { NullRequest=-1; Loading src/TNL/Problems/HeatEquationProblem_impl.h +14 −12 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ makeSnapshot( const RealType& time, if(CommunicatorType::isDistributed()) { Meshes::DistributedMeshes::DistributedGridIO<MeshFunctionType,Meshes::DistributedMeshes::LocalCopy> ::save(fileName.getFileName(), *uPointer ); Meshes::DistributedMeshes::DistributedGridIO<MeshFunctionType,Meshes::DistributedMeshes::MpiIO> ::save(fileName.getFileName(), *uPointer ); } else { Loading Loading @@ -249,10 +249,12 @@ getExplicitUpdate( const RealType& time, this->bindDofs( meshPointer, uDofs ); MeshFunctionPointer fuPointer( meshPointer, fuDofs ); this->explicitUpdater.setDifferentialOperator( this->differentialOperatorPointer ), this->explicitUpdater.setBoundaryConditions( this->boundaryConditionPointer ), this->explicitUpdater.setRightHandSide( this->rightHandSidePointer ), this->explicitUpdater.setDifferentialOperator( this->differentialOperatorPointer ); this->explicitUpdater.setBoundaryConditions( this->boundaryConditionPointer ); this->explicitUpdater.setRightHandSide( this->rightHandSidePointer ); std::cerr << "Starting updater ... " << std::endl; this->explicitUpdater.template update< typename Mesh::Cell, CommType >( time, tau, meshPointer, this->uPointer, fuPointer ); std::cerr << "Updater done ... " << std::endl; } Loading src/TNL/Solvers/PDE/ExplicitUpdater.h +2 −0 Original line number Diff line number Diff line Loading @@ -149,8 +149,10 @@ class ExplicitUpdater ( meshPointer, userDataPointer ); std::cerr << __FILE__ << ":" << __LINE__ << "Starting synchronization..." << std::endl; if(CommunicatorType::isDistributed()) fuPointer->template synchronize<CommunicatorType>(); std::cerr << __FILE__ << ":" << __LINE__ << "Synchronization done..." << std::endl; } Loading Loading
examples/heat-equation/tnl-heat-equation-eoc.h +3 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,9 @@ /* See Copyright Notice in tnl/Copyright */ #ifndef TNL_HEAT_EQUATION_EOC_H_ #define TNL_HEAT_EQUATION_EOC_H_ #pragma once #define MPIIO #include <TNL/Solvers/Solver.h> #include <TNL/Solvers/FastBuildConfigTag.h> Loading Loading @@ -78,5 +79,3 @@ int main( int argc, char* argv[] ) return EXIT_FAILURE; return EXIT_SUCCESS; } #endif /* TNL_HEAT_EQUATION_EOC_H_ */
src/TNL/Communicators/MpiCommunicator.h +44 −20 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include <mpi.h> #include <TNL/String.h> #include <TNL/Logger.h> #include <TNL/Config/ConfigDescription.h> namespace TNL { Loading @@ -39,25 +40,41 @@ class MpiCommunicator inline static MPI_Datatype MPIDataType( const double* ) { return MPI_DOUBLE; }; inline static MPI_Datatype MPIDataType( const long double* ) { return MPI_LONG_DOUBLE; }; typedef MPI::Request Request; static MPI::Request NullRequest; static std::streambuf *psbuf; static std::streambuf *backup; static std::ofstream filestr; public: using Request = MPI::Request; static bool isDistributed() { return GetSize()>1; }; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) { #ifdef HAVE_MPI config.addEntry< bool >( "redirect-mpi-output", "Only process with rank 0 prints to console. Other processes are redirected to files.", true ); #endif } static void Init(int argc, char **argv,bool redirect=false) static bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) { #ifdef HAVE_MPI redirect = parameters.getParameter< bool >( "redirect-mpi-output" ); setupRedirection(); #endif return true; } static void Init(int argc, char **argv ) { #ifdef HAVE_MPI MPI::Init( argc, argv ); NullRequest=MPI::REQUEST_NULL; redirect = true; #endif } static void setupRedirection() { if(isDistributed() && redirect ) { //redirect all stdout to files, only 0 take to go to console Loading @@ -67,9 +84,9 @@ class MpiCommunicator if(MPI::COMM_WORLD.Get_rank()!=0) { std::cout<< GetRank() <<": Redirecting std::out to file" <<std::endl; String stdoutfile; stdoutfile=String( "./stdout-")+convertToString(MPI::COMM_WORLD.Get_rank())+String(".txt"); filestr.open (stdoutfile.getString()); String stdoutFile; stdoutFile=String( "./stdout-")+convertToString(MPI::COMM_WORLD.Get_rank())+String(".txt"); filestr.open (stdoutFile.getString()); psbuf = filestr.rdbuf(); std::cout.rdbuf(psbuf); } Loading Loading @@ -182,12 +199,19 @@ class MpiCommunicator } } static MPI::Request NullRequest; static std::streambuf *psbuf; static std::streambuf *backup; static std::ofstream filestr; static bool redirect; }; MPI::Request MpiCommunicator::NullRequest; std::streambuf *MpiCommunicator::psbuf; std::streambuf *MpiCommunicator::backup; std::ofstream MpiCommunicator::filestr; bool MpiCommunicator::redirect; }//namespace Communicators } // namespace TNL Loading
src/TNL/Communicators/NoDistrCommunicator.h +8 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,14 @@ class NoDistrCommunicator typedef int Request; static Request NullRequest; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ){}; static bool setup( const Config::ParameterContainer& parameters, const String& prefix = "" ) { return true; } static void Init(int argc, char **argv, bool redirect=false) { NullRequest=-1; Loading
src/TNL/Problems/HeatEquationProblem_impl.h +14 −12 Original line number Diff line number Diff line Loading @@ -214,7 +214,7 @@ makeSnapshot( const RealType& time, if(CommunicatorType::isDistributed()) { Meshes::DistributedMeshes::DistributedGridIO<MeshFunctionType,Meshes::DistributedMeshes::LocalCopy> ::save(fileName.getFileName(), *uPointer ); Meshes::DistributedMeshes::DistributedGridIO<MeshFunctionType,Meshes::DistributedMeshes::MpiIO> ::save(fileName.getFileName(), *uPointer ); } else { Loading Loading @@ -249,10 +249,12 @@ getExplicitUpdate( const RealType& time, this->bindDofs( meshPointer, uDofs ); MeshFunctionPointer fuPointer( meshPointer, fuDofs ); this->explicitUpdater.setDifferentialOperator( this->differentialOperatorPointer ), this->explicitUpdater.setBoundaryConditions( this->boundaryConditionPointer ), this->explicitUpdater.setRightHandSide( this->rightHandSidePointer ), this->explicitUpdater.setDifferentialOperator( this->differentialOperatorPointer ); this->explicitUpdater.setBoundaryConditions( this->boundaryConditionPointer ); this->explicitUpdater.setRightHandSide( this->rightHandSidePointer ); std::cerr << "Starting updater ... " << std::endl; this->explicitUpdater.template update< typename Mesh::Cell, CommType >( time, tau, meshPointer, this->uPointer, fuPointer ); std::cerr << "Updater done ... " << std::endl; } Loading
src/TNL/Solvers/PDE/ExplicitUpdater.h +2 −0 Original line number Diff line number Diff line Loading @@ -149,8 +149,10 @@ class ExplicitUpdater ( meshPointer, userDataPointer ); std::cerr << __FILE__ << ":" << __LINE__ << "Starting synchronization..." << std::endl; if(CommunicatorType::isDistributed()) fuPointer->template synchronize<CommunicatorType>(); std::cerr << __FILE__ << ":" << __LINE__ << "Synchronization done..." << std::endl; } Loading