Skip to content

Commit 1abd1ce

Browse files
Allow to skip MeshBase::detect_interior_parents()
1 parent 0104425 commit 1abd1ce

6 files changed

Lines changed: 36 additions & 4 deletions

File tree

include/mesh/mesh_base.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,13 @@ class MeshBase : public ParallelObject
11931193
void allow_find_neighbors(bool allow) { _skip_find_neighbors = !allow; }
11941194
bool allow_find_neighbors() const { return !_skip_find_neighbors; }
11951195

1196+
/**
1197+
* If \p false is passed then this mesh will no longer work to detect
1198+
* interior parents when being prepared for use
1199+
*/
1200+
void allow_detect_interior_parents(bool allow) { _skip_detect_interior_parents = !allow; }
1201+
bool allow_detect_interior_parents() const { return !_skip_detect_interior_parents; }
1202+
11961203
/**
11971204
* If false is passed in then this mesh will no longer have remote
11981205
* elements deleted when being prepared for use; i.e. even a
@@ -1390,7 +1397,8 @@ class MeshBase : public ParallelObject
13901397
virtual void read (const std::string & name,
13911398
void * mesh_data=nullptr,
13921399
bool skip_renumber_nodes_and_elements=false,
1393-
bool skip_find_neighbors=false) = 0;
1400+
bool skip_find_neighbors=false,
1401+
bool skip_detect_interior_parents=false) = 0;
13941402
virtual void write (const std::string & name) const = 0;
13951403

13961404
/**
@@ -1986,6 +1994,11 @@ class MeshBase : public ParallelObject
19861994
*/
19871995
bool _skip_find_neighbors;
19881996

