@@ -319,35 +319,57 @@ namespace {
319319 SMART_ASSERT (block2 -> Size () == 0 || block2 -> Num_Nodes_per_Element () == 0 || !conn2 .empty ());
320320
321321 if (interFace .map_flag == MapType ::FILE_ORDER || elmt_map .empty ()) {
322- size_t node_count = block1 -> Size () * block1 -> Num_Nodes_per_Element ();
323- SMART_ASSERT (node_count == block2 -> Size () * block2 -> Num_Nodes_per_Element ());
322+ SMART_ASSERT (block1 -> Size () == block2 -> Size ());
323+ SMART_ASSERT (block1 -> Num_Nodes_per_Element () == block2 -> Num_Nodes_per_Element ());
324+ size_t num_element = block1 -> Size ();
325+ size_t nnpe = block1 -> Num_Nodes_per_Element ();
324326
325327 if (interFace .map_flag != MapType ::FILE_ORDER && !node_map .empty ()) {
326- for (size_t e = 0 ; e < node_count ; ++ e ) {
327- if (node_map [conn1 [e ] - 1 ] + 1 != conn2 [e ]) {
328- size_t elem = e / block2 -> Num_Nodes_per_Element ();
329- size_t node = e % block2 -> Num_Nodes_per_Element ();
330- Warning (
331- fmt ::format (".. Connectivities in block id {} are not the same.\n"
332- " First difference is node {} of local element {}\n" ,
333- block1 -> Id (), node + 1 , elem + 1 ));
334- is_same = false;
335- break ;
336- }
328+ for (size_t e = 0 ; is_same && e < num_element ; ++ e ) {
329+ for (size_t n = 0 ; is_same && n < nnpe ; ++ n ) {
330+ if (node_map [conn1 [e * nnpe + n ] - 1 ] + 1 != conn2 [e * nnpe + n ]) {
331+ bool permuted = false;
332+ if (interFace .allowPermutation ) {
333+ // Mismatch in ordered connectivity for this element... See if a permutation matches...
334+ std ::vector < INT > e1_conn (nnpe );
335+ for (size_t i = 0 ; i < nnpe ; i ++ ) {
336+ e1_conn [i ] = node_map [conn1 [e * nnpe + i ] - 1 ] + 1 ;
337+ }
338+ permuted = std ::is_permutation (e1_conn .begin (), e1_conn .end (), & conn2 [e ], & conn2 [e + nnpe ]);
339+ }
340+ if (!permuted ) {
341+ std ::string permit_permute = interFace .allowPermutation ? " (or permuted)" : "" ;
342+ Warning (
343+ fmt ::format (".. Connectivities in block id {} are not the same{}.\n"
344+ " First difference is node {} of local element {}\n" ,
345+ block1 -> Id (), permit_permute , n + 1 , e + 1 ));
346+ is_same = false;
347+ break ;
348+ }
349+ }
350+ }
337351 }
338352 }
339353 else {
340- for (size_t e = 0 ; e < node_count ; ++ e ) {
341- if (conn1 [e ] != conn2 [e ]) {
342- size_t elem = e / block2 -> Num_Nodes_per_Element ();
343- size_t node = e % block2 -> Num_Nodes_per_Element ();
344- Warning (
345- fmt ::format (".. Connectivities in block id {} are not the same.\n"
346- " First difference is node {} of local element {}\n" ,
347- block1 -> Id (), node + 1 , elem + 1 ));
348- is_same = false;
349- break ;
350- }
354+ for (size_t e = 0 ; is_same && e < num_element ; ++ e ) {
355+ for (size_t n = 0 ; is_same && n < nnpe ; ++ n ) {
356+ if (conn1 [e * nnpe + n ] != conn2 [e * nnpe + n ]) {
357+ bool permuted = false;
358+ if (interFace .allowPermutation ) {
359+ // Mismatch in ordered connectivity for this element... See if a permutation matches...
360+ permuted = std ::is_permutation (& conn1 [e * nnpe ], & conn1 [e * nnpe + nnpe ], & conn2 [e * nnpe ], & conn2 [e * nnpe + nnpe ]);
361+ }
362+ if (!permuted ) {
363+ std ::string permit_permute = interFace .allowPermutation ? " (or permuted)" : "" ;
364+ Warning (
365+ fmt ::format (".. Connectivities in block id {} are not the same{}.\n"
366+ " First difference is node {} of local element {}\n" ,
367+ block1 -> Id (), permit_permute , n + 1 , e + 1 ));
368+ is_same = false;
369+ break ;
370+ }
371+ }
372+ }
351373 }
352374 }
353375 }
@@ -366,14 +388,28 @@ namespace {
366388 auto n1 = conn1 [off1 ];
367389 auto map_n1 = node_map .empty () ? n1 : node_map [n1 - 1 ] + 1 ;
368390 if (map_n1 != conn2 [off2 ]) {
369- Warning (
370- fmt ::format (".. Connectivities in block id {} are not the same.\n"
371- " First difference is node {} of local element {} "
372- "(file1) {} (file2)\n" ,
373- block1 -> Id (), n + 1 , e1 + 1 , e2 + 1 ));
374- is_same = false;
375- break ;
376- }
391+ bool permuted = false;
392+ if (interFace .allowPermutation ) {
393+ // Mismatch in ordered connectivity for this element... See if a permutation matches...
394+ std ::vector < INT > e1_conn (nnpe );
395+ for (size_t i = 0 ; i < nnpe ; i ++ ) {
396+ n1 = conn1 [off1 ];
397+ map_n1 = node_map .empty () ? n1 : node_map [n1 - 1 ] + 1 ;
398+ e1_conn [i ] = map_n1 ;
399+ }
400+ permuted = std ::is_permutation (e1_conn .begin (), e1_conn .end (), & conn2 [e2 * nnpe ], & conn2 [e2 * nnpe + nnpe ]);
401+ }
402+ if (!permuted ) {
403+ std ::string permit_permute = interFace .allowPermutation ? " (or permuted)" : "" ;
404+ Warning (
405+ fmt ::format (".. Connectivities in block id {} are not the same{}.\n"
406+ " First difference is node {} of local element {} "
407+ "(file1) {} (file2)\n" ,
408+ block1 -> Id (), n + 1 , e1 + 1 , e2 + 1 ));
409+ is_same = false;
410+ break ;
411+ }
412+ }
377413 }
378414 }
379415 }
0 commit comments