Skip to content

Commit 0f2c5cf

Browse files
authored
Merge pull request #3084 from roystgnr/iga_multiblock_fix
Exodus IGA fix for multiblock files
2 parents f2a4bc0 + 666171e commit 0f2c5cf

File tree

4 files changed

+49
-9
lines changed

4 files changed

+49
-9
lines changed

src/mesh/exodusII_io.C

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@
4646
#include <map>
4747
#include <sstream>
4848

49+
namespace
50+
{
51+
using namespace libMesh;
52+
53+
const std::vector<Real> & bex_constraint_vec(std::size_t i,
54+
const ExodusII_IO_Helper & helper)
55+
{
56+
std::size_t vec_offset = 0;
57+
for (auto block_num : index_range(helper.bex_dense_constraint_vecs))
58+
{
59+
const auto & vecblock = helper.bex_dense_constraint_vecs[block_num];
60+
libmesh_assert_greater_equal(i, vec_offset);
61+
if (i - vec_offset < vecblock.size())
62+
return vecblock[i - vec_offset];
63+
64+
vec_offset += vecblock.size();
65+
}
66+
67+
libmesh_error_msg("Requested BEX coefficient vector " << i << " not found");
68+
}
69+
}
70+
4971
namespace libMesh
5072
{
5173

@@ -456,9 +478,7 @@ void ExodusII_IO::read (const std::string & fname)
456478
const auto & my_constraint_rows = exio_helper->bex_cv_conn[elem_num];
457479
const unsigned long elem_coef_vec_index =
458480
my_constraint_rows[spline_node_index] - 1; // Exodus isn't 0-based
459-
const auto & my_vec =
460-
libmesh_vector_at(exio_helper->bex_dense_constraint_vecs[i],
461-
elem_coef_vec_index);
481+
const auto & my_vec = bex_constraint_vec(elem_coef_vec_index, *exio_helper);
462482
for (auto elem_node_index :
463483
make_range(elem->n_nodes()))
464484
{
@@ -484,9 +504,11 @@ void ExodusII_IO::read (const std::string & fname)
484504
const unsigned long elem_coef_vec_index =
485505
my_constraint_rows[spline_node_index] - 1; // Exodus isn't 0-based
486506

507+
auto & coef_vec =
508+
bex_constraint_vec(elem_coef_vec_index, *exio_helper);
509+
487510
const Real coef =
488-
libmesh_vector_at(exio_helper->bex_dense_constraint_vecs[i],
489-
elem_coef_vec_index)[elem_node_index];
511+
libmesh_vector_at(coef_vec, elem_node_index);
490512

491513
const int gi = (elem_num)*exio_helper->num_nodes_per_elem +
492514
spline_node_index;
@@ -522,9 +544,10 @@ void ExodusII_IO::read (const std::string & fname)
522544

523545
const Node & spline_node = mesh.node_ref(libmesh_node_id);
524546

547+
auto & coef_vec =
548+
bex_constraint_vec(elem_coef_vec_index, *exio_helper);
525549
const Real coef =
526-
libmesh_vector_at(exio_helper->bex_dense_constraint_vecs[i],
527-
elem_coef_vec_index)[elem_node_index];
550+
libmesh_vector_at(coef_vec, elem_node_index);
528551

529552
// We don't need to store 0 entries;
530553
// constraint_rows is a sparse structure.

src/mesh/exodusII_io_helper.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ void ExodusII_IO_Helper::read_bex_cv_blocks()
909909
exII::ex_get_attribute(ex_id, &attr);
910910

911911
bex_num_dense_cv_blocks = value_count / 2;
912+
913+
libmesh_error_msg_if(bex_num_dense_cv_blocks > 1,
914+
"Found more than 1 dense bex CV block; unsure how to handle that");
912915
}
913916
}
914917

tests/mesh/mesh_input.C

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public:
6767
#endif // !LIBMESH_USE_COMPLEX_NUMBERS
6868

6969
CPPUNIT_TEST( testExodusFileMappingsPlateWithHole);
70+
CPPUNIT_TEST( testExodusFileMappingsTwoBlocks);
7071
CPPUNIT_TEST( testExodusFileMappingsCyl3d);
7172
#endif // LIBMESH_HAVE_EXODUS_API
7273

@@ -712,8 +713,13 @@ public:
712713
{
713714
auto locator = mesh.sub_point_locator();
714715

715-
const std::set<subdomain_id_type> manifold_subdomain { 0 };
716-
const std::set<subdomain_id_type> nodeelem_subdomain { 1 };
716+
// A multiblock Exodus file will have a subdomain for each block;
717+
// we stick the nodeelem subdomain at the end.
718+
const subdomain_id_type nodeelems = mesh.n_subdomains()-1;
719+
const std::set<subdomain_id_type> nodeelem_subdomain { nodeelems };
720+
std::set<subdomain_id_type> manifold_subdomain;
721+
for (auto i : make_range(nodeelems))
722+
manifold_subdomain.insert(i);
717723

718724
for (auto & elem : mesh.element_ptr_range())
719725
{
@@ -999,6 +1005,14 @@ public:
9991005
1.791640772215248, 1.413679237529376});
10001006
}
10011007

1008+
void testExodusFileMappingsTwoBlocks ()
1009+
{
1010+
testExodusFileMappings("meshes/two_quads_two_blocks.e",
1011+
// Regression values for sin_x_plus_cos_y
1012+
{2.03496953073072, 1.97996853164955,
1013+
1.18462134113435, 1.03085301158959});
1014+
}
1015+
10021016
void testExodusFileMappingsCyl3d ()
10031017
{
10041018
testExodusFileMappings("meshes/PressurizedCyl3d_Patch1_8Elem.e",
4.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)