File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -954,8 +954,10 @@ template <unsigned Tdim>
954954void mpm::Mesh<Tdim>::resume_domain_cell_ranks() {
955955 // Get MPI rank
956956 int mpi_rank = 0 ;
957+ int mpi_size = 0 ;
957958#ifdef USE_MPI
958959 MPI_Comm_rank (MPI_COMM_WORLD, &mpi_rank);
960+ MPI_Comm_size (MPI_COMM_WORLD, &mpi_size);
959961 const unsigned rank_max = std::numeric_limits<unsigned >::max ();
960962 const unsigned ncells = this ->ncells ();
961963 // Vector of cell ranks
@@ -980,6 +982,13 @@ void mpm::Mesh<Tdim>::resume_domain_cell_ranks() {
980982 unsigned j = 0 ;
981983 for (auto citr = cells_.cbegin (); citr != cells_.cend (); ++citr) {
982984 int recv_rank = recv_ranks.at (j);
985+ if (recv_rank >= mpi_size) {
986+ console_->error (
987+ " Resuming analysis: Cell id {} has invalid MPI rank: {} larger than "
988+ " MPI size: {}" ,
989+ (*citr)->id (), recv_rank, mpi_size);
990+ MPI_Abort (MPI_COMM_WORLD, EXIT_FAILURE);
991+ }
983992 (*citr)->rank (recv_rank);
984993 ++j;
985994 }
Original file line number Diff line number Diff line change @@ -62,6 +62,13 @@ bool mpm::MPMExplicit<Tdim>::solve() {
6262 if (analysis_.find (" resume" ) != analysis_.end ())
6363 resume = analysis_[" resume" ][" resume" ].template get <bool >();
6464
65+ // Enable repartitioning if resume is done with particles generated outside
66+ // the MPM code.
67+ bool repartition = false ;
68+ if (analysis_.find (" resume" ) != analysis_.end () &&
69+ analysis_[" resume" ].find (" repartition" ) != analysis_[" resume" ].end ())
70+ repartition = analysis_[" resume" ][" repartition" ].template get <bool >();
71+
6572 // Pressure smoothing
6673 pressure_smoothing_ = io_->analysis_bool (" pressure_smoothing" );
6774
@@ -85,18 +92,22 @@ bool mpm::MPMExplicit<Tdim>::solve() {
8592 mesh_->iterate_over_particles (std::bind (
8693 &mpm::ParticleBase<Tdim>::compute_mass, std::placeholders::_1));
8794
95+ bool initial_step = (resume == true ) ? false : true ;
8896 // Check point resume
8997 if (resume) {
9098 this ->checkpoint_resume ();
91- mesh_->resume_domain_cell_ranks ();
99+ if (repartition) {
100+ this ->mpi_domain_decompose (initial_step);
101+ } else {
102+ mesh_->resume_domain_cell_ranks ();
92103#ifdef USE_MPI
93104#ifdef USE_GRAPH_PARTITIONING
94- MPI_Barrier (MPI_COMM_WORLD);
105+ MPI_Barrier (MPI_COMM_WORLD);
95106#endif
96107#endif
108+ }
97109 } else {
98110 // Domain decompose
99- bool initial_step = (resume == true ) ? false : true ;
100111 this ->mpi_domain_decompose (initial_step);
101112 }
102113
You can’t perform that action at this time.
0 commit comments