1997+
/**
1998+
* If this is \p true then we will skip \p detect_interior_parents in \p prepare_for_use
1999+
*/
2000+
bool _skip_detect_interior_parents;
2001+
19892002
/**
19902003
* If this is false then even on DistributedMesh remote elements
19912004
* will not be deleted during mesh preparation.

include/mesh/unstructured_mesh.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class UnstructuredMesh : public MeshBase
109109
virtual void read (const std::string & name,
110110
void * mesh_data=nullptr,
111111
bool skip_renumber_nodes_and_elements=false,
112-
bool skip_find_neighbors=false) override;
112+
bool skip_find_neighbors=false,
113+
bool skip_detect_interior_parents=false) override;
113114
/**
114115
* Write the file specified by \p name. Attempts to figure out the
115116
* proper method by the file extension.

src/mesh/distributed_mesh.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ DistributedMesh::DistributedMesh (const MeshBase & other_mesh) :
194194
this->copy_nodes_and_elements(other_mesh, true);
195195

196196
this->allow_find_neighbors(other_mesh.allow_find_neighbors());
197+
this->allow_detect_interior_parents(other_mesh.allow_detect_interior_parents());
197198
this->allow_renumbering(other_mesh.allow_renumbering());
198199
this->allow_remote_element_removal(other_mesh.allow_remote_element_removal());
199200
this->skip_partitioning(other_mesh.skip_partitioning());

src/mesh/mesh_base.C

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ MeshBase::MeshBase (const Parallel::Communicator & comm_in,
7878
_skip_all_partitioning(libMesh::on_command_line("--skip-partitioning")),
7979
_skip_renumber_nodes_and_elements(false),
8080
_skip_find_neighbors(false),
81+
_skip_detect_interior_parents(false),
8182
_allow_remote_element_removal(true),
8283
_allow_node_and_elem_unique_id_overlap(false),
8384
_spatial_dimension(d),
@@ -114,6 +115,7 @@ MeshBase::MeshBase (const MeshBase & other_mesh) :
114115
_skip_all_partitioning(other_mesh._skip_all_partitioning),
115116
_skip_renumber_nodes_and_elements(other_mesh._skip_renumber_nodes_and_elements),
116117
_skip_find_neighbors(other_mesh._skip_find_neighbors),
118+
_skip_detect_interior_parents(other_mesh._skip_detect_interior_parents),
117119
_allow_remote_element_removal(other_mesh._allow_remote_element_removal),
118120
_allow_node_and_elem_unique_id_overlap(other_mesh._allow_node_and_elem_unique_id_overlap),
119121
_elem_dims(other_mesh._elem_dims),
@@ -201,6 +203,7 @@ MeshBase& MeshBase::operator= (MeshBase && other_mesh)
201203
_skip_all_partitioning = other_mesh.skip_partitioning();
202204
_skip_renumber_nodes_and_elements = !(other_mesh.allow_renumbering());
203205
_skip_find_neighbors = !(other_mesh.allow_find_neighbors());
206+
_skip_detect_interior_parents = !(other_mesh.allow_detect_interior_parents());
204207
_allow_remote_element_removal = other_mesh.allow_remote_element_removal();
205208
_allow_node_and_elem_unique_id_overlap = other_mesh.allow_node_and_elem_unique_id_overlap();
206209
_block_id_to_name = std::move(other_mesh._block_id_to_name);
@@ -305,6 +308,8 @@ bool MeshBase::locally_equals (const MeshBase & other_mesh) const
305308
return false;
306309
if (_skip_find_neighbors != other_mesh._skip_find_neighbors)
307310
return false;
311+
if (_skip_detect_interior_parents != other_mesh._skip_detect_interior_parents)
312+
return false;
308313
if (_allow_remote_element_removal != other_mesh._allow_remote_element_removal)
309314
return false;
310315
if (_allow_node_and_elem_unique_id_overlap != other_mesh._allow_node_and_elem_unique_id_overlap)
@@ -896,7 +901,8 @@ void MeshBase::prepare_for_use ()
896901

897902
// Search the mesh for elements that have a neighboring element
898903
// of dim+1 and set that element as the interior parent
899-
this->detect_interior_parents();
904+
if (!_skip_detect_interior_parents)
905+
this->detect_interior_parents();
900906

901907
// Fix up node unique ids in case mesh generation code didn't take
902908
// exceptional care to do so.

src/mesh/replicated_mesh.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ ReplicatedMesh::ReplicatedMesh (const MeshBase & other_mesh) :
104104
this->copy_nodes_and_elements(other_mesh, true);
105105

106106
this->allow_find_neighbors(other_mesh.allow_find_neighbors());
107+
this->allow_detect_interior_parents(other_mesh.allow_detect_interior_parents());
107108
this->allow_renumbering(other_mesh.allow_renumbering());
108109
this->allow_remote_element_removal(other_mesh.allow_remote_element_removal());
109110
this->skip_partitioning(other_mesh.skip_partitioning());

src/mesh/unstructured_mesh.C

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,11 @@ void UnstructuredMesh::copy_nodes_and_elements(const MeshBase & other_mesh,
834834
const bool allowed_renumbering = this->allow_renumbering();
835835
const bool allowed_find_neighbors = this->allow_find_neighbors();
836836
const bool allowed_elem_removal = this->allow_remote_element_removal();
837+
const bool allowed_detect_detect_interior_parents = this->allow_detect_interior_parents();
837838
this->allow_renumbering(false);
838839
this->allow_remote_element_removal(false);
839840
this->allow_find_neighbors(!skip_find_neighbors);
841+
this->allow_detect_interior_parents(other_mesh.allow_detect_interior_parents());
840842

841843
// We should generally be able to skip *all* partitioning here
842844
// because we're only adding one already-consistent mesh to another.
@@ -848,6 +850,7 @@ void UnstructuredMesh::copy_nodes_and_elements(const MeshBase & other_mesh,
848850

849851
//But in the long term, don't change our policies.
850852
this->allow_find_neighbors(allowed_find_neighbors);
853+
this->allow_detect_interior_parents(allowed_detect_detect_interior_parents);
851854
this->allow_renumbering(allowed_renumbering);
852855
this->allow_remote_element_removal(allowed_elem_removal);
853856
this->skip_partitioning(skipped_partitioning);
@@ -1272,7 +1275,8 @@ void UnstructuredMesh::find_neighbors (const bool reset_remote_elements,
12721275
void UnstructuredMesh::read (const std::string & name,
12731276
void *,
12741277
bool skip_renumber_nodes_and_elements,
1275-
bool skip_find_neighbors)
1278+
bool skip_find_neighbors,
1279+
bool skip_detect_interior_parents)
12761280
{
12771281
// Set the skip_renumber_nodes_and_elements flag on all processors
12781282
// if necessary.
@@ -1294,9 +1298,15 @@ void UnstructuredMesh::read (const std::string & name,
12941298

12951299
// Done reading the mesh. Now prepare it for use.
12961300
const bool old_allow_find_neighbors = this->allow_find_neighbors();
1301+
const bool old_allow_detect_interior_parents = this->allow_detect_interior_parents();
1302+
12971303
this->allow_find_neighbors(!skip_find_neighbors);
1304+
this->allow_detect_interior_parents(!skip_detect_interior_parents);
1305+
12981306
this->prepare_for_use();
1307+
12991308
this->allow_find_neighbors(old_allow_find_neighbors);
1309+
this->allow_detect_interior_parents(old_allow_detect_interior_parents);
13001310
}
13011311

13021312

0 commit comments

Comments
 (0)