Skip to content

Commit 22ecd6e

Browse files
committed
EXODIFF: Allow permuted connectivity to be considered the same (with option)
1 parent fd29bfe commit 22ecd6e

File tree

4 files changed

+80
-40
lines changed

4 files changed

+80
-40
lines changed

packages/seacas/applications/exodiff/ED_SystemInterface.C

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -389,6 +389,10 @@ void SystemInterface::enroll_options()
389389
nullptr);
390390
options_.enroll("show_unmatched", GetLongOption::NoValue,
391391
"If the -partial switch used, print the elements that did not match.", nullptr);
392+
options_.enroll("allow_permuted_connectivity", GetLongOption::NoValue,
393+
"The element connectivities are the same if they match\n"
394+
"\t\texactly *OR* are a permutation of each other.",
395+
nullptr);
392396
options_.enroll("ignore_dups", GetLongOption::NoValue,
393397
"If two elements/nodes are in the same location in map or partial\n"
394398
" map case, just return first match instead of aborting.",
@@ -777,9 +781,8 @@ bool SystemInterface::parse_options(int argc, char **argv)
777781
if (options_.retrieve("ignore_nans") != nullptr) {
778782
ignore_nans = true;
779783
}
780-
if (options_.retrieve("ignore_dups") != nullptr) {
781-
ignore_dups = true;
782-
}
784+
allowPermutation = (options_.retrieve("allow_permuted_connectivity") != nullptr);
785+
783786
if (options_.retrieve("ignore_steps") != nullptr) {
784787
ignore_steps = true;
785788
}

packages/seacas/applications/exodiff/ED_SystemInterface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright(C) 1999-2020, 2022, 2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2020, 2022, 2024, 2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
@@ -125,6 +125,7 @@ class SystemInterface
125125
bool doL1Norm{false};
126126
bool doL2Norm{false};
127127
bool pedantic{false}; // Be most picky on what is different (not fully picky yet)
128+
bool allowPermutation{false}; // Allow element connectivity to be permuted -- same nodes; different order.
128129

129130
bool interpolating{false}; // Interpolate times on file2 to match times on file1;
130131
bool by_name{false}; // Match entities by name instead of by id.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// Copyright(C) 1999-2024 National Technology & Engineering Solutions
1+
// Copyright(C) 1999-2025 National Technology & Engineering Solutions
22
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
33
// NTESS, the U.S. Government retains certain rights in this software.
44
//
55
// See packages/seacas/LICENSE for details
66
#pragma once
77

8-
static const std::string version("4.00");
9-
static const std::string verdate("2024-11-14");
8+
static const std::string version("4.01");
9+
static const std::string verdate("2025-05-14");

packages/seacas/applications/exodiff/check.C

Lines changed: 68 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)