ReplicatedMesh::renumber_nodes_and_elements() always renumbers
nodes even when _skip_renumber_nodes_and_elements==true.
(This is the same Issue as #938, but this also provides a simple test case.)
The renumbering happens on line 732 of replicated_mesh.C which is inside a
if(_skip_renumber_nodes_and_elements)
block...
Here's a mesh and simple test code which triggers the issue. It is contiguously numbered, but the node numbering does not start from 0, so when renumber_nodes_and_elements() gets called, the nodes get renumbered.
#include "libmesh/mesh.h"
using namespace libMesh;
int main (int argc, char ** argv)
{
LibMeshInit init(argc, argv);
Mesh mesh(init.comm());
mesh.allow_renumbering(false);
mesh.read("split_blocks.e");
// Calling renumber_nodes_and_elements() will renumber nodes,
// regardless of what the allow_renumbering() flag is set to.
mesh.renumber_nodes_and_elements();
mesh.write("renumbered.e");
return 0;
}
I'm not sure what the right fix is. As mentioned in #938, if we do truly skip renumbering then there are issues in other parts of the code. On the other hand, I don't think the renumber_nodes_and_elements() function itself can remain as-is, since it currently produces this unexpected behavior...
I think one can reasonably assert that if a user directly calls renumber_nodes_and_elements then we should renumber nodes and elements, or alternatively perhaps we could error if there's been a previous call to allow_renumbering(false). However, probably what we can't debate is that other APIs like contract should not call renumber_nodes_and_elements if _skip_renumber_nodes_and_elements is true which was the case brought up in #938
error if there's been a previous call to allow_renumbering(false).
I like this idea. Anyone who's really sure they want to override that setting can turn it off first.