Skip to content

Commit 012e632

Browse files
committed
ExodusII_IO: if the mesh is renumbered then don't load data vectors.
1 parent 64f0767 commit 012e632

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

include/mesh/exodusII_io.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ class ExodusII_IO : public MeshInput<MeshBase>,
212212
/**
213213
* If we read in a nodal solution while reading in a mesh, we can attempt
214214
* to copy that nodal solution into an EquationSystems object.
215+
*
216+
* \note This function cannot be used with renumbering. For more information,
217+
* see MeshBase::allow_renumbering(). If you need both renumbering and nodal
218+
* solution vectors, then disable renumbering, load the solution vectors, and
219+
* then reenable renumbering.
215220
*/
216221
void copy_nodal_solution(System & system,
217222
std::string system_var_name,
@@ -221,6 +226,11 @@ class ExodusII_IO : public MeshInput<MeshBase>,
221226
/**
222227
* If we read in a elemental solution while reading in a mesh, we can attempt
223228
* to copy that elemental solution into an EquationSystems object.
229+
*
230+
* \note This function cannot be used with renumbering. For more
231+
* information, see MeshBase::allow_renumbering(). If you need both
232+
* renumbering and nodal solution vectors, then disable renumbering, load the
233+
* solution vectors, and then reenable renumbering.
224234
*/
225235
void copy_elemental_solution(System & system,
226236
std::string system_var_name,

src/mesh/exodusII_io.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ void ExodusII_IO::copy_nodal_solution(System & system,
10611061

10621062
const MeshBase & mesh = MeshInput<MeshBase>::mesh();
10631063

1064+
libmesh_error_msg_if(mesh.allow_renumbering(),
1065+
"ERROR, nodal data cannot be loaded if the mesh may be renumbered!");
1066+
10641067
// With Exodus files we only open them on processor 0, so that's the
10651068
// where we have to do the data read too.
10661069
if (system.comm().rank() == 0)
@@ -1173,6 +1176,9 @@ void ExodusII_IO::copy_elemental_solution(System & system,
11731176
const MeshBase & mesh = MeshInput<MeshBase>::mesh();
11741177
const DofMap & dof_map = system.get_dof_map();
11751178

1179+
libmesh_error_msg_if(mesh.allow_renumbering(),
1180+
"ERROR, elemental data cannot be loaded if the mesh may be renumbered!");
1181+
11761182
// Map from element ID to elemental variable value. We need to use
11771183
// a map here rather than a vector (e.g. elem_var_values) since the
11781184
// libmesh element numbering can contain "holes". This is the case

tests/mesh/mesh_input.C

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,12 @@ public:
653653

654654
{
655655
MeshType mesh(*TestCommWorld);
656+
mesh.allow_renumbering(false);
656657
IOType meshinput(mesh);
657658

658659
// Avoid getting Nemesis solution values mixed up
659660
if (meshinput.is_parallel_format())
660661
{
661-
mesh.allow_renumbering(false);
662662
mesh.skip_noncritical_partitioning(true);
663663
}
664664

@@ -742,12 +742,12 @@ public:
742742

743743
{
744744
MeshType mesh(*TestCommWorld);
745+
mesh.allow_renumbering(false);
745746
IOType meshinput(mesh);
746747

747748
// Avoid getting Nemesis solution values mixed up
748749
if (meshinput.is_parallel_format())
749750
{
750-
mesh.allow_renumbering(false);
751751
mesh.skip_noncritical_partitioning(true);
752752
}
753753

@@ -831,6 +831,7 @@ public:
831831
// file(s) were written properly.
832832
{
833833
MeshType mesh(*TestCommWorld);
834+
mesh.allow_renumbering(false);
834835
EquationSystems es(mesh);
835836
auto & sys = es.add_system<System>("SimpleSystem");
836837
sys.add_variable("teste", CONSTANT, MONOMIAL);
@@ -921,12 +922,12 @@ public:
921922

922923
{
923924
MeshType mesh(*TestCommWorld);
925+
mesh.allow_renumbering(false);
924926
IOType meshinput(mesh);
925927

926928
// Avoid getting Nemesis solution values mixed up
927929
if (meshinput.is_parallel_format())
928930
{
929-
mesh.allow_renumbering(false);
930931
mesh.skip_noncritical_partitioning(true);
931932
}
932933

@@ -1034,6 +1035,7 @@ public:
10341035

10351036
// copy_elemental_solution currently requires ReplicatedMesh
10361037
ReplicatedMesh mesh(*TestCommWorld);
1038+
mesh.allow_renumbering(false);
10371039

10381040
EquationSystems es(mesh);
10391041
System & sys = es.add_system<System> ("SimpleSystem");
@@ -1183,7 +1185,6 @@ public:
11831185
{
11841186
Mesh mesh(*TestCommWorld);
11851187
mesh.allow_renumbering(false);
1186-
11871188
ExodusII_IO exii(mesh);
11881189

11891190
if (mesh.processor_id() == 0)

tests/mesh/write_vec_and_scalar.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public:
170170

171171
// Now read it back in
172172
MeshType read_mesh(*TestCommWorld);
173+
read_mesh.allow_renumbering(false);
173174
ExodusII_IO exio(read_mesh);
174175
exio.read(filename);
175176

@@ -215,6 +216,7 @@ public:
215216

216217
// Now read it back in
217218
MeshType read_mesh(*TestCommWorld);
219+
read_mesh.allow_renumbering(false);
218220
Nemesis_IO nemio(read_mesh);
219221
nemio.read(filename);
220222

0 commit comments

Comments
 (0)