diff --git a/examples/LA_example_00001.cpp b/examples/LA_example_00001.cpp index efe6113e25..4747dee9be 100644 --- a/examples/LA_example_00001.cpp +++ b/examples/LA_example_00001.cpp @@ -338,7 +338,7 @@ int run_restore(int rank, int nProcs) AMGSystemSolver solver(transpose, multigrid, debug); #if BITPIT_ENABLE_MPI==1 - solver.restoreSystem(MPI_COMM_WORLD, ".", "LA_example_0001_linear_system_"); + solver.restoreSystem(MPI_COMM_WORLD, false, ".", "LA_example_0001_linear_system_"); #else solver.restoreSystem(".", "LA_example_0001_linear_system_"); #endif diff --git a/examples/LA_example_00002.cpp b/examples/LA_example_00002.cpp index c69a39539e..b7afa6c2db 100644 --- a/examples/LA_example_00002.cpp +++ b/examples/LA_example_00002.cpp @@ -373,7 +373,7 @@ int run_restore(int rank, int nProcs) AMGSplitSystemSolver solver(transpose, multigrid, debug); #if BITPIT_ENABLE_MPI==1 - solver.restoreSystem(MPI_COMM_WORLD, ".", "LA_example_0002_linear_system_"); + solver.restoreSystem(MPI_COMM_WORLD, false, ".", "LA_example_0002_linear_system_"); #else solver.restoreSystem(".", "LA_example_0002_linear_system_"); #endif diff --git a/src/LA/system_solvers_large.cpp b/src/LA/system_solvers_large.cpp index c562ef5dcb..daa9d59f9c 100644 --- a/src/LA/system_solvers_large.cpp +++ b/src/LA/system_solvers_large.cpp @@ -1714,16 +1714,27 @@ void SystemSolver::matrixDump(std::ostream &systemStream, const std::string &dir * \param systemStream is the stream from which system information is read * \param directory is the directory from which the matrix data file will be read * \param prefix is the prefix that will be was added to the files during + */ +#if BITPIT_ENABLE_MPI==1 +/*! * \param redistribute if set to true, the matrix will be redistributed among the available * processes, allowing to restore the matrix with a different number of processes than those * used to dump it */ void SystemSolver::matrixRestore(std::istream &systemStream, const std::string &directory, const std::string &prefix, bool redistribute) +#else +void SystemSolver::matrixRestore(std::istream &systemStream, const std::string &directory, + const std::string &prefix) +#endif { BITPIT_UNUSED(systemStream); +#if BITPIT_ENABLE_MPI==1 restoreMatrix(directory, prefix + "A", redistribute, &m_A); +#else + restoreMatrix(directory, prefix + "A", &m_A); +#endif } /*! @@ -2154,21 +2165,21 @@ void SystemSolver::dumpSystem(const std::string &header, const std::string &dire * files are found they will be re-created from scratch (but they will not be initialized). */ #if BITPIT_ENABLE_MPI==1 - /*! +/*! * \param communicator is the MPI communicator - * \param directory is the directory where the files will be read from - * \param prefix is the prefix that will be was added to the files during * \param redistribute if set to true, the system will be redistributed among the available * processes, allowing to restore the system with a different number of processes than those * used to dump it */ -void SystemSolver::restoreSystem(MPI_Comm communicator, const std::string &directory, - const std::string &prefix, bool redistribute) -#else - /*! +#endif +/*! * \param directory is the directory where the files will be read from * \param prefix is the prefix that will be was added to the files during */ +#if BITPIT_ENABLE_MPI==1 +void SystemSolver::restoreSystem(MPI_Comm communicator, bool redistribute, + const std::string &directory, const std::string &prefix) +#else void SystemSolver::restoreSystem(const std::string &directory, const std::string &prefix) #endif { @@ -2189,7 +2200,11 @@ void SystemSolver::restoreSystem(const std::string &directory, const std::string restoreInfo(systemStream); // Restore the matrix +#if BITPIT_ENABLE_MPI==1 matrixRestore(systemStream, directory, prefix, redistribute); +#else + matrixRestore(systemStream, directory, prefix); +#endif // Restore RHS and solution vectors vectorsRestore(systemStream, directory, prefix); @@ -2433,16 +2448,25 @@ void SystemSolver::dumpMatrix(Mat matrix, const std::string &directory, const st * * \param directory is the directory from which the matrix data file will be read * \param name is the name of the matrix that will be dumped + */ +#if BITPIT_ENABLE_MPI==1 +/*! * \param redistribute if set to true, the matrix will be redistributed among the available * processes, allowing to restore the matrix with a different number of processes than those * used to dump it + */ +#endif +/*! * \param[out] matrix on output will contain the restored matrix */ +#if BITPIT_ENABLE_MPI==1 void SystemSolver::restoreMatrix(const std::string &directory, const std::string &name, bool redistribute, Mat *matrix) const { -#if BITPIT_ENABLE_MPI==1 - BITPIT_UNUSED(redistribute); +#else +void SystemSolver::restoreMatrix(const std::string &directory, const std::string &name, + Mat *matrix) const +{ #endif // Create matrix @@ -2787,17 +2811,25 @@ void SystemSolver::restoreVector(const std::string &directory, const std::string * * \param directory is the directory from which the vector data file will be read * \param name is the name of the vector that will be dumped + */ +#if BITPIT_ENABLE_MPI==1 +/*! * \param redistribute if set to true, the vector will be redistributed among the available * processes, allowing to restore the vector with a different number of processes than those * used to dump it + */ +#endif +/*! * \param[out] vector on output will contain the restored vector */ +#if BITPIT_ENABLE_MPI==1 void SystemSolver::restoreVector(const std::string &directory, const std::string &name, bool redistribute, Vec *vector) const -{ -#if BITPIT_ENABLE_MPI==1 - BITPIT_UNUSED(redistribute); +#else +void SystemSolver::restoreVector(const std::string &directory, const std::string &name, + Vec *vector) const #endif +{ // Get size information std::size_t localSize = std::numeric_limits::max(); diff --git a/src/LA/system_solvers_large.hpp b/src/LA/system_solvers_large.hpp index aeaf6d6915..75ec2ad104 100644 --- a/src/LA/system_solvers_large.hpp +++ b/src/LA/system_solvers_large.hpp @@ -314,8 +314,8 @@ class SystemSolver { void dumpSystem(const std::string &header, const std::string &directory, const std::string &prefix = "") const; #if BITPIT_ENABLE_MPI==1 - void restoreSystem(MPI_Comm communicator, const std::string &directory, - const std::string &prefix = "", bool redistribute = false); + void restoreSystem(MPI_Comm communicator, bool redistribute, const std::string &directory, + const std::string &prefix = ""); #else void restoreSystem(const std::string &directory, const std::string &prefix = ""); #endif @@ -377,7 +377,11 @@ class SystemSolver { void matrixUpdate(long nRows, const long *rows, const Assembler &assembler); virtual void matrixFill(const std::string &filePath); virtual void matrixDump(std::ostream &systemStream, const std::string &directory, const std::string &prefix) const; +#if BITPIT_ENABLE_MPI==1 virtual void matrixRestore(std::istream &systemStream, const std::string &directory, const std::string &prefix, bool redistribute); +#else + virtual void matrixRestore(std::istream &systemStream, const std::string &directory, const std::string &prefix); +#endif virtual void matrixDestroy(); virtual void vectorsCreate(); @@ -434,7 +438,11 @@ class SystemSolver { void createMatrix(int rowBlockSize, int colBlockSize, int nNestedRows, int nNestedCols, Mat *subMatrices, Mat *matrix) const; void fillMatrix(Mat matrix, const std::string &filePath) const; void dumpMatrix(Mat matrix, const std::string &directory, const std::string &name) const; +#if BITPIT_ENABLE_MPI==1 void restoreMatrix(const std::string &directory, const std::string &name, bool redistribute, Mat *matrix) const; +#else + void restoreMatrix(const std::string &directory, const std::string &name, Mat *matrix) const; +#endif void exportMatrix(Mat matrix, const std::string &filePath, FileFormat fileFormat) const; void destroyMatrix(Mat *matrix) const; @@ -446,7 +454,11 @@ class SystemSolver { void dumpVector(Vec vector, const std::string &directory, const std::string &name) const; void dumpVector(Vec vector, VectorSide side, const std::string &directory, const std::string &name) const; void restoreVector(const std::string &directory, const std::string &name, Mat matrix, VectorSide side, Vec *vector) const; +#if BITPIT_ENABLE_MPI==1 void restoreVector(const std::string &directory, const std::string &name, bool redistribute, Vec *vector) const; +#else + void restoreVector(const std::string &directory, const std::string &name, Vec *vector) const; +#endif void restoreVector(const std::string &directory, const std::string &name, std::size_t localSize, std::size_t globalSize, Vec *vector) const; void exportVector(Vec vector, const std::string &filePath, FileFormat fileFormat) const; void exportVector(Vec vector, std::vector *data) const; diff --git a/test/integration_tests/LA/test_LA_00006.cpp b/test/integration_tests/LA/test_LA_00006.cpp index 6a05e85871..2e36c87c06 100644 --- a/test/integration_tests/LA/test_LA_00006.cpp +++ b/test/integration_tests/LA/test_LA_00006.cpp @@ -197,7 +197,7 @@ int subtest_002() SplitSystemSolver solver(transpose, multigrid, debug); #if BITPIT_ENABLE_MPI==1 - solver.restoreSystem(MPI_COMM_WORLD, ".", "LA_example_0002_linear_system_"); + solver.restoreSystem(MPI_COMM_WORLD, false, ".", "LA_example_0002_linear_system_"); #else solver.restoreSystem(".", "LA_example_0002_linear_system_"); #endif diff --git a/test/integration_tests/LA/test_LA_parallel_00003.cpp b/test/integration_tests/LA/test_LA_parallel_00003.cpp index 55af831fec..6ebc5282fa 100644 --- a/test/integration_tests/LA/test_LA_parallel_00003.cpp +++ b/test/integration_tests/LA/test_LA_parallel_00003.cpp @@ -102,7 +102,7 @@ int subtest_001(int rank, int nProcs) log::cout() << "Restoring system..." << std::endl; SystemSolver restoredSolver("", false); - restoredSolver.restoreSystem(MPI_COMM_WORLD, ".", "test_parallel_00003_"); + restoredSolver.restoreSystem(MPI_COMM_WORLD, false, ".", "test_parallel_00003_"); long restoredGlobalNRows = restoredSolver.getRowGlobalCount(); long globalNRows = solver.getRowGlobalCount(); diff --git a/test/integration_tests/LA/test_LA_parallel_00004.cpp b/test/integration_tests/LA/test_LA_parallel_00004.cpp index 6eda053eed..114868fce2 100644 --- a/test/integration_tests/LA/test_LA_parallel_00004.cpp +++ b/test/integration_tests/LA/test_LA_parallel_00004.cpp @@ -228,7 +228,7 @@ int subtest_002(int rank, int nProcs) bool transpose = false; SplitSystemSolver solver(transpose, multigrid, debug); - solver.restoreSystem(MPI_COMM_WORLD, ".", "LA_example_0002_linear_system_"); + solver.restoreSystem(MPI_COMM_WORLD, false, ".", "LA_example_0002_linear_system_"); log::cout() << "Linear system restored." << std::endl; // Export system