diff --git a/include/mesh/unstructured_mesh.h b/include/mesh/unstructured_mesh.h index b2a3f679d60..b08840886a5 100644 --- a/include/mesh/unstructured_mesh.h +++ b/include/mesh/unstructured_mesh.h @@ -159,7 +159,8 @@ class UnstructuredMesh : public MeshBase const bool skip_find_neighbors = false, dof_id_type element_id_offset = 0, dof_id_type node_id_offset = 0, - unique_id_type unique_id_offset = 0); + unique_id_type unique_id_offset = 0, + const bool skip_prepare = false); /** diff --git a/src/mesh/mesh_base.C b/src/mesh/mesh_base.C index 0fbf752d6c2..98497c7e891 100644 --- a/src/mesh/mesh_base.C +++ b/src/mesh/mesh_base.C @@ -236,7 +236,8 @@ void MeshBase::prepare_for_use (const bool skip_renumber_nodes_and_elements, con } // Partition the mesh. - this->partition(); + if (!_skip_partitioning) + this->partition(); // If we're using DistributedMesh, we'll probably want it // parallelized. diff --git a/src/mesh/replicated_mesh.C b/src/mesh/replicated_mesh.C index f0297887b0f..dbf7ac9b232 100644 --- a/src/mesh/replicated_mesh.C +++ b/src/mesh/replicated_mesh.C @@ -1146,7 +1146,7 @@ void ReplicatedMesh::stitching_helper (const ReplicatedMesh * other_mesh, // of neighbors will be copied verbatim from the other mesh this->copy_nodes_and_elements(*other_mesh, skip_find_neighbors, elem_delta, node_delta, - unique_delta); + unique_delta, /* skip_prepare= */ true); // Copy BoundaryInfo from other_mesh too. We do this via the // list APIs rather than element-by-element for speed. @@ -1330,7 +1330,21 @@ void ReplicatedMesh::stitching_helper (const ReplicatedMesh * other_mesh, } } - this->prepare_for_use( /*skip_renumber_nodes_and_elements= */ false, skip_find_neighbors); + { + auto prev_allow_renumbering = this->allow_renumbering(); + auto prev_allow_remote_element_removal = allow_remote_element_removal(); + auto prev_skip_partitioning = skip_partitioning(); + + this->allow_renumbering(false); + this->allow_remote_element_removal(false); + this->skip_partitioning(true); + + this->prepare_for_use(false, skip_find_neighbors); + + this->allow_renumbering(prev_allow_renumbering); + this->allow_remote_element_removal(prev_allow_remote_element_removal); + this->skip_partitioning(prev_skip_partitioning); + } // After the stitching, we may want to clear boundary IDs from element // faces that are now internal to the mesh diff --git a/src/mesh/unstructured_mesh.C b/src/mesh/unstructured_mesh.C index be471e97de4..9c424232e55 100644 --- a/src/mesh/unstructured_mesh.C +++ b/src/mesh/unstructured_mesh.C @@ -66,7 +66,8 @@ void UnstructuredMesh::copy_nodes_and_elements(const UnstructuredMesh & other_me #ifdef LIBMESH_ENABLE_UNIQUE_ID unique_id_offset #endif - ) + , + const bool skip_prepare) { LOG_SCOPE("copy_nodes_and_elements()", "UnstructuredMesh"); @@ -209,19 +210,22 @@ void UnstructuredMesh::copy_nodes_and_elements(const UnstructuredMesh & other_me } } - //Finally prepare the new Mesh for use. Keep the same numbering and - //partitioning for now. - this->allow_renumbering(false); - this->allow_remote_element_removal(false); - this->skip_partitioning(true); + if (!skip_prepare) + { + //Finally prepare the new Mesh for use. Keep the same numbering and + //partitioning for now. + this->allow_renumbering(false); + this->allow_remote_element_removal(false); + this->skip_partitioning(true); - this->prepare_for_use(false, skip_find_neighbors); + this->prepare_for_use(false, skip_find_neighbors); - //But in the long term, use the same renumbering and partitioning - //policies as our source mesh. - this->allow_renumbering(other_mesh.allow_renumbering()); - this->allow_remote_element_removal(other_mesh.allow_remote_element_removal()); - this->skip_partitioning(other_mesh.skip_partitioning()); + //But in the long term, use the same renumbering and partitioning + //policies as our source mesh. + this->allow_renumbering(other_mesh.allow_renumbering()); + this->allow_remote_element_removal(other_mesh.allow_remote_element_removal()); + this->skip_partitioning(other_mesh.skip_partitioning()); + } }