@@ -205,73 +205,92 @@ RepeatableRayStudyBase::verifyReplicatedRays()
205205 "private param '_define_rays_replicated' == true." ;
206206
207207 // First, verify that our _rays have unique IDs beacuse we will do mapping based on Ray ID
208- verifyUniqueRayIDs (_rays .begin (),
209- _rays .end (),
210- /* global = */ false,
211- "in _rays after calling defineRays()." + error_suffix );
208+ try
209+ {
210+ verifyUniqueRayIDs (_rays .begin (),
211+ _rays .end (),
212+ /* global = */ false,
213+ "in _rays after calling defineRays()." + error_suffix );
214+ }
215+ catch (...)
216+ {
217+ _fe_problem .handleException ("verifyReplicatedRays" );
218+ }
219+ _fe_problem .checkExceptionAndStopSolve (/*print_message=*/ false);
212220
213221 // Tag for sending rays from rank 0 -> all other ranks
214222 const auto tag = comm ().get_unique_tag ();
215223
216- // Send a copy of the rays on rank 0 to all other processors for verification
217- if (_pid == 0 )
224+ try
218225 {
219- std ::vector < Parallel ::Request > requests (n_processors () - 1 );
220- auto request_it = requests .begin ();
226+ // Send a copy of the rays on rank 0 to all other processors for verification
227+ if (_pid == 0 )
228+ {
229+ std ::vector < Parallel ::Request > requests (n_processors () - 1 );
230+ auto request_it = requests .begin ();
221231
222- for (processor_id_type pid = 0 ; pid < n_processors (); ++ pid )
223- if (pid != 0 )
224- comm ().send_packed_range (
225- pid , parallelStudy (), _rays .begin (), _rays .end (), * request_it ++ , tag );
232+ for (processor_id_type pid = 0 ; pid < n_processors (); ++ pid )
233+ if (pid != 0 )
234+ comm ().send_packed_range (
235+ pid , parallelStudy (), _rays .begin (), _rays .end (), * request_it ++ , tag );
226236
227- Parallel ::wait (requests );
228- }
229- // All other processors will receive and verify that their rays match the rays on rank 0
230- else
231- {
232- // Map of RayID -> Ray for comparison from the Rays on rank 0 to the local rays
233- std ::unordered_map < RayID , const Ray * > ray_map ;
234- ray_map .reserve (_rays .size ());
235- for (const auto & ray : _rays )
236- ray_map .emplace (ray -> id (), ray .get ());
237-
238- // Receive the duplicated rays from rank 0
239- std ::vector < std ::shared_ptr < Ray >> rank_0_rays ;
240- rank_0_rays .reserve (_rays .size ());
241- comm ().receive_packed_range (
242- 0 , parallelStudy (), std ::back_inserter (rank_0_rays ), (std ::shared_ptr < Ray > * )nullptr , tag );
243-
244- // The sizes better match
245- if (rank_0_rays .size () != _rays .size ())
246- mooseError ("The size of _rays on rank " ,
247- _pid ,
248- " does not match the size of rays on rank 0." ,
249- error_suffix );
250-
251- // Make sure we have a matching local ray for each ray from rank 0
252- for (const auto & ray : rank_0_rays )
237+ Parallel ::wait (requests );
238+ }
239+ // All other processors will receive and verify that their rays match the rays on rank 0
240+ else
253241 {
254- const auto find = ray_map .find (ray -> id ());
255- if (find == ray_map .end ())
256- mooseError ("A Ray was found on rank " ,
242+ // Map of RayID -> Ray for comparison from the Rays on rank 0 to the local rays
243+ std ::unordered_map < RayID , const Ray * > ray_map ;
244+ ray_map .reserve (_rays .size ());
245+ for (const auto & ray : _rays )
246+ ray_map .emplace (ray -> id (), ray .get ());
247+
248+ // Receive the duplicated rays from rank 0
249+ std ::vector < std ::shared_ptr < Ray >> rank_0_rays ;
250+ rank_0_rays .reserve (_rays .size ());
251+ comm ().receive_packed_range (0 ,
252+ parallelStudy (),
253+ std ::back_inserter (rank_0_rays ),
254+ (std ::shared_ptr < Ray > * )nullptr ,
255+ tag );
256+
257+ // The sizes better match
258+ if (rank_0_rays .size () != _rays .size ())
259+ mooseError ("The size of _rays on rank " ,
257260 _pid ,
258- " with an ID that does not exist on rank 0." ,
259- error_suffix ,
260- "\n\n" ,
261- ray -> getInfo ());
261+ " does not match the size of rays on rank 0." ,
262+ error_suffix );
262263
263- const Ray * root_ray = find -> second ;
264- if ( * root_ray != * ray )
264+ // Make sure we have a matching local ray for each ray from rank 0
265+ for ( const auto & ray : rank_0_rays )
265266 {
266- mooseError ("A Ray was found on rank " ,
267- _pid ,
268- " that does not exist on rank 0." ,
269- error_suffix ,
270- "\n\nLocal ray:\n\n" ,
271- ray -> getInfo (),
272- "\n\nRank 0 ray:\n\n" ,
273- root_ray -> getInfo ());
267+ const auto find = ray_map .find (ray -> id ());
268+ if (find == ray_map .end ())
269+ mooseError ("A Ray was found on rank " ,
270+ _pid ,
271+ " with an ID that does not exist on rank 0." ,
272+ error_suffix ,
273+ "\n\n" ,
274+ ray -> getInfo ());
275+
276+ const Ray * root_ray = find -> second ;
277+ if (* root_ray != * ray )
278+ {
279+ mooseError ("A Ray was found on rank " ,
280+ _pid ,
281+ " that does not exist on rank 0." ,
282+ error_suffix ,
283+ "\n\nLocal ray:\n\n" ,
284+ ray -> getInfo (),
285+ "\n\nRank 0 ray:\n\n" ,
286+ root_ray -> getInfo ());
287+ }
274288 }
275289 }
276290 }
291+ catch (...)
292+ {
293+ _fe_problem .handleException ("verifyReplicatedRays" );
294+ }
295+ _fe_problem .checkExceptionAndStopSolve (/*print_message=*/ false);
277296}
0 commit comments