Line data Source code
1 : // The libMesh Finite Element Library.
2 : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 :
4 : // This library is free software; you can redistribute and/or
5 : // modify it under the terms of the GNU Lesser General Public
6 : // License as published by the Free Software Foundation; either
7 : // version 2.1 of the License, or (at your option) any later version.
8 :
9 : // This library is distributed in the hope that it will be useful,
10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 : // Lesser General Public License for more details.
13 :
14 : // You should have received a copy of the GNU Lesser General Public
15 : // License along with this library; if not, write to the Free Software
16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 :
18 :
19 :
20 : // library configuration
21 : #include "libmesh/libmesh_config.h"
22 :
23 : // Local includes
24 : #include "libmesh/boundary_info.h"
25 : #include "libmesh/libmesh_logging.h"
26 : #include "libmesh/elem.h"
27 : #include "libmesh/ghost_point_neighbors.h"
28 : #include "libmesh/mesh_base.h"
29 : #include "libmesh/mesh_communication.h"
30 : #include "libmesh/mesh_serializer.h"
31 : #include "libmesh/mesh_tools.h"
32 : #include "libmesh/parallel.h"
33 : #include "libmesh/parallel_algebra.h"
34 : #include "libmesh/parallel_fe_type.h"
35 : #include "libmesh/partitioner.h"
36 : #include "libmesh/point_locator_base.h"
37 : #include "libmesh/sparse_matrix.h"
38 : #include "libmesh/threads.h"
39 : #include "libmesh/enum_elem_type.h"
40 : #include "libmesh/enum_point_locator_type.h"
41 : #include "libmesh/enum_to_string.h"
42 : #include "libmesh/point_locator_nanoflann.h"
43 : #include "libmesh/elem_side_builder.h"
44 : #include "libmesh/elem_range.h"
45 : #include "libmesh/node_range.h"
46 :
47 : // C++ includes
48 : #include <algorithm> // for std::min
49 : #include <map> // for std::multimap
50 : #include <memory>
51 : #include <sstream> // for std::ostringstream
52 : #include <unordered_map>
53 :
54 : #include "libmesh/periodic_boundaries.h"
55 : #include "libmesh/periodic_boundary.h"
56 :
57 : namespace libMesh
58 : {
59 :
60 :
61 :
62 : // ------------------------------------------------------------
63 : // MeshBase class member functions
64 332756 : MeshBase::MeshBase (const Parallel::Communicator & comm_in,
65 332756 : unsigned char d) :
66 : ParallelObject (comm_in),
67 332756 : boundary_info (new BoundaryInfo(*this)), // BoundaryInfo has protected ctor, can't use std::make_unique
68 313436 : _n_parts (1),
69 313436 : _default_mapping_type(LAGRANGE_MAP),
70 313436 : _default_mapping_data(0),
71 313436 : _preparation (),
72 313436 : _element_stored_range (),
73 313436 : _const_active_local_element_stored_range (),
74 313436 : _point_locator (),
75 313436 : _count_lower_dim_elems_in_point_locator(true),
76 313436 : _partitioner (),
77 : #ifdef LIBMESH_ENABLE_UNIQUE_ID
78 313436 : _next_unique_id(DofObject::invalid_unique_id),
79 : #endif
80 313436 : _interior_mesh(this),
81 313436 : _skip_noncritical_partitioning(false),
82 342416 : _skip_all_partitioning(libMesh::on_command_line("--skip-partitioning")),
83 313436 : _skip_renumber_nodes_and_elements(false),
84 313436 : _skip_find_neighbors(false),
85 313436 : _skip_detect_interior_parents(false),
86 313436 : _allow_remote_element_removal(true),
87 313436 : _allow_node_and_elem_unique_id_overlap(false),
88 313436 : _spatial_dimension(d),
89 332756 : _default_ghosting(std::make_unique<GhostPointNeighbors>(*this)),
90 1046568 : _point_locator_close_to_point_tol(0.)
91 : {
92 323096 : _elem_dims.insert(d);
93 332756 : _ghosting_functors.push_back(_default_ghosting.get());
94 9660 : libmesh_assert_less_equal (LIBMESH_DIM, 3);
95 9660 : libmesh_assert_greater_equal (LIBMESH_DIM, d);
96 9660 : libmesh_assert (libMesh::initialized());
97 332756 : }
98 :
99 :
100 :
101 24392 : MeshBase::MeshBase (const MeshBase & other_mesh) :
102 : ParallelObject (other_mesh),
103 24392 : boundary_info (new BoundaryInfo(*this)), // BoundaryInfo has protected ctor, can't use std::make_unique
104 24392 : _n_parts (other_mesh._n_parts),
105 24392 : _default_mapping_type(other_mesh._default_mapping_type),
106 24392 : _default_mapping_data(other_mesh._default_mapping_data),
107 22800 : _preparation (other_mesh._preparation),
108 22800 : _element_stored_range (),
109 22800 : _const_active_local_element_stored_range (),
110 22800 : _point_locator (),
111 24392 : _count_lower_dim_elems_in_point_locator(other_mesh._count_lower_dim_elems_in_point_locator),
112 22800 : _partitioner (),
113 : #ifdef LIBMESH_ENABLE_UNIQUE_ID
114 24392 : _next_unique_id(other_mesh._next_unique_id),
115 : #endif
116 : // If the other mesh interior_parent pointers just go back to
117 : // itself, so should we
118 24392 : _interior_mesh((other_mesh._interior_mesh == &other_mesh) ?
119 : this : other_mesh._interior_mesh),
120 24392 : _skip_noncritical_partitioning(other_mesh._skip_noncritical_partitioning),
121 24392 : _skip_all_partitioning(other_mesh._skip_all_partitioning),
122 24392 : _skip_renumber_nodes_and_elements(other_mesh._skip_renumber_nodes_and_elements),
123 24392 : _skip_find_neighbors(other_mesh._skip_find_neighbors),
124 24392 : _skip_detect_interior_parents(other_mesh._skip_detect_interior_parents),
125 24392 : _allow_remote_element_removal(other_mesh._allow_remote_element_removal),
126 24392 : _allow_node_and_elem_unique_id_overlap(other_mesh._allow_node_and_elem_unique_id_overlap),
127 804 : _elem_dims(other_mesh._elem_dims),
128 804 : _elem_default_orders(other_mesh._elem_default_orders),
129 24392 : _supported_nodal_order(other_mesh._supported_nodal_order),
130 804 : _mesh_subdomains(other_mesh._mesh_subdomains),
131 804 : _elemset_codes_inverse_map(other_mesh._elemset_codes_inverse_map),
132 804 : _all_elemset_ids(other_mesh._all_elemset_ids),
133 24392 : _spatial_dimension(other_mesh._spatial_dimension),
134 24392 : _default_ghosting(std::make_unique<GhostPointNeighbors>(*this)),
135 99932 : _point_locator_close_to_point_tol(other_mesh._point_locator_close_to_point_tol)
136 : {
137 804 : const GhostingFunctor * const other_default_ghosting = other_mesh._default_ghosting.get();
138 :
139 79468 : for (GhostingFunctor * const gf : other_mesh._ghosting_functors)
140 : {
141 : // If the other mesh is using default ghosting, then we will use our own
142 : // default ghosting
143 55076 : if (gf == other_default_ghosting)
144 : {
145 24392 : _ghosting_functors.push_back(_default_ghosting.get());
146 24392 : continue;
147 : }
148 :
149 60352 : std::shared_ptr<GhostingFunctor> clone_gf = gf->clone();
150 : // Some subclasses of GhostingFunctor might not override the
151 : // clone function yet. If this is the case, GhostingFunctor will
152 : // return nullptr by default. The clone function should be overridden
153 : // in all derived classes. This following code ("else") is written
154 : // for API upgrade. That will allow users gradually to update their code.
155 : // Once the API upgrade is done, we will come back and delete "else."
156 30684 : if (clone_gf)
157 : {
158 30684 : clone_gf->set_mesh(this);
159 60352 : add_ghosting_functor(clone_gf);
160 : }
161 : else
162 : {
163 : libmesh_deprecated();
164 0 : add_ghosting_functor(*gf);
165 : }
166 : }
167 :
168 24392 : if (other_mesh._partitioner.get())
169 47980 : _partitioner = other_mesh._partitioner->clone();
170 :
171 : #ifdef LIBMESH_ENABLE_PERIODIC
172 : // Deep copy of all periodic boundaries
173 24392 : if (other_mesh._disjoint_neighbor_boundary_pairs)
174 : {
175 136 : _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
176 :
177 213 : for (const auto & [id, pb] : *other_mesh._disjoint_neighbor_boundary_pairs)
178 142 : if (pb)
179 280 : (*_disjoint_neighbor_boundary_pairs)[id] = pb->clone();
180 : }
181 : #endif
182 :
183 : // _elemset_codes stores pointers to entries in _elemset_codes_inverse_map,
184 : // so it is not possible to simply copy it directly from other_mesh
185 24392 : for (const auto & [set, code] : _elemset_codes_inverse_map)
186 0 : _elemset_codes.emplace(code, &set);
187 24392 : }
188 :
189 426 : MeshBase& MeshBase::operator= (MeshBase && other_mesh)
190 : {
191 12 : LOG_SCOPE("operator=(&&)", "MeshBase");
192 :
193 : // Move assign as a ParallelObject.
194 12 : this->ParallelObject::operator=(other_mesh);
195 :
196 426 : _n_parts = other_mesh.n_partitions();
197 426 : _default_mapping_type = other_mesh.default_mapping_type();
198 426 : _default_mapping_data = other_mesh.default_mapping_data();
199 426 : _preparation = other_mesh._preparation;
200 12 : _element_stored_range = std::move(other_mesh._element_stored_range);
201 12 : _const_active_local_element_stored_range = std::move(other_mesh._const_active_local_element_stored_range);
202 12 : _point_locator = std::move(other_mesh._point_locator);
203 426 : _count_lower_dim_elems_in_point_locator = other_mesh.get_count_lower_dim_elems_in_point_locator();
204 : #ifdef LIBMESH_ENABLE_UNIQUE_ID
205 426 : _next_unique_id = other_mesh.next_unique_id();
206 : #endif
207 : // If the other mesh interior_parent pointers just go back to
208 : // itself, so should we
209 426 : _interior_mesh = (other_mesh._interior_mesh == &other_mesh) ?
210 : this : other_mesh._interior_mesh;
211 426 : _skip_noncritical_partitioning = other_mesh.skip_noncritical_partitioning();
212 426 : _skip_all_partitioning = other_mesh.skip_partitioning();
213 426 : _skip_renumber_nodes_and_elements = !(other_mesh.allow_renumbering());
214 426 : _skip_find_neighbors = !(other_mesh.allow_find_neighbors());
215 426 : _skip_detect_interior_parents = !(other_mesh.allow_detect_interior_parents());
216 426 : _allow_remote_element_removal = other_mesh.allow_remote_element_removal();
217 426 : _allow_node_and_elem_unique_id_overlap = other_mesh.allow_node_and_elem_unique_id_overlap();
218 12 : _block_id_to_name = std::move(other_mesh._block_id_to_name);
219 12 : _elem_dims = std::move(other_mesh.elem_dimensions());
220 12 : _elem_default_orders = std::move(other_mesh.elem_default_orders());
221 426 : _supported_nodal_order = other_mesh.supported_nodal_order();
222 12 : _mesh_subdomains = other_mesh._mesh_subdomains;
223 12 : _elemset_codes = std::move(other_mesh._elemset_codes);
224 12 : _elemset_codes_inverse_map = std::move(other_mesh._elemset_codes_inverse_map);
225 12 : _all_elemset_ids = std::move(other_mesh._all_elemset_ids);
226 426 : _spatial_dimension = other_mesh.spatial_dimension();
227 426 : _elem_integer_names = std::move(other_mesh._elem_integer_names);
228 426 : _elem_integer_default_values = std::move(other_mesh._elem_integer_default_values);
229 426 : _node_integer_names = std::move(other_mesh._node_integer_names);
230 426 : _node_integer_default_values = std::move(other_mesh._node_integer_default_values);
231 426 : _point_locator_close_to_point_tol = other_mesh.get_point_locator_close_to_point_tol();
232 :
233 : #ifdef LIBMESH_ENABLE_PERIODIC
234 : // Deep copy of all periodic boundaries:
235 : // We must clone each PeriodicBoundaryBase in the source map,
236 : // since unique_ptr cannot be copied and we need independent instances
237 426 : if (other_mesh._disjoint_neighbor_boundary_pairs)
238 : {
239 0 : _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
240 :
241 0 : for (const auto & [id, pb] : *other_mesh._disjoint_neighbor_boundary_pairs)
242 0 : if (pb)
243 0 : (*_disjoint_neighbor_boundary_pairs)[id] = pb->clone();
244 : }
245 : #endif
246 :
247 : // This relies on our subclasses *not* invalidating pointers when we
248 : // do their portion of the move assignment later!
249 12 : boundary_info = std::move(other_mesh.boundary_info);
250 12 : boundary_info->set_mesh(*this);
251 :
252 : #ifdef DEBUG
253 : // Make sure that move assignment worked for pointers
254 12 : for (const auto & [set, code] : _elemset_codes_inverse_map)
255 : {
256 0 : auto it = _elemset_codes.find(code);
257 0 : libmesh_assert_msg(it != _elemset_codes.end(),
258 : "Elemset code " << code << " not found in _elmset_codes container.");
259 0 : libmesh_assert_equal_to(it->second, &set);
260 : }
261 : #endif
262 :
263 : // We're *not* really done at this point, but we have the problem
264 : // that some of our data movement might be expecting subclasses data
265 : // movement to happen first. We'll let subclasses handle that by
266 : // calling our post_dofobject_moves()
267 438 : return *this;
268 : }
269 :
270 :
271 15151 : bool MeshBase::operator== (const MeshBase & other_mesh) const
272 : {
273 1062 : LOG_SCOPE("operator==()", "MeshBase");
274 :
275 15151 : bool is_equal = this->locally_equals(other_mesh);
276 15151 : this->comm().min(is_equal);
277 16213 : return is_equal;
278 : }
279 :
280 :
281 15151 : bool MeshBase::locally_equals (const MeshBase & other_mesh) const
282 : {
283 : // Check whether (almost) everything in the base is equal
284 : //
285 : // We don't check _next_unique_id here, because it's expected to
286 : // change in a DistributedMesh prepare_for_use(); it's conceptually
287 : // "mutable".
288 : //
289 : // We use separate if statements instead of logical operators here,
290 : // to make it easy to see the failing condition when using a
291 : // debugger to figure out why a MeshTools::valid_is_prepared(mesh)
292 : // is failing.
293 15151 : if (_n_parts != other_mesh._n_parts)
294 0 : return false;
295 15151 : if (_default_mapping_type != other_mesh._default_mapping_type)
296 0 : return false;
297 15151 : if (_default_mapping_data != other_mesh._default_mapping_data)
298 0 : return false;
299 15151 : if (_preparation != other_mesh._preparation)
300 0 : return false;
301 16621 : if (_count_lower_dim_elems_in_point_locator !=
302 15151 : other_mesh._count_lower_dim_elems_in_point_locator)
303 0 : return false;
304 :
305 : // We should either both have our own interior parents or both not;
306 : // but if we both don't then we can't really assert anything else
307 : // because pointing at the same interior mesh is fair but so is
308 : // pointing at two different copies of "the same" interior mesh.
309 16621 : if ((_interior_mesh == this) !=
310 15151 : (other_mesh._interior_mesh == &other_mesh))
311 0 : return false;
312 :
313 15151 : if (_skip_noncritical_partitioning != other_mesh._skip_noncritical_partitioning)
314 0 : return false;
315 15151 : if (_skip_all_partitioning != other_mesh._skip_all_partitioning)
316 0 : return false;
317 15151 : if (_skip_renumber_nodes_and_elements != other_mesh._skip_renumber_nodes_and_elements)
318 0 : return false;
319 15151 : if (_skip_find_neighbors != other_mesh._skip_find_neighbors)
320 0 : return false;
321 15151 : if (_skip_detect_interior_parents != other_mesh._skip_detect_interior_parents)
322 0 : return false;
323 15151 : if (_allow_remote_element_removal != other_mesh._allow_remote_element_removal)
324 0 : return false;
325 15151 : if (_allow_node_and_elem_unique_id_overlap != other_mesh._allow_node_and_elem_unique_id_overlap)
326 0 : return false;
327 15151 : if (_spatial_dimension != other_mesh._spatial_dimension)
328 0 : return false;
329 15151 : if (_point_locator_close_to_point_tol != other_mesh._point_locator_close_to_point_tol)
330 0 : return false;
331 15151 : if (_block_id_to_name != other_mesh._block_id_to_name)
332 0 : return false;
333 15151 : if (_elem_dims != other_mesh._elem_dims)
334 0 : return false;
335 15151 : if (_elem_default_orders != other_mesh._elem_default_orders)
336 0 : return false;
337 15151 : if (_supported_nodal_order != other_mesh._supported_nodal_order)
338 0 : return false;
339 15151 : if (_mesh_subdomains != other_mesh._mesh_subdomains)
340 6 : return false;
341 14938 : if (_all_elemset_ids != other_mesh._all_elemset_ids)
342 0 : return false;
343 14938 : if (_elem_integer_names != other_mesh._elem_integer_names)
344 0 : return false;
345 15340 : if (_elem_integer_default_values != other_mesh._elem_integer_default_values)
346 0 : return false;
347 14938 : if (_node_integer_names != other_mesh._node_integer_names)
348 0 : return false;
349 15340 : if (_node_integer_default_values != other_mesh._node_integer_default_values)
350 0 : return false;
351 14938 : if (static_cast<bool>(_default_ghosting) != static_cast<bool>(other_mesh._default_ghosting))
352 0 : return false;
353 14938 : if (static_cast<bool>(_partitioner) != static_cast<bool>(other_mesh._partitioner))
354 0 : return false;
355 14938 : if (*boundary_info != *other_mesh.boundary_info)
356 6 : return false;
357 :
358 : // First check whether the "existence" of the two pointers differs (one present, one absent)
359 15775 : if (static_cast<bool>(_disjoint_neighbor_boundary_pairs) !=
360 1050 : static_cast<bool>(other_mesh._disjoint_neighbor_boundary_pairs))
361 0 : return false;
362 : // If both exist, compare the contents (Weak Test: just compare sizes like `_ghosting_functors`)
363 14729 : if (_disjoint_neighbor_boundary_pairs &&
364 1054 : (_disjoint_neighbor_boundary_pairs->size() != other_mesh._disjoint_neighbor_boundary_pairs->size()))
365 0 : return false;
366 :
367 : const constraint_rows_type & other_rows =
368 1050 : other_mesh.get_constraint_rows();
369 66361 : for (const auto & [node, row] : this->_constraint_rows)
370 : {
371 51636 : const dof_id_type node_id = node->id();
372 51636 : const Node * other_node = other_mesh.query_node_ptr(node_id);
373 51636 : if (!other_node)
374 0 : return false;
375 :
376 6416 : auto it = other_rows.find(other_node);
377 51636 : if (it == other_rows.end())
378 0 : return false;
379 :
380 6416 : const auto & other_row = it->second;
381 58052 : if (row.size() != other_row.size())
382 0 : return false;
383 :
384 231893 : for (auto i : index_range(row))
385 : {
386 18096 : const auto & [elem_pair, coef] = row[i];
387 18096 : const auto & [other_elem_pair, other_coef] = other_row[i];
388 18096 : libmesh_assert(elem_pair.first);
389 18096 : libmesh_assert(other_elem_pair.first);
390 180257 : if (elem_pair.first->id() !=
391 342418 : other_elem_pair.first->id() ||
392 180257 : elem_pair.second !=
393 198353 : other_elem_pair.second ||
394 180257 : coef != other_coef)
395 0 : return false;
396 : }
397 : }
398 :
399 14725 : for (const auto & [elemset_code, elemset_ptr] : this->_elemset_codes)
400 0 : if (const auto it = other_mesh._elemset_codes.find(elemset_code);
401 0 : it == other_mesh._elemset_codes.end() || *elemset_ptr != *it->second)
402 0 : return false;
403 :
404 : // FIXME: we have no good way to compare ghosting functors, since
405 : // they're in a vector of pointers, and we have no way *at all*
406 : // to compare ghosting functors, since they don't have operator==
407 : // defined and we encourage users to subclass them. We can check if
408 : // we have the same number, is all.
409 16171 : if (_ghosting_functors.size() !=
410 1446 : other_mesh._ghosting_functors.size())
411 0 : return false;
412 :
413 : // Same deal for partitioners. We tested that we both have one or
414 : // both don't, but are they equivalent? Let's guess "yes".
415 :
416 : // Now let the subclasses decide whether everything else is equal
417 14725 : return this->subclass_locally_equals(other_mesh);
418 : }
419 :
420 :
421 367596 : MeshBase::~MeshBase()
422 : {
423 357148 : this->MeshBase::clear();
424 :
425 10464 : libmesh_exceptionless_assert (!libMesh::closed());
426 1365856 : }
427 :
428 :
429 :
430 10923691 : unsigned int MeshBase::mesh_dimension() const
431 : {
432 10923691 : if (!_elem_dims.empty())
433 10923691 : return cast_int<unsigned int>(*_elem_dims.rbegin());
434 0 : return 0;
435 : }
436 :
437 :
438 :
439 0 : void MeshBase::set_elem_dimensions(std::set<unsigned char> elem_dims)
440 : {
441 : #ifdef DEBUG
442 : // In debug mode, we call cache_elem_data() and then make sure
443 : // the result actually agrees with what the user specified.
444 0 : parallel_object_only();
445 :
446 0 : this->cache_elem_data();
447 0 : libmesh_assert_msg(_elem_dims == elem_dims, \
448 : "Specified element dimensions does not match true element dimensions!");
449 : #endif
450 :
451 0 : _elem_dims = std::move(elem_dims);
452 0 : }
453 :
454 :
455 :
456 1775 : void MeshBase::add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
457 : {
458 : // Populate inverse map, stealing id_set's resources
459 1725 : auto [it1, inserted1] = _elemset_codes_inverse_map.emplace(std::move(id_set), code);
460 :
461 : // Reference to the newly inserted (or previously existing) id_set
462 1775 : const auto & inserted_id_set = it1->first;
463 :
464 : // Keep track of all elemset ids ever added for O(1) n_elemsets()
465 : // performance. Only need to do this if we didn't know about this
466 : // id_set before...
467 1775 : if (inserted1)
468 1775 : _all_elemset_ids.insert(inserted_id_set.begin(), inserted_id_set.end());
469 :
470 : // Take the address of the newly emplaced set to use in
471 : // _elemset_codes, avoid duplicating std::set storage
472 1775 : auto [it2, inserted2] = _elemset_codes.emplace(code, &inserted_id_set);
473 :
474 : // Throw an error if this code already exists with a pointer to a
475 : // different set of ids.
476 1775 : libmesh_error_msg_if(!inserted2 && it2->second != &inserted_id_set,
477 : "The elemset code " << code << " already exists with a different id_set.");
478 1775 : }
479 :
480 :
481 :
482 15010 : unsigned int MeshBase::n_elemsets() const
483 : {
484 15010 : return _all_elemset_ids.size();
485 : }
486 :
487 2963 : void MeshBase::get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type & id_set_to_fill) const
488 : {
489 : // If we don't recognize this elemset_code, hand back an empty set
490 102 : id_set_to_fill.clear();
491 :
492 2963 : if (const auto it = _elemset_codes.find(elemset_code);
493 102 : it != _elemset_codes.end())
494 1386 : id_set_to_fill.insert(it->second->begin(), it->second->end());
495 2963 : }
496 :
497 852 : dof_id_type MeshBase::get_elemset_code(const MeshBase::elemset_type & id_set) const
498 : {
499 24 : auto it = _elemset_codes_inverse_map.find(id_set);
500 852 : return (it == _elemset_codes_inverse_map.end()) ? DofObject::invalid_id : it->second;
501 : }
502 :
503 8453 : std::vector<dof_id_type> MeshBase::get_elemset_codes() const
504 : {
505 240 : std::vector<dof_id_type> ret;
506 8453 : ret.reserve(_elemset_codes.size());
507 9234 : for (const auto & pr : _elemset_codes)
508 781 : ret.push_back(pr.first);
509 8453 : return ret;
510 : }
511 :
512 284 : void MeshBase::change_elemset_code(dof_id_type old_code, dof_id_type new_code)
513 : {
514 : // Look up elemset ids for old_code
515 8 : auto it = _elemset_codes.find(old_code);
516 :
517 : // If we don't have the old_code, then do nothing. Alternatively, we
518 : // could throw an error since trying to change an elemset code you
519 : // don't have could indicate there's a problem...
520 284 : if (it == _elemset_codes.end())
521 0 : return;
522 :
523 : // Make copy of the set of elemset ids. We are not changing these,
524 : // only updating the elemset code it corresponds to.
525 284 : elemset_type id_set_copy = *(it->second);
526 :
527 : // Look up the corresponding entry in the inverse map. Note: we want
528 : // the iterator because we are going to remove it.
529 8 : auto inverse_it = _elemset_codes_inverse_map.find(id_set_copy);
530 284 : libmesh_error_msg_if(inverse_it == _elemset_codes_inverse_map.end(),
531 : "Expected _elemset_codes_inverse_map entry for elemset code " << old_code);
532 :
533 : // Erase entry from inverse map
534 276 : _elemset_codes_inverse_map.erase(inverse_it);
535 :
536 : // Erase entry from forward map
537 276 : _elemset_codes.erase(it);
538 :
539 : // Add new code with original set of ids.
540 560 : this->add_elemset_code(new_code, id_set_copy);
541 :
542 : // We can't update any actual elemset codes if there is no extra integer defined for it.
543 284 : if (!this->has_elem_integer("elemset_code"))
544 0 : return;
545 :
546 : // Get index of elemset_code extra integer
547 284 : unsigned int elemset_index = this->get_elem_integer_index("elemset_code");
548 :
549 : // Loop over all elems and update code
550 : Threads::parallel_for
551 284 : (this->element_stored_range(),
552 1240 : [elemset_index, old_code, new_code](const ElemRange & range)
553 : {
554 5254 : for (Elem * elem : range)
555 : {
556 : dof_id_type elemset_code =
557 4970 : elem->get_extra_integer(elemset_index);
558 :
559 4970 : if (elemset_code == old_code)
560 2415 : elem->set_extra_integer(elemset_index, new_code);
561 : }
562 284 : });
563 : }
564 :
565 284 : void MeshBase::change_elemset_id(elemset_id_type old_id, elemset_id_type new_id)
566 : {
567 : // Early return if we don't have old_id
568 8 : if (!_all_elemset_ids.count(old_id))
569 0 : return;
570 :
571 : // Throw an error if the new_id is already used
572 8 : libmesh_error_msg_if(_all_elemset_ids.count(new_id),
573 : "Cannot change elemset id " << old_id <<
574 : " to " << new_id << ", " << new_id << " already exists.");
575 :
576 : // We will build up a new version of the inverse map so we can iterate over
577 : // the current one without invalidating anything.
578 16 : std::map<MeshBase::elemset_type, dof_id_type> new_elemset_codes_inverse_map;
579 852 : for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
580 : {
581 32 : auto id_set_copy = id_set;
582 16 : if (id_set_copy.count(old_id))
583 : {
584 : // Remove old_id, insert new_id
585 8 : id_set_copy.erase(old_id);
586 276 : id_set_copy.insert(new_id);
587 : }
588 :
589 : // Store in new version of map
590 552 : new_elemset_codes_inverse_map.emplace(id_set_copy, elemset_code);
591 : }
592 :
593 : // Swap existing map with newly-built one
594 8 : _elemset_codes_inverse_map.swap(new_elemset_codes_inverse_map);
595 :
596 : // Reconstruct _elemset_codes map
597 8 : _elemset_codes.clear();
598 852 : for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
599 568 : _elemset_codes.emplace(elemset_code, &id_set);
600 :
601 : // Update _all_elemset_ids
602 8 : _all_elemset_ids.erase(old_id);
603 276 : _all_elemset_ids.insert(new_id);
604 : }
605 :
606 262591 : unsigned int MeshBase::spatial_dimension () const
607 : {
608 271295 : return cast_int<unsigned int>(_spatial_dimension);
609 : }
610 :
611 :
612 :
613 369814 : void MeshBase::set_spatial_dimension(unsigned char d)
614 : {
615 : // The user can set the _spatial_dimension however they wish,
616 : // libMesh will only *increase* the spatial dimension, however,
617 : // never decrease it.
618 369814 : _spatial_dimension = d;
619 369814 : }
620 :
621 :
622 :
623 4716 : unsigned int MeshBase::add_elem_integer(std::string name,
624 : bool allocate_data,
625 : dof_id_type default_value)
626 : {
627 5912 : for (auto i : index_range(_elem_integer_names))
628 1416 : if (_elem_integer_names[i] == name)
629 : {
630 8 : libmesh_assert_less(i, _elem_integer_default_values.size());
631 284 : _elem_integer_default_values[i] = default_value;
632 284 : return i;
633 : }
634 :
635 136 : libmesh_assert_equal_to(_elem_integer_names.size(),
636 : _elem_integer_default_values.size());
637 4432 : _elem_integer_names.push_back(std::move(name));
638 4432 : _elem_integer_default_values.push_back(default_value);
639 4432 : if (allocate_data)
640 3844 : this->size_elem_extra_integers();
641 4568 : return _elem_integer_names.size()-1;
642 : }
643 :
644 :
645 :
646 38197 : std::vector<unsigned int> MeshBase::add_elem_integers(const std::vector<std::string> & names,
647 : bool allocate_data,
648 : const std::vector<dof_id_type> * default_values)
649 : {
650 1208 : libmesh_assert(!default_values || default_values->size() == names.size());
651 1208 : libmesh_assert_equal_to(_elem_integer_names.size(), _elem_integer_default_values.size());
652 :
653 2416 : std::unordered_map<std::string, std::size_t> name_indices;
654 39049 : for (auto i : index_range(_elem_integer_names))
655 852 : name_indices[_elem_integer_names[i]] = i;
656 :
657 39389 : std::vector<unsigned int> returnval(names.size());
658 :
659 1208 : bool added_an_integer = false;
660 40702 : for (auto i : index_range(names))
661 : {
662 156 : const std::string & name = names[i];
663 2505 : if (const auto it = name_indices.find(name);
664 78 : it != name_indices.end())
665 : {
666 426 : returnval[i] = it->second;
667 438 : _elem_integer_default_values[it->second] =
668 426 : default_values ? (*default_values)[i] : DofObject::invalid_id;
669 : }
670 : else
671 : {
672 2145 : returnval[i] = _elem_integer_names.size();
673 2079 : name_indices[name] = returnval[i];
674 2079 : _elem_integer_names.push_back(name);
675 : _elem_integer_default_values.push_back
676 2883 : (default_values ? (*default_values)[i] : DofObject::invalid_id);
677 66 : added_an_integer = true;
678 : }
679 : }
680 :
681 38197 : if (allocate_data && added_an_integer)
682 1065 : this->size_elem_extra_integers();
683 :
684 39405 : return returnval;
685 : }
686 :
687 :
688 :
689 3278 : unsigned int MeshBase::get_elem_integer_index(std::string_view name) const
690 : {
691 4130 : for (auto i : index_range(_elem_integer_names))
692 4037 : if (_elem_integer_names[i] == name)
693 3278 : return i;
694 :
695 0 : libmesh_error_msg("Unknown elem integer " << name);
696 : return libMesh::invalid_uint;
697 : }
698 :
699 :
700 :
701 8539 : bool MeshBase::has_elem_integer(std::string_view name) const
702 : {
703 9533 : for (auto & entry : _elem_integer_names)
704 2367 : if (entry == name)
705 40 : return true;
706 :
707 632 : return false;
708 : }
709 :
710 :
711 :
712 16916 : unsigned int MeshBase::add_node_integer(std::string name,
713 : bool allocate_data,
714 : dof_id_type default_value)
715 : {
716 27329 : for (auto i : index_range(_node_integer_names))
717 10208 : if (_node_integer_names[i] == name)
718 : {
719 16 : libmesh_assert_less(i, _node_integer_default_values.size());
720 568 : _node_integer_default_values[i] = default_value;
721 568 : return i;
722 : }
723 :
724 702 : libmesh_assert_equal_to(_node_integer_names.size(),
725 : _node_integer_default_values.size());
726 16348 : _node_integer_names.push_back(std::move(name));
727 16348 : _node_integer_default_values.push_back(default_value);
728 16348 : if (allocate_data)
729 7120 : this->size_node_extra_integers();
730 17050 : return _node_integer_names.size()-1;
731 : }
732 :
733 :
734 :
735 38055 : std::vector<unsigned int> MeshBase::add_node_integers(const std::vector<std::string> & names,
736 : bool allocate_data,
737 : const std::vector<dof_id_type> * default_values)
738 : {
739 1204 : libmesh_assert(!default_values || default_values->size() == names.size());
740 1204 : libmesh_assert_equal_to(_node_integer_names.size(), _node_integer_default_values.size());
741 :
742 2408 : std::unordered_map<std::string, std::size_t> name_indices;
743 38623 : for (auto i : index_range(_node_integer_names))
744 568 : name_indices[_node_integer_names[i]] = i;
745 :
746 39243 : std::vector<unsigned int> returnval(names.size());
747 :
748 1204 : bool added_an_integer = false;
749 40687 : for (auto i : index_range(names))
750 : {
751 192 : const std::string & name = names[i];
752 2632 : if (const auto it = name_indices.find(name);
753 96 : it != name_indices.end())
754 : {
755 0 : returnval[i] = it->second;
756 0 : _node_integer_default_values[it->second] =
757 0 : default_values ? (*default_values)[i] : DofObject::invalid_id;
758 : }
759 : else
760 : {
761 2728 : returnval[i] = _node_integer_names.size();
762 2632 : name_indices[name] = returnval[i];
763 2632 : _node_integer_names.push_back(name);
764 : _node_integer_default_values.push_back
765 3724 : (default_values ? (*default_values)[i] : DofObject::invalid_id);
766 96 : added_an_integer = true;
767 : }
768 : }
769 :
770 38055 : if (allocate_data && added_an_integer)
771 1010 : this->size_node_extra_integers();
772 :
773 39259 : return returnval;
774 : }
775 :
776 :
777 :
778 710 : unsigned int MeshBase::get_node_integer_index(std::string_view name) const
779 : {
780 1988 : for (auto i : index_range(_node_integer_names))
781 1968 : if (_node_integer_names[i] == name)
782 710 : return i;
783 :
784 0 : libmesh_error_msg("Unknown node integer " << name);
785 : return libMesh::invalid_uint;
786 : }
787 :
788 :
789 :
790 1136 : bool MeshBase::has_node_integer(std::string_view name) const
791 : {
792 3134 : for (auto & entry : _node_integer_names)
793 3134 : if (entry == name)
794 32 : return true;
795 :
796 0 : return false;
797 : }
798 :
799 :
800 :
801 42305 : void MeshBase::remove_orphaned_nodes ()
802 : {
803 2584 : LOG_SCOPE("remove_orphaned_nodes()", "MeshBase");
804 :
805 : // Will hold the set of nodes that are currently connected to elements
806 1292 : std::unordered_set<Node *> connected_nodes;
807 :
808 : // Loop over the elements. Find which nodes are connected to at
809 : // least one of them.
810 3889342 : for (const auto & element : this->element_ptr_range())
811 19081100 : for (auto & n : element->node_ref_range())
812 16944527 : connected_nodes.insert(&n);
813 :
814 11204814 : for (const auto & node : this->node_ptr_range())
815 723942 : if (!connected_nodes.count(node))
816 122761 : this->delete_node(node);
817 :
818 42305 : _preparation.has_removed_orphaned_nodes = true;
819 42305 : }
820 :
821 :
822 :
823 : #ifdef LIBMESH_ENABLE_DEPRECATED
824 0 : void MeshBase::prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
825 : {
826 : libmesh_deprecated();
827 :
828 : // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
829 : // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
830 : // precedence
831 0 : if (skip_renumber_nodes_and_elements)
832 0 : this->allow_renumbering(false);
833 :
834 : // We always accept the user's value for skip_find_neighbors, in contrast to skip_renumber
835 0 : const bool old_allow_find_neighbors = this->allow_find_neighbors();
836 0 : this->allow_find_neighbors(!skip_find_neighbors);
837 :
838 0 : this->prepare_for_use();
839 :
840 0 : this->allow_find_neighbors(old_allow_find_neighbors);
841 0 : }
842 :
843 0 : void MeshBase::prepare_for_use (const bool skip_renumber_nodes_and_elements)
844 : {
845 : libmesh_deprecated();
846 :
847 : // We only respect the users wish if they tell us to skip renumbering. If they tell us not to
848 : // skip renumbering but someone previously called allow_renumbering(false), then the latter takes
849 : // precedence
850 0 : if (skip_renumber_nodes_and_elements)
851 0 : this->allow_renumbering(false);
852 :
853 0 : this->prepare_for_use();
854 0 : }
855 : #endif // LIBMESH_ENABLE_DEPRECATED
856 :
857 :
858 :
859 :
860 435442 : void MeshBase::prepare_for_use ()
861 : {
862 : // Mark everything as unprepared, except for those things we've been
863 : // told we don't need to prepare, for backwards compatibility
864 435442 : this->clear_point_locator();
865 435442 : this->clear_stored_ranges();
866 435442 : _preparation = false;
867 435442 : _preparation.has_neighbor_ptrs = _skip_find_neighbors;
868 435442 : _preparation.has_removed_remote_elements = !_allow_remote_element_removal;
869 :
870 435442 : this->complete_preparation();
871 435442 : }
872 :
873 :
874 438708 : void MeshBase::complete_preparation()
875 : {
876 26232 : LOG_SCOPE("complete_preparation()", "MeshBase");
877 :
878 13116 : parallel_object_only();
879 :
880 13116 : libmesh_assert(this->comm().verify(this->is_serial()));
881 :
882 : // If we don't go into this method with valid constraint rows, we're
883 : // only going to be able to make that worse.
884 : #ifdef DEBUG
885 13116 : MeshTools::libmesh_assert_valid_constraint_rows(*this);
886 : #endif
887 :
888 : // A distributed mesh may have processors with no elements (or
889 : // processors with no elements of higher dimension, if we ever
890 : // support mixed-dimension meshes), but we want consistent
891 : // mesh_dimension anyways.
892 : //
893 : // cache_elem_data() should get the elem_dimensions() and
894 : // mesh_dimension() correct later, and we don't need it earlier.
895 :
896 :
897 : // Renumber the nodes and elements so that they in contiguous
898 : // blocks. By default, _skip_renumber_nodes_and_elements is false.
899 : //
900 : // Instances where you if prepare_for_use() should not renumber the nodes
901 : // and elements include reading in e.g. an xda/r or gmv file. In
902 : // this case, the ordering of the nodes may depend on an accompanying
903 : // solution, and the node ordering cannot be changed.
904 :
905 :
906 : // Mesh modification operations might not leave us with consistent
907 : // id counts, or might leave us with orphaned nodes we're no longer
908 : // using, but our partitioner might need that consistency and/or
909 : // might be confused by orphaned nodes.
910 438708 : if (!_skip_renumber_nodes_and_elements)
911 : {
912 393989 : if (!_preparation.has_removed_orphaned_nodes ||
913 639 : !_preparation.has_synched_id_counts)
914 393350 : this->renumber_nodes_and_elements();
915 : }
916 : else
917 : {
918 44719 : if (!_preparation.has_removed_orphaned_nodes)
919 42305 : this->remove_orphaned_nodes();
920 44719 : if (!_preparation.has_synched_id_counts)
921 42305 : this->update_parallel_id_counts();
922 : }
923 :
924 : // Let all the elements find their neighbors
925 438708 : if (!_skip_find_neighbors && !_preparation.has_neighbor_ptrs)
926 424119 : this->find_neighbors();
927 :
928 : // The user may have set boundary conditions. We require that the
929 : // boundary conditions were set consistently. Because we examine
930 : // neighbors when evaluating non-raw boundary condition IDs, this
931 : // assert is only valid when our neighbor links are in place.
932 : #ifdef DEBUG
933 13116 : MeshTools::libmesh_assert_valid_boundary_ids(*this);
934 : #endif
935 :
936 : // Search the mesh for all the dimensions of the elements
937 : // and cache them.
938 438708 : if (!_preparation.has_cached_elem_data)
939 435868 : this->cache_elem_data();
940 :
941 : // Search the mesh for elements that have a neighboring element
942 : // of dim+1 and set that element as the interior parent
943 438708 : if (!_preparation.has_interior_parent_ptrs)
944 : {
945 435442 : if (!_skip_detect_interior_parents)
946 435442 : this->detect_interior_parents();
947 : else
948 : {
949 : // We must set the flag that says "interior parent pointers have been set up"
950 : // even though we skip detect_interior_parents().
951 0 : _preparation.has_interior_parent_ptrs = true;
952 : }
953 : }
954 :
955 : // Fix up node unique ids in case mesh generation code didn't take
956 : // exceptional care to do so.
957 : // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
958 :
959 : // We're going to still require that mesh generation code gets
960 : // element unique ids consistent.
961 : #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
962 13116 : MeshTools::libmesh_assert_valid_unique_ids(*this);
963 : #endif
964 :
965 : // Allow our GhostingFunctor objects to reinit if necessary.
966 : // Do this before partitioning and redistributing, and before
967 : // deleting remote elements.
968 438708 : if (!_preparation.has_reinit_ghosting_functors)
969 435655 : this->reinit_ghosting_functors();
970 :
971 : // Partition the mesh unless *all* partitioning is to be skipped.
972 : // If only noncritical partitioning is to be skipped, the
973 : // partition() call will still check for orphaned nodes.
974 438708 : if (!skip_partitioning() && !_preparation.is_partitioned)
975 12914 : this->partition();
976 13232 : else if (!this->n_unpartitioned_elem() &&
977 202 : !this->n_unpartitioned_nodes())
978 6616 : _preparation.is_partitioned = true;
979 :
980 : // If we're using DistributedMesh, we'll probably want it
981 : // parallelized.
982 438708 : if (this->_allow_remote_element_removal &&
983 426624 : !_preparation.has_removed_remote_elements)
984 381291 : this->delete_remote_elements();
985 : else
986 57417 : _preparation.has_removed_remote_elements = true;
987 :
988 : // Much of our boundary info may have been for now-remote parts of the mesh,
989 : // in which case we don't want to keep local copies of data meant to be
990 : // local. On the other hand we may have deleted, or the user may have added in
991 : // a distributed fashion, boundary data that is meant to be global. So we
992 : // handle both of those scenarios here
993 438708 : if (!_preparation.has_boundary_id_sets)
994 89504 : this->get_boundary_info().regenerate_id_sets();
995 :
996 438708 : if (!_skip_renumber_nodes_and_elements)
997 393989 : this->renumber_nodes_and_elements();
998 :
999 : // The mesh is now prepared for use, with the possible exception of
1000 : // partitioning that was supposed to be skipped, and it should know
1001 : // it.
1002 : #ifndef NDEBUG
1003 13116 : Preparation completed_preparation = _preparation;
1004 13116 : if (skip_partitioning())
1005 184 : completed_preparation.is_partitioned = true;
1006 13116 : libmesh_assert(completed_preparation);
1007 : #endif
1008 :
1009 : #ifdef DEBUG
1010 13116 : MeshTools::libmesh_assert_valid_boundary_ids(*this);
1011 : #ifdef LIBMESH_ENABLE_UNIQUE_ID
1012 13116 : MeshTools::libmesh_assert_valid_unique_ids(*this);
1013 : #endif
1014 : #endif
1015 438708 : }
1016 :
1017 : void
1018 435655 : MeshBase::reinit_ghosting_functors()
1019 : {
1020 981460 : for (auto & gf : _ghosting_functors)
1021 : {
1022 16574 : libmesh_assert(gf);
1023 545805 : gf->mesh_reinit();
1024 : }
1025 :
1026 435655 : _preparation.has_reinit_ghosting_functors = true;
1027 435655 : }
1028 :
1029 1017203 : void MeshBase::clear ()
1030 : {
1031 : // Reset the number of partitions
1032 1017203 : _n_parts = 1;
1033 :
1034 : // Reset the preparation flags
1035 1017203 : _preparation = false;
1036 :
1037 : // Clear boundary information
1038 1017203 : if (boundary_info)
1039 1015925 : boundary_info->clear();
1040 :
1041 : // Clear cached element data
1042 30399 : _elem_dims.clear();
1043 30399 : _elem_default_orders.clear();
1044 1017203 : _supported_nodal_order = MAXIMUM;
1045 :
1046 30399 : _elemset_codes.clear();
1047 30399 : _elemset_codes_inverse_map.clear();
1048 :
1049 30399 : _constraint_rows.clear();
1050 :
1051 : // Clear our point locator.
1052 1017203 : this->clear_point_locator();
1053 1017203 : this->clear_stored_ranges();
1054 1017203 : }
1055 :
1056 :
1057 89630 : bool MeshBase::is_prepared() const
1058 : {
1059 89630 : return static_cast<bool>(_preparation);
1060 : }
1061 :
1062 :
1063 2059 : void MeshBase::unset_is_prepared()
1064 : {
1065 2059 : _preparation = false;
1066 2059 : this->clear_point_locator();
1067 2059 : this->clear_stored_ranges();
1068 2059 : }
1069 :
1070 :
1071 1004841 : void MeshBase::add_ghosting_functor(GhostingFunctor & ghosting_functor)
1072 : {
1073 : // We used to implicitly support duplicate inserts to std::set
1074 : #ifdef LIBMESH_ENABLE_DEPRECATED
1075 : _ghosting_functors.erase
1076 947485 : (std::remove(_ghosting_functors.begin(),
1077 : _ghosting_functors.end(),
1078 1004841 : &ghosting_functor),
1079 86034 : _ghosting_functors.end());
1080 : #endif
1081 :
1082 : // We shouldn't have two copies of the same functor
1083 28678 : libmesh_assert(std::find(_ghosting_functors.begin(),
1084 : _ghosting_functors.end(),
1085 : &ghosting_functor) ==
1086 : _ghosting_functors.end());
1087 :
1088 1004841 : _ghosting_functors.push_back(&ghosting_functor);
1089 1004841 : }
1090 :
1091 :
1092 :
1093 974299 : void MeshBase::remove_ghosting_functor(GhostingFunctor & ghosting_functor)
1094 : {
1095 918967 : auto raw_it = std::find(_ghosting_functors.begin(),
1096 1001965 : _ghosting_functors.end(), &ghosting_functor);
1097 :
1098 : // The DofMap has a "to_mesh" parameter that tells it to avoid
1099 : // registering a new functor with the mesh, but it doesn't keep
1100 : // track of which functors weren't added, so we'll support "remove a
1101 : // functor that isn't there" just like we did with set::erase
1102 : // before.
1103 974299 : if (raw_it != _ghosting_functors.end())
1104 973376 : _ghosting_functors.erase(raw_it);
1105 :
1106 : // We shouldn't have had two copies of the same functor
1107 27666 : libmesh_assert(std::find(_ghosting_functors.begin(),
1108 : _ghosting_functors.end(),
1109 : &ghosting_functor) ==
1110 : _ghosting_functors.end());
1111 :
1112 974299 : if (const auto it = _shared_functors.find(&ghosting_functor);
1113 27666 : it != _shared_functors.end())
1114 69 : _shared_functors.erase(it);
1115 974299 : }
1116 :
1117 :
1118 :
1119 27995 : void MeshBase::subdomain_ids (std::set<subdomain_id_type> & ids, const bool global /* = true */) const
1120 : {
1121 : // This requires an inspection on every processor
1122 1298 : if (global)
1123 1298 : parallel_object_only();
1124 :
1125 34 : struct SBDInserter {
1126 : std::set<subdomain_id_type> my_ids;
1127 :
1128 1298 : SBDInserter () {}
1129 36 : SBDInserter (SBDInserter &, Threads::split) {}
1130 :
1131 28101 : void operator()(const ConstElemRange & range) {
1132 2218422 : for (const Elem * elem : range)
1133 2190321 : my_ids.insert(elem->subdomain_id());
1134 28101 : }
1135 :
1136 36 : void join(SBDInserter & other) {
1137 36 : my_ids.merge(other.my_ids);
1138 36 : }
1139 : };
1140 :
1141 2596 : SBDInserter inserter;
1142 27995 : Threads::parallel_reduce(this->active_local_element_stored_range(), inserter);
1143 :
1144 1298 : ids.swap(inserter.my_ids);
1145 :
1146 27995 : if (global)
1147 : {
1148 : // Only include the unpartitioned elements if the user requests the global IDs.
1149 : // In the case of the local subdomain IDs, it doesn't make sense to include the
1150 : // unpartitioned elements because said elements do not have a sense of locality.
1151 58166 : for (const auto & elem : this->active_unpartitioned_element_ptr_range())
1152 28873 : ids.insert(elem->subdomain_id());
1153 :
1154 : // Some subdomains may only live on other processors
1155 27995 : this->comm().set_union(ids);
1156 : }
1157 27995 : }
1158 :
1159 :
1160 :
1161 632832 : void MeshBase::redistribute()
1162 : {
1163 : // We now have all elements and nodes redistributed; our ghosting
1164 : // functors should be ready to redistribute and/or recompute any
1165 : // cached data they use too.
1166 636016 : for (auto & gf : as_range(this->ghosting_functors_begin(),
1167 1432147 : this->ghosting_functors_end()))
1168 770455 : gf->redistribute();
1169 632832 : }
1170 :
1171 :
1172 :
1173 535041 : void MeshBase::update_post_partitioning()
1174 : {
1175 : // A range over all elements might still be fine here, but any range
1176 : // over local elements is obsolete if our partitioner changed the
1177 : // definition of "local".
1178 9766 : _const_active_local_element_stored_range.reset(nullptr);
1179 535041 : }
1180 :
1181 :
1182 :
1183 21170 : subdomain_id_type MeshBase::n_subdomains() const
1184 : {
1185 : // This requires an inspection on every processor
1186 596 : parallel_object_only();
1187 :
1188 1192 : std::set<subdomain_id_type> ids;
1189 :
1190 21170 : this->subdomain_ids (ids);
1191 :
1192 21766 : return cast_int<subdomain_id_type>(ids.size());
1193 : }
1194 :
1195 :
1196 :
1197 0 : subdomain_id_type MeshBase::n_local_subdomains() const
1198 : {
1199 0 : std::set<subdomain_id_type> ids;
1200 :
1201 0 : this->subdomain_ids (ids, /* global = */ false);
1202 :
1203 0 : return cast_int<subdomain_id_type>(ids.size());
1204 : }
1205 :
1206 :
1207 :
1208 :
1209 3459992 : dof_id_type MeshBase::n_nodes_on_proc (const processor_id_type proc_id) const
1210 : {
1211 : // We're either counting a processor's nodes or unpartitioned
1212 : // nodes
1213 5758 : libmesh_assert (proc_id < this->n_processors() ||
1214 : proc_id == DofObject::invalid_processor_id);
1215 :
1216 6914226 : return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
1217 10374218 : this->pid_nodes_end (proc_id)));
1218 : }
1219 :
1220 :
1221 :
1222 3891556 : dof_id_type MeshBase::n_elem_on_proc (const processor_id_type proc_id) const
1223 : {
1224 : // We're either counting a processor's elements or unpartitioned
1225 : // elements
1226 18682 : libmesh_assert (proc_id < this->n_processors() ||
1227 : proc_id == DofObject::invalid_processor_id);
1228 :
1229 7764430 : return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
1230 11655986 : this->pid_elements_end (proc_id)));
1231 : }
1232 :
1233 :
1234 :
1235 1296807 : dof_id_type MeshBase::n_active_elem_on_proc (const processor_id_type proc_id) const
1236 : {
1237 2164 : libmesh_assert_less (proc_id, this->n_processors());
1238 2591450 : return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
1239 3888257 : this->active_pid_elements_end (proc_id)));
1240 : }
1241 :
1242 :
1243 :
1244 0 : dof_id_type MeshBase::n_sub_elem () const
1245 : {
1246 0 : dof_id_type ne=0;
1247 :
1248 0 : for (const auto & elem : this->element_ptr_range())
1249 0 : ne += elem->n_sub_elem();
1250 :
1251 0 : return ne;
1252 : }
1253 :
1254 :
1255 :
1256 32266 : dof_id_type MeshBase::n_active_sub_elem () const
1257 : {
1258 1575 : dof_id_type ne=0;
1259 :
1260 25301373 : for (const auto & elem : this->active_element_ptr_range())
1261 25267532 : ne += elem->n_sub_elem();
1262 :
1263 32266 : return ne;
1264 : }
1265 :
1266 :
1267 :
1268 14995 : std::string MeshBase::get_info(const unsigned int verbosity /* = 0 */, const bool global /* = true */) const
1269 : {
1270 15835 : std::ostringstream oss;
1271 :
1272 14995 : oss << " Mesh Information:" << '\n';
1273 :
1274 14995 : if (!_elem_dims.empty())
1275 : {
1276 14995 : oss << " elem_dimensions()={";
1277 14995 : std::copy(_elem_dims.begin(),
1278 420 : --_elem_dims.end(), // --end() is valid if the set is non-empty
1279 14575 : std::ostream_iterator<unsigned int>(oss, ", "));
1280 14995 : oss << cast_int<unsigned int>(*_elem_dims.rbegin());
1281 14995 : oss << "}\n";
1282 : }
1283 :
1284 14995 : if (!_elem_default_orders.empty())
1285 : {
1286 14995 : oss << " elem_default_orders()={";
1287 14995 : std::transform(_elem_default_orders.begin(),
1288 420 : --_elem_default_orders.end(),
1289 14995 : std::ostream_iterator<std::string>(oss, ", "),
1290 8 : [](Order o)
1291 276 : { return Utility::enum_to_string<Order>(o); });
1292 14995 : oss << Utility::enum_to_string<Order>(*_elem_default_orders.rbegin());
1293 14995 : oss << "}\n";
1294 : }
1295 :
1296 14995 : oss << " supported_nodal_order()=" << this->supported_nodal_order() << '\n'
1297 15835 : << " spatial_dimension()=" << this->spatial_dimension() << '\n'
1298 15415 : << " n_nodes()=" << this->n_nodes() << '\n'
1299 14995 : << " n_local_nodes()=" << this->n_local_nodes() << '\n'
1300 15415 : << " n_elem()=" << this->n_elem() << '\n'
1301 29570 : << " n_local_elem()=" << this->n_local_elem() << '\n';
1302 : #ifdef LIBMESH_ENABLE_AMR
1303 29150 : oss << " n_active_elem()=" << this->n_active_elem() << '\n';
1304 : #endif
1305 14995 : if (global)
1306 15415 : oss << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n';
1307 : else
1308 0 : oss << " n_local_subdomains()= " << static_cast<std::size_t>(this->n_local_subdomains()) << '\n';
1309 15415 : oss << " n_elemsets()=" << static_cast<std::size_t>(this->n_elemsets()) << '\n';
1310 14995 : if (!_elemset_codes.empty())
1311 0 : oss << " n_elemset_codes=" << _elemset_codes.size() << '\n';
1312 14995 : oss << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
1313 15835 : << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
1314 15415 : << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
1315 15835 : << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n'
1316 15415 : << " is_prepared()=" << (this->is_prepared() ? "true" : "false") << '\n'
1317 43089 : << " is_replicated()=" << (this->is_replicated() ? "true" : "false") << '\n';
1318 :
1319 14995 : if (verbosity > 0)
1320 : {
1321 284 : if (global)
1322 : {
1323 8 : libmesh_parallel_only(this->comm());
1324 292 : if (this->processor_id() != 0)
1325 236 : oss << "\n Detailed global get_info() (verbosity > 0) is reduced and output to only rank 0.";
1326 : }
1327 :
1328 : // Helper for printing element types
1329 672 : const auto elem_type_helper = [](const std::set<int> & elem_types) {
1330 784 : std::stringstream ss;
1331 1344 : for (auto it = elem_types.begin(); it != elem_types.end();)
1332 : {
1333 1288 : ss << Utility::enum_to_string((ElemType)*it);
1334 672 : if (++it != elem_types.end())
1335 0 : ss << ", ";
1336 : }
1337 728 : return ss.str();
1338 560 : };
1339 :
1340 : // Helper for whether or not the given DofObject is to be included. If we're doing
1341 : // a global reduction, we also count unpartitioned objects on rank 0.
1342 871156 : const auto include_object = [this, &global](const DofObject & dof_object) {
1343 978188 : return this->processor_id() == dof_object.processor_id() ||
1344 250756 : (global &&
1345 42324 : this->processor_id() == 0 &&
1346 846328 : dof_object.processor_id() == DofObject::invalid_processor_id);
1347 276 : };
1348 :
1349 8 : Real volume = 0;
1350 :
1351 : // Add bounding box information
1352 284 : const auto bbox = global ? MeshTools::create_bounding_box(*this) : MeshTools::create_local_bounding_box(*this);
1353 284 : if (!global || this->processor_id() == 0)
1354 : oss << "\n " << (global ? "" : "Local ") << "Mesh Bounding Box:\n"
1355 48 : << " Minimum: " << bbox.min() << "\n"
1356 44 : << " Maximum: " << bbox.max() << "\n"
1357 88 : << " Delta: " << (bbox.max() - bbox.min()) << "\n";
1358 :
1359 : // Obtain the global or local element types
1360 16 : std::set<int> elem_types;
1361 49712 : for (const Elem * elem : this->active_local_element_ptr_range())
1362 49420 : elem_types.insert(elem->type());
1363 284 : if (global)
1364 : {
1365 : // Pick up unpartitioned elems on rank 0
1366 292 : if (this->processor_id() == 0)
1367 92 : for (const Elem * elem : this->active_unpartitioned_element_ptr_range())
1368 40 : elem_types.insert(elem->type());
1369 :
1370 284 : this->comm().set_union(elem_types);
1371 : }
1372 :
1373 : // Add element types
1374 284 : if (!global || this->processor_id() == 0)
1375 : oss << "\n " << (global ? "" : "Local ") << "Mesh Element Type(s):\n "
1376 140 : << elem_type_helper(elem_types) << "\n";
1377 :
1378 : // Reduce the nodeset ids
1379 16 : auto nodeset_ids = this->get_boundary_info().get_node_boundary_ids();
1380 284 : if (global)
1381 284 : this->comm().set_union(nodeset_ids);
1382 :
1383 : // Accumulate local information for each nodeset
1384 1608 : struct NodesetInfo
1385 : {
1386 : std::size_t num_nodes = 0;
1387 : BoundingBox bbox;
1388 : };
1389 16 : std::map<boundary_id_type, NodesetInfo> nodeset_info_map;
1390 91376 : for (const auto & [node, id] : this->get_boundary_info().get_nodeset_map())
1391 : {
1392 91092 : if (!include_object(*node))
1393 38364 : continue;
1394 :
1395 48672 : NodesetInfo & info = nodeset_info_map[id];
1396 :
1397 48672 : ++info.num_nodes;
1398 :
1399 48672 : if (verbosity > 1)
1400 48672 : info.bbox.union_with(*node);
1401 : }
1402 :
1403 : // Add nodeset info
1404 284 : if (!global || this->processor_id() == 0)
1405 : {
1406 48 : oss << "\n " << (global ? "" : "Local ") << "Mesh Nodesets:\n";
1407 48 : if (nodeset_ids.empty())
1408 0 : oss << " None\n";
1409 : }
1410 :
1411 8 : const auto & nodeset_name_map = this->get_boundary_info().get_nodeset_name_map();
1412 1988 : for (const auto id : nodeset_ids)
1413 : {
1414 1704 : NodesetInfo & info = nodeset_info_map[id];
1415 :
1416 : // Reduce the local information for this nodeset if required
1417 1704 : if (global)
1418 : {
1419 1704 : this->comm().sum(info.num_nodes);
1420 1704 : if (verbosity > 1)
1421 : {
1422 1752 : this->comm().min(info.bbox.min());
1423 1752 : this->comm().max(info.bbox.max());
1424 : }
1425 : }
1426 :
1427 1704 : const bool has_name = nodeset_name_map.count(id) && nodeset_name_map.at(id).size();
1428 1800 : const std::string name = has_name ? nodeset_name_map.at(id) : "";
1429 96 : if (global)
1430 48 : libmesh_assert(this->comm().verify(name));
1431 :
1432 1704 : if (global ? this->processor_id() == 0 : info.num_nodes > 0)
1433 : {
1434 288 : oss << " Nodeset " << id;
1435 288 : if (has_name)
1436 528 : oss << " (" << name << ")";
1437 312 : oss << ", " << info.num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1438 :
1439 288 : if (verbosity > 1)
1440 : {
1441 288 : oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1442 288 : << info.bbox.min() << "\n"
1443 288 : << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1444 288 : << info.bbox.max() << "\n"
1445 288 : << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1446 288 : << (info.bbox.max() - info.bbox.min()) << "\n";
1447 : }
1448 : }
1449 : }
1450 :
1451 : // Reduce the sideset ids
1452 16 : auto sideset_ids = this->get_boundary_info().get_side_boundary_ids();
1453 284 : if (global)
1454 284 : this->comm().set_union(sideset_ids);
1455 :
1456 : // Accumulate local information for each sideset
1457 : struct SidesetInfo
1458 : {
1459 : std::size_t num_sides = 0;
1460 : Real volume = 0;
1461 : std::set<int> side_elem_types;
1462 : std::set<int> elem_types;
1463 : std::set<dof_id_type> elem_ids;
1464 : std::set<dof_id_type> node_ids;
1465 : BoundingBox bbox;
1466 : };
1467 16 : ElemSideBuilder side_builder;
1468 16 : std::map<boundary_id_type, SidesetInfo> sideset_info_map;
1469 70396 : for (const auto & pair : this->get_boundary_info().get_sideset_map())
1470 : {
1471 70112 : const Elem * elem = pair.first;
1472 63456 : if (!include_object(*elem))
1473 30176 : continue;
1474 :
1475 39936 : const auto id = pair.second.second;
1476 39936 : SidesetInfo & info = sideset_info_map[id];
1477 :
1478 39936 : const auto s = pair.second.first;
1479 39936 : const Elem & side = side_builder(*elem, s);
1480 :
1481 39936 : ++info.num_sides;
1482 39936 : info.side_elem_types.insert(side.type());
1483 39936 : info.elem_types.insert(elem->type());
1484 39936 : info.elem_ids.insert(elem->id());
1485 :
1486 199680 : for (const Node & node : side.node_ref_range())
1487 146432 : if (include_object(node))
1488 147552 : info.node_ids.insert(node.id());
1489 :
1490 39936 : if (verbosity > 1)
1491 : {
1492 39936 : info.volume += side.volume();
1493 39936 : info.bbox.union_with(side.loose_bounding_box());
1494 : }
1495 : }
1496 :
1497 : // Add sideset info
1498 284 : if (!global || this->processor_id() == 0)
1499 : {
1500 48 : oss << "\n " << (global ? "" : "Local ") << "Mesh Sidesets:\n";
1501 48 : if (sideset_ids.empty())
1502 0 : oss << " None\n";
1503 : }
1504 8 : const auto & sideset_name_map = this->get_boundary_info().get_sideset_name_map();
1505 1988 : for (const auto id : sideset_ids)
1506 : {
1507 1704 : SidesetInfo & info = sideset_info_map[id];
1508 :
1509 1704 : auto num_elems = info.elem_ids.size();
1510 1704 : auto num_nodes = info.node_ids.size();
1511 :
1512 : // Reduce the local information for this sideset if required
1513 1704 : if (global)
1514 : {
1515 1704 : this->comm().sum(info.num_sides);
1516 1704 : this->comm().set_union(info.side_elem_types, 0);
1517 1704 : this->comm().sum(num_elems);
1518 1704 : this->comm().set_union(info.elem_types, 0);
1519 1704 : this->comm().sum(num_nodes);
1520 1704 : if (verbosity > 1)
1521 : {
1522 1704 : this->comm().sum(info.volume);
1523 1752 : this->comm().min(info.bbox.min());
1524 1752 : this->comm().max(info.bbox.max());
1525 : }
1526 : }
1527 :
1528 1704 : const bool has_name = sideset_name_map.count(id) && sideset_name_map.at(id).size();
1529 1800 : const std::string name = has_name ? sideset_name_map.at(id) : "";
1530 96 : if (global)
1531 48 : libmesh_assert(this->comm().verify(name));
1532 :
1533 1704 : if (global ? this->processor_id() == 0 : info.num_sides > 0)
1534 : {
1535 288 : oss << " Sideset " << id;
1536 288 : if (has_name)
1537 528 : oss << " (" << name << ")";
1538 552 : oss << ", " << info.num_sides << " sides (" << elem_type_helper(info.side_elem_types) << ")"
1539 1056 : << ", " << num_elems << " " << (global ? "" : "local ") << "elems (" << elem_type_helper(info.elem_types) << ")"
1540 600 : << ", " << num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1541 :
1542 288 : if (verbosity > 1)
1543 : {
1544 312 : oss << " " << (global ? "Side" : "Local side") << " volume: " << info.volume << "\n"
1545 288 : << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1546 288 : << info.bbox.min() << "\n"
1547 288 : << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1548 288 : << info.bbox.max() << "\n"
1549 288 : << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1550 288 : << (info.bbox.max() - info.bbox.min()) << "\n";
1551 : }
1552 : }
1553 : }
1554 :
1555 : // Reduce the edgeset ids
1556 16 : auto edgeset_ids = this->get_boundary_info().get_edge_boundary_ids();
1557 284 : if (global)
1558 284 : this->comm().set_union(edgeset_ids);
1559 :
1560 : // Accumulate local information for each edgeset
1561 0 : struct EdgesetInfo
1562 : {
1563 : std::size_t num_edges = 0;
1564 : std::set<int> edge_elem_types;
1565 : BoundingBox bbox;
1566 : };
1567 16 : std::map<boundary_id_type, EdgesetInfo> edgeset_info_map;
1568 284 : std::unique_ptr<const Elem> edge;
1569 :
1570 284 : for (const auto & pair : this->get_boundary_info().get_edgeset_map())
1571 : {
1572 0 : const Elem * elem = pair.first;
1573 0 : if (!include_object(*elem))
1574 0 : continue;
1575 :
1576 0 : const auto id = pair.second.second;
1577 0 : EdgesetInfo & info = edgeset_info_map[id];
1578 :
1579 0 : elem->build_edge_ptr(edge, pair.second.first);
1580 :
1581 0 : ++info.num_edges;
1582 0 : info.edge_elem_types.insert(edge->type());
1583 :
1584 0 : if (verbosity > 1)
1585 0 : info.bbox.union_with(edge->loose_bounding_box());
1586 : }
1587 :
1588 : // Add edgeset info
1589 284 : if (!global || this->processor_id() == 0)
1590 : {
1591 48 : oss << "\n " << (global ? "" : "Local ") << "Mesh Edgesets:\n";
1592 48 : if (edgeset_ids.empty())
1593 48 : oss << " None\n";
1594 : }
1595 :
1596 8 : const auto & edgeset_name_map = this->get_boundary_info().get_edgeset_name_map();
1597 284 : for (const auto id : edgeset_ids)
1598 : {
1599 0 : EdgesetInfo & info = edgeset_info_map[id];
1600 :
1601 : // Reduce the local information for this edgeset if required
1602 0 : if (global)
1603 : {
1604 0 : this->comm().sum(info.num_edges);
1605 0 : this->comm().set_union(info.edge_elem_types, 0);
1606 0 : if (verbosity > 1)
1607 : {
1608 0 : this->comm().min(info.bbox.min());
1609 0 : this->comm().min(info.bbox.max());
1610 : }
1611 : }
1612 :
1613 0 : const bool has_name = edgeset_name_map.count(id) && edgeset_name_map.at(id).size();
1614 0 : const std::string name = has_name ? edgeset_name_map.at(id) : "";
1615 0 : if (global)
1616 0 : libmesh_assert(this->comm().verify(name));
1617 :
1618 0 : if (global ? this->processor_id() == 0 : info.num_edges > 0)
1619 : {
1620 0 : oss << " Edgeset " << id;
1621 0 : if (has_name)
1622 0 : oss << " (" << name << ")";
1623 0 : oss << ", " << info.num_edges << " " << (global ? "" : "local ") << "edges ("
1624 0 : << elem_type_helper(info.edge_elem_types) << ")\n";
1625 :
1626 0 : if (verbosity > 1)
1627 : {
1628 0 : oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1629 0 : << info.bbox.min() << "\n"
1630 0 : << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1631 0 : << info.bbox.max() << "\n"
1632 0 : << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1633 0 : << (info.bbox.max() - info.bbox.min()) << "\n";
1634 : }
1635 : }
1636 : }
1637 :
1638 : // Reduce the block IDs and block names
1639 16 : std::set<subdomain_id_type> subdomains;
1640 194032 : for (const Elem * elem : this->active_element_ptr_range())
1641 92640 : if (include_object(*elem))
1642 49420 : subdomains.insert(elem->subdomain_id());
1643 284 : if (global)
1644 284 : this->comm().set_union(subdomains);
1645 :
1646 : // Accumulate local information for each subdomain
1647 0 : struct SubdomainInfo
1648 : {
1649 : std::size_t num_elems = 0;
1650 : Real volume = 0;
1651 : std::set<int> elem_types;
1652 : std::set<dof_id_type> active_node_ids;
1653 : #ifdef LIBMESH_ENABLE_AMR
1654 : std::size_t num_active_elems = 0;
1655 : #endif
1656 : BoundingBox bbox;
1657 : };
1658 16 : std::map<subdomain_id_type, SubdomainInfo> subdomain_info_map;
1659 194032 : for (const Elem * elem : this->element_ptr_range())
1660 92640 : if (include_object(*elem))
1661 : {
1662 49152 : SubdomainInfo & info = subdomain_info_map[elem->subdomain_id()];
1663 :
1664 49152 : ++info.num_elems;
1665 49152 : info.elem_types.insert(elem->type());
1666 :
1667 : #ifdef LIBMESH_ENABLE_AMR
1668 4096 : if (elem->active())
1669 49152 : ++info.num_active_elems;
1670 : #endif
1671 :
1672 442368 : for (const Node & node : elem->node_ref_range())
1673 392704 : if (include_object(node) && node.active())
1674 330608 : info.active_node_ids.insert(node.id());
1675 :
1676 49152 : if (verbosity > 1 && elem->active())
1677 : {
1678 49152 : info.volume += elem->volume();
1679 49152 : info.bbox.union_with(elem->loose_bounding_box());
1680 : }
1681 268 : }
1682 :
1683 : // Add subdomain info
1684 284 : oss << "\n " << (global ? "" : "Local ") << "Mesh Subdomains:\n";
1685 8 : const auto & subdomain_name_map = this->get_subdomain_name_map();
1686 568 : for (const auto id : subdomains)
1687 : {
1688 284 : SubdomainInfo & info = subdomain_info_map[id];
1689 :
1690 284 : auto num_active_nodes = info.active_node_ids.size();
1691 :
1692 : // Reduce the information for this subdomain if needed
1693 284 : if (global)
1694 : {
1695 284 : this->comm().sum(info.num_elems);
1696 : #ifdef LIBMESH_ENABLE_AMR
1697 284 : this->comm().sum(info.num_active_elems);
1698 : #endif
1699 284 : this->comm().sum(num_active_nodes);
1700 284 : this->comm().set_union(info.elem_types, 0);
1701 284 : if (verbosity > 1)
1702 : {
1703 292 : this->comm().min(info.bbox.min());
1704 292 : this->comm().max(info.bbox.max());
1705 284 : this->comm().sum(info.volume);
1706 : }
1707 : }
1708 284 : if (verbosity > 1)
1709 284 : volume += info.volume;
1710 :
1711 8 : const bool has_name = subdomain_name_map.count(id);
1712 292 : const std::string name = has_name ? subdomain_name_map.at(id) : "";
1713 16 : if (global)
1714 8 : libmesh_assert(this->comm().verify(name));
1715 :
1716 284 : if (!global || this->processor_id() == 0)
1717 : {
1718 48 : oss << " Subdomain " << id;
1719 48 : if (has_name)
1720 0 : oss << " (" << name << ")";
1721 48 : oss << ": " << info.num_elems << " " << (global ? "" : "local ") << "elems "
1722 56 : << "(" << elem_type_helper(info.elem_types);
1723 : #ifdef LIBMESH_ENABLE_AMR
1724 48 : oss << ", " << info.num_active_elems << " active";
1725 : #endif
1726 52 : oss << "), " << num_active_nodes << " " << (global ? "" : "local ") << "active nodes\n";
1727 48 : if (verbosity > 1)
1728 : {
1729 52 : oss << " " << (global ? "Volume" : "Local volume") << ": " << info.volume << "\n";
1730 48 : oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1731 48 : << info.bbox.min() << "\n"
1732 48 : << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1733 48 : << info.bbox.max() << "\n"
1734 48 : << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1735 48 : << (info.bbox.max() - info.bbox.min()) << "\n";
1736 : }
1737 : }
1738 : }
1739 :
1740 560 : oss << " " << (global ? "Global" : "Local") << " mesh volume = " << volume << "\n";
1741 :
1742 268 : }
1743 :
1744 15415 : return oss.str();
1745 14155 : }
1746 :
1747 :
1748 14995 : void MeshBase::print_info(std::ostream & os, const unsigned int verbosity /* = 0 */, const bool global /* = true */) const
1749 : {
1750 15415 : os << this->get_info(verbosity, global)
1751 420 : << std::endl;
1752 14995 : }
1753 :
1754 :
1755 0 : std::ostream & operator << (std::ostream & os, const MeshBase & m)
1756 : {
1757 0 : m.print_info(os);
1758 0 : return os;
1759 : }
1760 :
1761 :
1762 432944 : void MeshBase::partition (const unsigned int n_parts)
1763 : {
1764 : // If we get here and we have unpartitioned elements, we need that
1765 : // fixed.
1766 432944 : if (this->n_unpartitioned_elem() > 0)
1767 : {
1768 9410 : libmesh_assert (partitioner().get());
1769 9410 : libmesh_assert (this->is_serial());
1770 315616 : partitioner()->partition (*this, n_parts);
1771 : }
1772 : // A nullptr partitioner or a skip_partitioning(true) call or a
1773 : // skip_noncritical_partitioning(true) call means don't repartition;
1774 : // skip_noncritical_partitioning() checks all these.
1775 3528 : else if (!skip_noncritical_partitioning())
1776 : {
1777 110599 : partitioner()->partition (*this, n_parts);
1778 : }
1779 : else
1780 : {
1781 : // Adaptive coarsening may have "orphaned" nodes on processors
1782 : // whose elements no longer share them. We need to check for
1783 : // and possibly fix that.
1784 6729 : MeshTools::correct_node_proc_ids(*this);
1785 :
1786 : // Make sure locally cached partition count is correct
1787 6729 : this->recalculate_n_partitions();
1788 :
1789 : // Make sure any other locally cached data is correct
1790 6729 : this->update_post_partitioning();
1791 : }
1792 :
1793 432944 : _preparation.is_partitioned = true;
1794 432944 : }
1795 :
1796 18649 : void MeshBase::all_second_order (const bool full_ordered)
1797 : {
1798 18649 : this->all_second_order_range(this->element_ptr_range(), full_ordered);
1799 18649 : }
1800 :
1801 14971 : void MeshBase::all_complete_order ()
1802 : {
1803 14971 : this->all_complete_order_range(this->element_ptr_range());
1804 14971 : }
1805 :
1806 6729 : unsigned int MeshBase::recalculate_n_partitions()
1807 : {
1808 : // This requires an inspection on every processor
1809 170 : parallel_object_only();
1810 :
1811 6729 : unsigned int max_proc_id=0;
1812 :
1813 225762 : for (const auto & elem : this->active_local_element_ptr_range())
1814 223045 : max_proc_id = std::max(max_proc_id, static_cast<unsigned int>(elem->processor_id()));
1815 :
1816 : // The number of partitions is one more than the max processor ID.
1817 6729 : _n_parts = max_proc_id+1;
1818 :
1819 6729 : this->comm().max(_n_parts);
1820 :
1821 6729 : return _n_parts;
1822 : }
1823 :
1824 :
1825 :
1826 555104 : std::unique_ptr<PointLocatorBase> MeshBase::sub_point_locator () const
1827 : {
1828 : // If there's no master point locator, then we need one.
1829 555104 : if (_point_locator.get() == nullptr)
1830 : {
1831 : // PointLocator construction may not be safe within threads
1832 760 : libmesh_assert(!Threads::in_threads);
1833 :
1834 : // And it may require parallel communication
1835 760 : parallel_object_only();
1836 :
1837 : #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1838 : _point_locator = PointLocatorBase::build(NANOFLANN, *this);
1839 : #else
1840 43522 : _point_locator = PointLocatorBase::build(TREE_ELEMENTS, *this);
1841 : #endif
1842 :
1843 22521 : if (_point_locator_close_to_point_tol > 0.)
1844 0 : _point_locator->set_close_to_point_tol(_point_locator_close_to_point_tol);
1845 : }
1846 :
1847 : // Otherwise there was a master point locator, and we can grab a
1848 : // sub-locator easily.
1849 : return
1850 : #ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1851 : PointLocatorBase::build(NANOFLANN, *this, _point_locator.get());
1852 : #else
1853 555104 : PointLocatorBase::build(TREE_ELEMENTS, *this, _point_locator.get());
1854 : #endif
1855 : }
1856 :
1857 :
1858 :
1859 108655665 : void MeshBase::clear_point_locator ()
1860 : {
1861 1565035 : _point_locator.reset(nullptr);
1862 108655665 : }
1863 :
1864 :
1865 :
1866 0 : void MeshBase::set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems)
1867 : {
1868 0 : _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
1869 0 : }
1870 :
1871 :
1872 :
1873 6658441 : bool MeshBase::get_count_lower_dim_elems_in_point_locator() const
1874 : {
1875 6658441 : return _count_lower_dim_elems_in_point_locator;
1876 : }
1877 :
1878 :
1879 :
1880 1063271 : std::string & MeshBase::subdomain_name(subdomain_id_type id)
1881 : {
1882 1063271 : return _block_id_to_name[id];
1883 : }
1884 :
1885 44105 : const std::string & MeshBase::subdomain_name(subdomain_id_type id) const
1886 : {
1887 : // An empty string to return when no matching subdomain name is found
1888 44105 : static const std::string empty;
1889 :
1890 44105 : if (const auto iter = _block_id_to_name.find(id);
1891 1623 : iter == _block_id_to_name.end())
1892 1417 : return empty;
1893 : else
1894 2476 : return iter->second;
1895 : }
1896 :
1897 0 : void MeshBase::set_subdomain_name(const subdomain_id_type id,
1898 : const std::string & name,
1899 : const bool synchronous)
1900 : {
1901 0 : if (synchronous)
1902 0 : parallel_object_only();
1903 0 : _block_id_to_name[id] = name;
1904 0 : }
1905 :
1906 :
1907 0 : subdomain_id_type MeshBase::get_id_by_name(std::string_view name) const
1908 : {
1909 : // Linear search over the map values.
1910 0 : for (const auto & [sbd_id, sbd_name] : _block_id_to_name)
1911 0 : if (sbd_name == name)
1912 0 : return sbd_id;
1913 :
1914 : // If we made it here without returning, we don't have a subdomain
1915 : // with the requested name, so return Elem::invalid_subdomain_id.
1916 0 : return Elem::invalid_subdomain_id;
1917 : }
1918 :
1919 :
1920 1670846 : const ElemRange & MeshBase::element_stored_range()
1921 : {
1922 1670846 : if (!_element_stored_range)
1923 : {
1924 : // Range construction may not be safe within threads
1925 13986 : libmesh_assert(!Threads::in_threads);
1926 :
1927 : _element_stored_range =
1928 2040754 : std::make_unique<ElemRange>(this->elements_begin(),
1929 1393126 : this->elements_end());
1930 : }
1931 :
1932 1670846 : return *_element_stored_range;
1933 : }
1934 :
1935 569658 : const ConstElemRange & MeshBase::active_local_element_stored_range() const
1936 : {
1937 569658 : if (!_const_active_local_element_stored_range)
1938 : {
1939 : // Range construction may not be safe within threads
1940 1754 : libmesh_assert(!Threads::in_threads);
1941 :
1942 : _const_active_local_element_stored_range =
1943 905633 : std::make_unique<ConstElemRange>(this->active_local_elements_begin(),
1944 607848 : this->active_local_elements_end());
1945 : }
1946 :
1947 569658 : return *_const_active_local_element_stored_range;
1948 : }
1949 :
1950 110905979 : void MeshBase::clear_stored_ranges()
1951 : {
1952 1561419 : _element_stored_range.reset(nullptr);
1953 1561419 : _const_active_local_element_stored_range.reset(nullptr);
1954 110905979 : }
1955 :
1956 :
1957 : #ifdef LIBMESH_ENABLE_DEPRECATED
1958 0 : void MeshBase::cache_elem_dims()
1959 : {
1960 : libmesh_deprecated();
1961 :
1962 0 : this->cache_elem_data();
1963 0 : }
1964 : #endif // LIBMESH_ENABLE_DEPRECATED
1965 :
1966 501049 : void MeshBase::cache_elem_data()
1967 : {
1968 : // This requires an inspection on every processor
1969 15110 : parallel_object_only();
1970 :
1971 : // Need to clear containers first in case all elements of a
1972 : // particular dimension/order/subdomain have been deleted.
1973 30204 : _elem_dims.clear();
1974 30204 : _elem_default_orders.clear();
1975 30204 : _mesh_subdomains.clear();
1976 501049 : _supported_nodal_order = MAXIMUM;
1977 :
1978 34595137 : for (const auto & elem : this->active_element_ptr_range())
1979 : {
1980 33608149 : _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
1981 33608149 : _elem_default_orders.insert(elem->default_order());
1982 33608149 : _mesh_subdomains.insert(elem->subdomain_id());
1983 33608149 : _supported_nodal_order =
1984 33608149 : static_cast<Order>
1985 67216298 : (std::min(static_cast<int>(_supported_nodal_order),
1986 34064725 : static_cast<int>(elem->supported_nodal_order())));
1987 470845 : }
1988 :
1989 501049 : if (!this->is_serial())
1990 : {
1991 : // Some different dimension/order/subdomain elements may only live
1992 : // on other processors
1993 123802 : this->comm().set_union(_elem_dims);
1994 123802 : this->comm().set_union(_elem_default_orders);
1995 123802 : this->comm().min(_supported_nodal_order);
1996 123802 : this->comm().set_union(_mesh_subdomains);
1997 : }
1998 :
1999 : // If the largest element dimension found is larger than the current
2000 : // _spatial_dimension, increase _spatial_dimension.
2001 501049 : unsigned int max_dim = this->mesh_dimension();
2002 501049 : if (max_dim > _spatial_dimension)
2003 43291 : _spatial_dimension = cast_int<unsigned char>(max_dim);
2004 :
2005 : // _spatial_dimension may need to increase from 1->2 or 2->3 if the
2006 : // mesh is full of 1D elements but they are not x-aligned, or the
2007 : // mesh is full of 2D elements but they are not in the x-y plane.
2008 : // If the mesh is x-aligned or x-y planar, we will end up checking
2009 : // every node's coordinates and not breaking out of the loop
2010 : // early...
2011 501049 : if (_spatial_dimension < LIBMESH_DIM)
2012 : {
2013 49262934 : for (const auto & node : this->node_ptr_range())
2014 : {
2015 : // Note: the exact floating point comparison is intentional,
2016 : // we don't want to get tripped up by tolerances.
2017 25482023 : if ((*node)(0) != 0. && _spatial_dimension < 1)
2018 0 : _spatial_dimension = 1;
2019 :
2020 25482023 : if ((*node)(1) != 0. && _spatial_dimension < 2)
2021 : {
2022 2501 : _spatial_dimension = 2;
2023 : #if LIBMESH_DIM == 2
2024 : // If libmesh is compiled in 2D mode, this is the
2025 : // largest spatial dimension possible so we can break
2026 : // out.
2027 : break;
2028 : #endif
2029 : }
2030 :
2031 : #if LIBMESH_DIM > 2
2032 25482023 : if ((*node)(2) != 0.)
2033 : {
2034 : // Spatial dimension can't get any higher than this, so
2035 : // we can break out.
2036 8187 : _spatial_dimension = 3;
2037 8187 : break;
2038 : }
2039 : #endif
2040 255131 : }
2041 : }
2042 :
2043 501049 : _preparation.has_cached_elem_data = true;
2044 501049 : }
2045 :
2046 :
2047 49940 : void MeshBase::sync_subdomain_name_map()
2048 : {
2049 : // This requires every processor
2050 1628 : parallel_object_only();
2051 :
2052 49940 : this->comm().set_union(_block_id_to_name);
2053 49940 : }
2054 :
2055 :
2056 435442 : void MeshBase::detect_interior_parents()
2057 : {
2058 13024 : LOG_SCOPE("detect_interior_parents()", "MeshBase");
2059 :
2060 : // This requires an inspection on every processor
2061 13024 : parallel_object_only();
2062 :
2063 : // This requires up-to-date mesh dimensions in cache
2064 13024 : libmesh_assert(_preparation.has_cached_elem_data);
2065 :
2066 : // Early return if the mesh is empty or has elements of a single spatial dimension.
2067 435442 : if (this->elem_dimensions().size() <= 1)
2068 : {
2069 428757 : _preparation.has_interior_parent_ptrs = true;
2070 429974 : return;
2071 : }
2072 :
2073 : // Convenient elem_dimensions iterators
2074 6497 : const auto dim_start = this->elem_dimensions().begin();
2075 188 : const auto dim_end = this->elem_dimensions().end();
2076 :
2077 : // In this function we find only +1 dimensional interior parents,
2078 : // (so, for a given element el, the interior parent p must satisfy p.dim() == el.dim() + 1).
2079 : // Therefore, we can avoid checking the existence of interior parents
2080 : // for all those elements el such there there is no p with p.dim() == el.dim() + 1.
2081 : // We store whether to skip any given dimension in the construction of interior parents
2082 : // inside the vector in dimensions_to_skip_for_interior_parents.
2083 6685 : std::vector<bool> skip_dimension_for_interior_parents(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2084 6497 : skip_dimension_for_interior_parents.back() = true;
2085 :
2086 : // Moreover, in the following, we will build a node-to-elem map.
2087 : // It is among the elems of this map that we will look for interior parents.
2088 : // Therefore, we can skip all elems p such that there is no el with el.dim() == p.dim() - 1.
2089 : // We store whether to skip any given dimension in the construction of the node-to-elem map
2090 : // in the vector skip_dimensions_for_node_to_el_map.
2091 6685 : std::vector<bool> skip_dimensions_for_node_to_el_map(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2092 6685 : skip_dimensions_for_node_to_el_map[*dim_start] = true;
2093 :
2094 : // We also create a flag to know if all dimensions should be skipped,
2095 : // and if we should therefore return early.
2096 188 : bool skip_all_dimensions = true;
2097 :
2098 : // Fill dimensions_to_skip_for_interior_parents and dimensions_to_skip_for_node_to_el_map.
2099 6877 : for (auto [it, next] = std::make_tuple(dim_start, std::next(dim_start));
2100 13704 : next != dim_end; ++it, ++next)
2101 : {
2102 6827 : if (*it + 1 != *next) // if sequential dimensions differ by exactly 1
2103 : {
2104 80 : skip_dimension_for_interior_parents[*it] = true;
2105 1431 : skip_dimensions_for_node_to_el_map[*next] = true;
2106 : }
2107 5548 : else if (!skip_dimension_for_interior_parents[*it])
2108 152 : skip_all_dimensions = false;
2109 : }
2110 :
2111 : // There is nothing to do if all dimensions should be
2112 : // skipped. Before returning, we must also set the flag that says
2113 : // "interior parent pointers have been set up" even though we
2114 : // determined there was no work to be done.
2115 6685 : if (skip_all_dimensions)
2116 : {
2117 1289 : _preparation.has_interior_parent_ptrs = true;
2118 36 : return;
2119 : }
2120 :
2121 : // Do we have interior parent pointers going to a different mesh?
2122 : // If so then we'll still check to make sure that's the only place
2123 : // they go, so we can libmesh_not_implemented() if not.
2124 304 : const bool separate_interior_mesh = (&(this->interior_mesh()) != this);
2125 :
2126 : // This map will be used to set interior parents
2127 152 : std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
2128 :
2129 303450 : for (const auto & elem : this->element_ptr_range())
2130 : {
2131 : // Ignore element if it cannot be interior parent of any other elem.
2132 154551 : if (skip_dimensions_for_node_to_el_map[elem->dim()])
2133 64974 : continue;
2134 :
2135 : // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
2136 495939 : for (auto n : make_range(elem->n_vertices()))
2137 : {
2138 24992 : libmesh_assert_less (elem->id(), this->max_elem_id());
2139 :
2140 433656 : node_to_elem[elem->node_id(n)].push_back(elem->id());
2141 : }
2142 5092 : }
2143 :
2144 : // Automatically set interior parents
2145 303450 : for (const auto & element : this->element_ptr_range())
2146 : {
2147 : // Ignore elements with dimensions to skip
2148 : // or elements that already have an interior parent.
2149 154551 : if (skip_dimension_for_interior_parents[element->dim()] || element->interior_parent())
2150 32778 : continue;
2151 :
2152 : // Start by generating sets of dim+1 dimensional elements that
2153 : // touch each vertex of the current element. If we encounter a
2154 : // vertex not connected to _any_ dim+1 dimensional elements,
2155 : // then we can exit the loop without checking the remaining
2156 : // vertices since an interior parent (if it exists) will be
2157 : // connected to all vertices of the current element.
2158 135413 : std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
2159 :
2160 6820 : bool found_interior_parents = true;
2161 :
2162 124968 : for (auto n : make_range(element->n_vertices()))
2163 : {
2164 130856 : auto it = node_to_elem.find(element->node_id(n));
2165 :
2166 : // Check at first that this node is not isolated.
2167 123974 : if (it == node_to_elem.end())
2168 : {
2169 1472 : found_interior_parents = false;
2170 6792 : break; // out of n-loop
2171 : }
2172 :
2173 356987 : for (const auto & vertex_neighbor_id : it->second)
2174 285119 : if (this->elem_ref(vertex_neighbor_id).dim() == element->dim()+1)
2175 8733 : neighbors[n].insert(vertex_neighbor_id);
2176 :
2177 77278 : if (neighbors[n].empty())
2178 : {
2179 : // We have found an empty set for one vertex, no reason
2180 : // to continue.
2181 5320 : found_interior_parents = false;
2182 5320 : break; // out of n-loop
2183 : }
2184 : }
2185 :
2186 : // If we have generated a non-empty set of elements for each
2187 : // vertex, we will now look for a vertex_neighbor_id that
2188 : // appears in _all_ of those sets. If found, this is our interior
2189 : // parent id. If multiple such common ids are found, we will
2190 : // take the lowest such id to be the interior parent id.
2191 6820 : if (found_interior_parents)
2192 : {
2193 56 : std::set<dof_id_type> & neighbors_0 = neighbors[0];
2194 1633 : for (const auto & interior_parent_id : neighbors_0)
2195 : {
2196 40 : found_interior_parents = false;
2197 2627 : for (auto n : make_range(1u, element->n_vertices()))
2198 : {
2199 1633 : if (neighbors[n].count(interior_parent_id))
2200 : {
2201 34 : found_interior_parents = true;
2202 : }
2203 : else
2204 : {
2205 12 : found_interior_parents = false;
2206 12 : break;
2207 : }
2208 : }
2209 :
2210 1420 : if (found_interior_parents)
2211 : {
2212 781 : element->set_interior_parent(this->elem_ptr(interior_parent_id));
2213 22 : break;
2214 : }
2215 : }
2216 :
2217 : // Do we have a mixed dimensional mesh that contains some of
2218 : // its own interior parents, but we already expect to have
2219 : // interior parents on a different mesh? That's going to
2220 : // take some work to support if anyone needs it.
2221 994 : if (separate_interior_mesh)
2222 0 : libmesh_not_implemented_msg
2223 : ("interior_parent() values in multiple meshes are unsupported.");
2224 : }
2225 113225 : }
2226 :
2227 : // This flag doesn't necessarily mean any Elems actually have
2228 : // interior parent pointers, just that we did all the work to
2229 : // determine whether or not they do.
2230 5396 : _preparation.has_interior_parent_ptrs = true;
2231 : }
2232 :
2233 :
2234 :
2235 : #ifdef LIBMESH_ENABLE_PERIODIC
2236 : /**
2237 : * Register a pair of boundaries as disjoint neighbor boundary pairs.
2238 : */
2239 994 : void MeshBase::add_disjoint_neighbor_boundary_pairs(const boundary_id_type b1,
2240 : const boundary_id_type b2,
2241 : const RealVectorValue & translation)
2242 : {
2243 : // Lazily allocate the container the first time it’s needed
2244 994 : if (!_disjoint_neighbor_boundary_pairs)
2245 1496 : _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
2246 :
2247 28 : PeriodicBoundaries & db = *_disjoint_neighbor_boundary_pairs;
2248 :
2249 : // Create forward and inverse boundary mappings
2250 1022 : PeriodicBoundary forward(translation);
2251 994 : PeriodicBoundary inverse(translation * -1.0);
2252 :
2253 994 : forward.myboundary = b1;
2254 994 : forward.pairedboundary = b2;
2255 994 : inverse.myboundary = b2;
2256 994 : inverse.pairedboundary = b1;
2257 :
2258 : // Add both directions into the container
2259 994 : db.emplace(b1, forward.clone());
2260 1022 : db.emplace(b2, inverse.clone());
2261 994 : }
2262 :
2263 565470 : PeriodicBoundaries * MeshBase::get_disjoint_neighbor_boundary_pairs()
2264 : {
2265 565470 : return _disjoint_neighbor_boundary_pairs.get();
2266 : }
2267 :
2268 2683568 : const PeriodicBoundaries * MeshBase::get_disjoint_neighbor_boundary_pairs() const
2269 : {
2270 2683568 : return _disjoint_neighbor_boundary_pairs.get();
2271 : }
2272 :
2273 213 : void MeshBase::remove_disjoint_boundary_pair(const boundary_id_type b1,
2274 : const boundary_id_type b2)
2275 : {
2276 : // Nothing to remove if not allocated or empty
2277 213 : if (!_disjoint_neighbor_boundary_pairs || _disjoint_neighbor_boundary_pairs->empty())
2278 0 : return;
2279 :
2280 6 : auto & pairs = *_disjoint_neighbor_boundary_pairs;
2281 :
2282 : // Helper to check and erase both directions
2283 402 : auto erase_if_match = [](boundary_id_type key,
2284 : boundary_id_type pair,
2285 24 : PeriodicBoundaries & pb_map)
2286 : {
2287 12 : auto it = pb_map.find(key);
2288 426 : if (it != pb_map.end())
2289 : {
2290 12 : const auto & pb = *(it->second);
2291 : // Check both directions
2292 426 : if ((pb.myboundary == key && pb.pairedboundary == pair) ||
2293 0 : (pb.pairedboundary == key && pb.myboundary == pair))
2294 414 : pb_map.erase(it);
2295 : }
2296 426 : };
2297 :
2298 213 : erase_if_match(b1, b2, pairs);
2299 213 : erase_if_match(b2, b1, pairs);
2300 : }
2301 :
2302 :
2303 : #endif
2304 :
2305 :
2306 :
2307 0 : void MeshBase::set_point_locator_close_to_point_tol(Real val)
2308 : {
2309 0 : _point_locator_close_to_point_tol = val;
2310 0 : if (_point_locator)
2311 : {
2312 0 : if (val > 0.)
2313 0 : _point_locator->set_close_to_point_tol(val);
2314 : else
2315 0 : _point_locator->unset_close_to_point_tol();
2316 : }
2317 0 : }
2318 :
2319 :
2320 :
2321 426 : Real MeshBase::get_point_locator_close_to_point_tol() const
2322 : {
2323 426 : return _point_locator_close_to_point_tol;
2324 : }
2325 :
2326 :
2327 :
2328 5335 : void MeshBase::size_elem_extra_integers()
2329 : {
2330 308 : const std::size_t new_size = _elem_integer_names.size();
2331 :
2332 : Threads::parallel_for
2333 5335 : (this->element_stored_range(),
2334 10972 : [new_size, this](const ElemRange & range)
2335 : {
2336 18640 : for (Elem * elem : range)
2337 13305 : elem->add_extra_integers(new_size, this->_elem_integer_default_values);
2338 5181 : });
2339 5335 : }
2340 :
2341 :
2342 :
2343 16602 : void MeshBase::size_node_extra_integers()
2344 : {
2345 966 : const std::size_t new_size = _node_integer_names.size();
2346 417025 : for (auto node : this->node_ptr_range())
2347 216374 : node->add_extra_integers(new_size, _node_integer_default_values);
2348 16602 : }
2349 :
2350 :
2351 : std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
2352 26167 : MeshBase::merge_extra_integer_names(const MeshBase & other)
2353 : {
2354 854 : std::pair<std::vector<unsigned int>, std::vector<unsigned int>> returnval;
2355 26167 : returnval.first = this->add_elem_integers(other._elem_integer_names, true, &other._elem_integer_default_values);
2356 26167 : returnval.second = this->add_node_integers(other._node_integer_names, true, &other._node_integer_default_values);
2357 26167 : return returnval;
2358 : }
2359 :
2360 :
2361 :
2362 : void
2363 426 : MeshBase::post_dofobject_moves(MeshBase && other_mesh)
2364 : {
2365 : // Now that all the DofObject moving is done, we can move the GhostingFunctor objects
2366 : // which include the _default_ghosting,_ghosting_functors and _shared_functors. We also need
2367 : // to set the mesh object associated with these functors to the assignee mesh.
2368 :
2369 : // _default_ghosting
2370 12 : _default_ghosting = std::move(other_mesh._default_ghosting);
2371 426 : _default_ghosting->set_mesh(this);
2372 :
2373 : // _ghosting_functors
2374 426 : _ghosting_functors = std::move(other_mesh._ghosting_functors);
2375 :
2376 852 : for (const auto gf : _ghosting_functors )
2377 : {
2378 426 : gf->set_mesh(this);
2379 : }
2380 :
2381 : // _shared_functors
2382 12 : _shared_functors = std::move(other_mesh._shared_functors);
2383 :
2384 426 : for (const auto & sf : _shared_functors )
2385 : {
2386 0 : (sf.second)->set_mesh(this);
2387 : }
2388 :
2389 : // _constraint_rows
2390 12 : _constraint_rows = std::move(other_mesh._constraint_rows);
2391 :
2392 426 : if (other_mesh.partitioner())
2393 426 : _partitioner = std::move(other_mesh.partitioner());
2394 426 : }
2395 :
2396 :
2397 : void
2398 0 : MeshBase::copy_cached_data(const MeshBase & other_mesh)
2399 : {
2400 0 : this->_spatial_dimension = other_mesh._spatial_dimension;
2401 0 : this->_elem_dims = other_mesh._elem_dims;
2402 0 : this->_elem_default_orders = other_mesh._elem_default_orders;
2403 0 : this->_supported_nodal_order = other_mesh._supported_nodal_order;
2404 0 : this->_mesh_subdomains = other_mesh._mesh_subdomains;
2405 0 : }
2406 :
2407 :
2408 14725 : bool MeshBase::nodes_and_elements_equal(const MeshBase & other_mesh) const
2409 : {
2410 2826850 : for (const auto & other_node : other_mesh.node_ptr_range())
2411 : {
2412 1524181 : const Node * node = this->query_node_ptr(other_node->id());
2413 1524181 : if (!node)
2414 0 : return false;
2415 1524181 : if (*other_node != *node)
2416 0 : return false;
2417 13279 : }
2418 2826850 : for (const auto & node : this->node_ptr_range())
2419 1524181 : if (!other_mesh.query_node_ptr(node->id()))
2420 13279 : return false;
2421 :
2422 1253356 : for (const auto & other_elem : other_mesh.element_ptr_range())
2423 : {
2424 789217 : const Elem * elem = this->query_elem_ptr(other_elem->id());
2425 789217 : if (!elem)
2426 0 : return false;
2427 789217 : if (!other_elem->topologically_equal(*elem))
2428 6 : return false;
2429 13279 : }
2430 1253080 : for (const auto & elem : this->element_ptr_range())
2431 789076 : if (!other_mesh.query_elem_ptr(elem->id()))
2432 13150 : return false;
2433 :
2434 14584 : return true;
2435 : }
2436 :
2437 :
2438 764 : dof_id_type MeshBase::n_constraint_rows() const
2439 : {
2440 764 : dof_id_type n_local_rows=0, n_unpartitioned_rows=0;
2441 764 : for (const auto & [node, node_constraints] : _constraint_rows)
2442 : {
2443 : // Unpartitioned nodes
2444 0 : if (node->processor_id() == DofObject::invalid_processor_id)
2445 0 : n_unpartitioned_rows++;
2446 0 : else if (node->processor_id() == this->processor_id())
2447 0 : n_local_rows++;
2448 : }
2449 :
2450 764 : this->comm().sum(n_local_rows);
2451 :
2452 764 : return n_unpartitioned_rows + n_local_rows;
2453 : }
2454 :
2455 :
2456 : void
2457 24392 : MeshBase::copy_constraint_rows(const MeshBase & other_mesh)
2458 : {
2459 1608 : LOG_SCOPE("copy_constraint_rows(mesh)", "MeshBase");
2460 :
2461 1592 : _constraint_rows.clear();
2462 :
2463 804 : const auto & other_constraint_rows = other_mesh.get_constraint_rows();
2464 72820 : for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
2465 : {
2466 48428 : const Node * const our_node = this->node_ptr(other_node->id());
2467 6416 : constraint_rows_mapped_type our_node_constraints;
2468 219637 : for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
2469 : {
2470 9048 : const auto & [other_elem, local_node_id] = other_inner_key_pair;
2471 171209 : const Elem * const our_elem = this->elem_ptr(other_elem->id());
2472 171209 : our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
2473 : }
2474 48428 : _constraint_rows[our_node] = std::move(our_node_constraints);
2475 : }
2476 24392 : }
2477 :
2478 :
2479 : template <typename T>
2480 : void
2481 565 : MeshBase::copy_constraint_rows(const SparseMatrix<T> & constraint_operator,
2482 : bool precondition_constraint_operator)
2483 : {
2484 32 : LOG_SCOPE("copy_constraint_rows(mat)", "MeshBase");
2485 :
2486 16 : this->_constraint_rows.clear();
2487 :
2488 : // We're not going to support doing this distributed yet; it'd be
2489 : // pointless unless we temporarily had a linear partitioning to
2490 : // better match the constraint operator.
2491 597 : MeshSerializer serialize(*this);
2492 :
2493 : // Our current mesh should already reflect the desired assembly space
2494 565 : libmesh_error_msg_if(this->n_nodes() != constraint_operator.m(),
2495 : "Constraint operator matrix with " <<
2496 : constraint_operator.m() <<
2497 : "rows does not match this mesh with " <<
2498 : this->n_nodes() << " nodes");
2499 :
2500 : // First, find what new unconstrained DoFs we need to add. We can't
2501 : // iterate over columns in a SparseMatrix, so we'll iterate over
2502 : // rows and keep track of columns.
2503 :
2504 : // If we have nodes that will work unconstrained, keep track of
2505 : // their node ids and corresponding column indices.
2506 : // existing_unconstrained_nodes[column_id] = node_id
2507 32 : std::map<dof_id_type, dof_id_type> existing_unconstrained_columns;
2508 32 : std::set<dof_id_type> existing_unconstrained_nodes;
2509 :
2510 : // In case we need new nodes, keep track of their columns.
2511 : // columns[j][k] will be the kth row index and value of column j
2512 : typedef
2513 : std::unordered_map<dof_id_type,
2514 : std::vector<std::pair<dof_id_type, Real>>>
2515 : columns_type;
2516 1114 : columns_type columns(constraint_operator.n());
2517 :
2518 : // If we need to precondition the constraint operator (e.g. it's an
2519 : // unpreconditioned extraction operator for a Flex IGA matrix),
2520 : // we'll want to keep track of the sum of each column, because we'll
2521 : // be dividing each column by that sum (Jacobi preconditioning on
2522 : // the right, which then leads to symmetric preconditioning on a
2523 : // physics Jacobian).
2524 32 : std::unordered_map<dof_id_type, Real> column_sums;
2525 :
2526 : // Work in parallel, though we'll have to sync shortly
2527 4028 : for (auto i : make_range(constraint_operator.row_start(),
2528 533 : constraint_operator.row_stop()))
2529 : {
2530 618 : std::vector<numeric_index_type> indices;
2531 618 : std::vector<T> values;
2532 :
2533 3463 : constraint_operator.get_row(i, indices, values);
2534 309 : libmesh_assert_equal_to(indices.size(), values.size());
2535 :
2536 3847 : if (indices.size() == 1 &&
2537 825 : values[0] == T(1))
2538 : {
2539 : // If we have multiple simple Ui=Uj constraints, let the
2540 : // first one be our "unconstrained" node and let the others
2541 : // be constrained to it.
2542 810 : if (existing_unconstrained_columns.find(indices[0]) !=
2543 138 : existing_unconstrained_columns.end())
2544 : {
2545 36 : const auto j = indices[0];
2546 36 : columns[j].emplace_back(i, 1);
2547 : }
2548 : else
2549 : {
2550 708 : existing_unconstrained_nodes.insert(i);
2551 774 : existing_unconstrained_columns.emplace(indices[0],i);
2552 : }
2553 : }
2554 : else
2555 22028 : for (auto jj : index_range(indices))
2556 : {
2557 19375 : const auto j = indices[jj];
2558 21134 : const Real coef = libmesh_real(values[jj]);
2559 1759 : libmesh_assert_equal_to(coef, values[jj]);
2560 19375 : columns[j].emplace_back(i, coef);
2561 : }
2562 : }
2563 :
2564 : // Merge data from different processors' slabs of the matrix
2565 565 : this->comm().set_union(existing_unconstrained_nodes);
2566 565 : this->comm().set_union(existing_unconstrained_columns);
2567 :
2568 48 : std::vector<columns_type> all_columns;
2569 565 : this->comm().allgather(columns, all_columns);
2570 :
2571 16 : columns.clear();
2572 6106 : for (auto p : index_range(all_columns))
2573 65601 : for (auto & [j, subcol] : all_columns[p])
2574 183429 : for (auto [i, v] : subcol)
2575 123369 : columns[j].emplace_back(i,v);
2576 :
2577 : // Keep track of elements on which unconstrained nodes exist, and
2578 : // their local node indices.
2579 : // node_to_elem_ptrs[node] = [elem_id, local_node_num]
2580 32 : std::unordered_map<const Node *, std::pair<dof_id_type, unsigned int>> node_to_elem_ptrs;
2581 :
2582 : // Find elements attached to any existing nodes that will stay
2583 : // unconstrained. We'll also build a subdomain set here so we don't
2584 : // have to assert that the mesh is already prepared before we pick a
2585 : // new subdomain for any NodeElems we need to add.
2586 32 : std::set<subdomain_id_type> subdomain_ids;
2587 145181 : for (const Elem * elem : this->element_ptr_range())
2588 : {
2589 49738 : subdomain_ids.insert(elem->subdomain_id());
2590 244572 : for (auto n : make_range(elem->n_nodes()))
2591 : {
2592 194834 : const Node * node = elem->node_ptr(n);
2593 194834 : if (existing_unconstrained_nodes.count(node->id()))
2594 12175 : node_to_elem_ptrs.emplace(node, std::make_pair(elem->id(), n));
2595 : }
2596 : }
2597 :
2598 565 : const subdomain_id_type new_sbd_id = *subdomain_ids.rbegin() + 1;
2599 :
2600 23189 : for (auto j : make_range(constraint_operator.n()))
2601 : {
2602 : // If we already have a good node for this then we're done
2603 4800 : if (existing_unconstrained_columns.count(j))
2604 4668 : continue;
2605 :
2606 : // Get a half-decent spot to place a new NodeElem for
2607 : // unconstrained DoF(s) here. Getting a *fully*-decent spot
2608 : // would require finding a Moore-Penrose pseudoinverse, and I'm
2609 : // not going to do that, but scaling a transpose will at least
2610 : // get us a little uniqueness to make visualization reasonable.
2611 264 : Point newpt;
2612 264 : Real total_scaling = 0;
2613 264 : unsigned int total_entries = 0;
2614 :
2615 : // We'll get a decent initial pid choice here too, if only to
2616 : // aid in later repartitioning.
2617 528 : std::map<processor_id_type, int> pids;
2618 :
2619 264 : auto & column = columns[j];
2620 122230 : for (auto [i, r] : column)
2621 : {
2622 112988 : Node & constrained_node = this->node_ref(i);
2623 112988 : const Point constrained_pt = constrained_node;
2624 3228 : newpt += r*constrained_pt;
2625 112988 : total_scaling += r;
2626 112988 : ++total_entries;
2627 112988 : ++pids[constrained_node.processor_id()];
2628 : }
2629 :
2630 9242 : if (precondition_constraint_operator)
2631 0 : column_sums[j] = total_scaling;
2632 :
2633 9242 : libmesh_error_msg_if
2634 : (!total_entries,
2635 : "Empty column " << j <<
2636 : " found in constraint operator matrix");
2637 :
2638 : // If we have *cancellation* here then we can end up dividing by
2639 : // zero; try just evenly scaling across all constrained node
2640 : // points instead.
2641 9242 : if (total_scaling > TOLERANCE)
2642 264 : newpt /= total_scaling;
2643 : else
2644 0 : newpt /= total_entries;
2645 :
2646 9242 : Node *n = this->add_point(newpt);
2647 9506 : std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
2648 9242 : elem->set_node(0, n);
2649 9242 : elem->subdomain_id() = new_sbd_id;
2650 :
2651 9506 : Elem * added_elem = this->add_elem(std::move(elem));
2652 9242 : this->_elem_dims.insert(0);
2653 9242 : this->_elem_default_orders.insert(added_elem->default_order());
2654 9242 : this->_supported_nodal_order =
2655 8714 : static_cast<Order>
2656 18484 : (std::min(static_cast<int>(this->_supported_nodal_order),
2657 9242 : static_cast<int>(added_elem->supported_nodal_order())));
2658 8978 : this->_mesh_subdomains.insert(new_sbd_id);
2659 9242 : node_to_elem_ptrs.emplace(n, std::make_pair(added_elem->id(), 0));
2660 9242 : existing_unconstrained_columns.emplace(j,n->id());
2661 :
2662 : // Repartition the new objects *after* adding them, so a
2663 : // DistributedMesh doesn't get confused and think you're not
2664 : // adding them on all processors at once.
2665 264 : int n_pids = 0;
2666 43912 : for (auto [pid, count] : pids)
2667 34670 : if (count >= n_pids)
2668 : {
2669 324 : n_pids = count;
2670 15469 : added_elem->processor_id() = pid;
2671 15469 : n->processor_id() = pid;
2672 : }
2673 : }
2674 :
2675 : // Calculate constraint rows in an indexed form that's easy for us
2676 : // to allgather
2677 : std::unordered_map<dof_id_type,
2678 : std::vector<std::pair<std::pair<dof_id_type, unsigned int>,Real>>>
2679 32 : indexed_constraint_rows;
2680 :
2681 4028 : for (auto i : make_range(constraint_operator.row_start(),
2682 533 : constraint_operator.row_stop()))
2683 : {
2684 951 : if (existing_unconstrained_nodes.count(i))
2685 774 : continue;
2686 :
2687 486 : std::vector<numeric_index_type> indices;
2688 486 : std::vector<T> values;
2689 :
2690 2689 : constraint_operator.get_row(i, indices, values);
2691 :
2692 486 : std::vector<std::pair<std::pair<dof_id_type, unsigned int>, Real>> constraint_row;
2693 :
2694 22100 : for (auto jj : index_range(indices))
2695 : {
2696 21173 : const dof_id_type node_id =
2697 : existing_unconstrained_columns[indices[jj]];
2698 :
2699 19411 : Node & constraining_node = this->node_ref(node_id);
2700 :
2701 1762 : libmesh_assert(node_to_elem_ptrs.count(&constraining_node));
2702 :
2703 19411 : auto p = node_to_elem_ptrs[&constraining_node];
2704 :
2705 19382 : Real coef = libmesh_real(values[jj]);
2706 1762 : libmesh_assert_equal_to(coef, values[jj]);
2707 :
2708 : // If we're preconditioning and we created a nodeelem then
2709 : // we can scale the meaning of that nodeelem's value to give
2710 : // us a better-conditioned matrix after the constraints are
2711 : // applied.
2712 19411 : if (precondition_constraint_operator)
2713 0 : if (auto sum_it = column_sums.find(indices[jj]);
2714 0 : sum_it != column_sums.end())
2715 : {
2716 0 : const Real scaling = sum_it->second;
2717 :
2718 0 : if (scaling > TOLERANCE)
2719 0 : coef /= scaling;
2720 : }
2721 :
2722 21173 : constraint_row.emplace_back(std::make_pair(p, coef));
2723 : }
2724 :
2725 243 : indexed_constraint_rows.emplace(i, std::move(constraint_row));
2726 : }
2727 :
2728 565 : this->comm().set_union(indexed_constraint_rows);
2729 :
2730 : // Add constraint rows as mesh constraint rows
2731 17591 : for (auto & [node_id, indexed_row] : indexed_constraint_rows)
2732 : {
2733 17026 : Node * constrained_node = this->node_ptr(node_id);
2734 :
2735 972 : constraint_rows_mapped_type constraint_row;
2736 :
2737 140395 : for (auto [p, coef] : indexed_row)
2738 : {
2739 123369 : const Elem * elem = this->elem_ptr(p.first);
2740 7048 : constraint_row.emplace_back
2741 126893 : (std::make_pair(std::make_pair(elem, p.second), coef));
2742 : }
2743 :
2744 16540 : this->_constraint_rows.emplace(constrained_node,
2745 486 : std::move(constraint_row));
2746 : }
2747 1098 : }
2748 :
2749 :
2750 0 : void MeshBase::print_constraint_rows(std::ostream & os,
2751 : bool print_nonlocal) const
2752 : {
2753 0 : parallel_object_only();
2754 :
2755 : std::string local_constraints =
2756 0 : this->get_local_constraints(print_nonlocal);
2757 :
2758 0 : if (this->processor_id())
2759 : {
2760 0 : this->comm().send(0, local_constraints);
2761 : }
2762 : else
2763 : {
2764 0 : os << "Processor 0:\n";
2765 0 : os << local_constraints;
2766 :
2767 0 : for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
2768 : {
2769 0 : this->comm().receive(p, local_constraints);
2770 0 : os << "Processor " << p << ":\n";
2771 0 : os << local_constraints;
2772 : }
2773 : }
2774 0 : }
2775 :
2776 :
2777 :
2778 0 : std::string MeshBase::get_local_constraints(bool print_nonlocal) const
2779 : {
2780 0 : std::ostringstream os;
2781 :
2782 0 : if (print_nonlocal)
2783 0 : os << "All ";
2784 : else
2785 0 : os << "Local ";
2786 :
2787 0 : os << "Mesh Constraint Rows:"
2788 0 : << std::endl;
2789 :
2790 0 : for (const auto & [node, row] : _constraint_rows)
2791 : {
2792 0 : const bool local = (node->processor_id() == this->processor_id());
2793 :
2794 : // Skip non-local dofs if requested
2795 0 : if (!print_nonlocal && !local)
2796 0 : continue;
2797 :
2798 0 : os << "Constraints for " << (local ? "Local" : "Ghost") << " Node " << node->id()
2799 0 : << ": \t";
2800 :
2801 0 : for (const auto & [elem_and_node, coef] : row)
2802 0 : os << " ((" << elem_and_node.first->id() << ',' << elem_and_node.second << "), " << coef << ")\t";
2803 :
2804 0 : os << std::endl;
2805 : }
2806 :
2807 0 : return os.str();
2808 0 : }
2809 :
2810 332756 : MeshBase::Preparation::Preparation() :
2811 313436 : is_partitioned(false),
2812 313436 : has_synched_id_counts(false),
2813 313436 : has_neighbor_ptrs(false),
2814 313436 : has_cached_elem_data(false),
2815 313436 : has_interior_parent_ptrs(false),
2816 313436 : has_removed_remote_elements(false),
2817 313436 : has_removed_orphaned_nodes(false),
2818 313436 : has_boundary_id_sets(false),
2819 332756 : has_reinit_ghosting_functors(false)
2820 332756 : {}
2821 :
2822 102746 : MeshBase::Preparation::operator bool() const
2823 : {
2824 176120 : return is_partitioned &&
2825 73374 : has_synched_id_counts &&
2826 73374 : has_neighbor_ptrs &&
2827 73374 : has_cached_elem_data &&
2828 73374 : has_interior_parent_ptrs &&
2829 73374 : has_removed_remote_elements &&
2830 73374 : has_removed_orphaned_nodes &&
2831 217358 : has_reinit_ghosting_functors &&
2832 115490 : has_boundary_id_sets;
2833 : }
2834 :
2835 : MeshBase::Preparation &
2836 1454704 : MeshBase::Preparation::operator= (bool set_all)
2837 : {
2838 1454704 : is_partitioned = set_all;
2839 1454704 : has_synched_id_counts = set_all;
2840 1454704 : has_neighbor_ptrs = set_all;
2841 1454704 : has_cached_elem_data = set_all;
2842 1454704 : has_interior_parent_ptrs = set_all;
2843 1454704 : has_removed_remote_elements = set_all;
2844 1454704 : has_removed_orphaned_nodes = set_all;
2845 1454704 : has_reinit_ghosting_functors = set_all;
2846 1454704 : has_boundary_id_sets = set_all;
2847 :
2848 1454704 : return *this;
2849 : }
2850 :
2851 : bool
2852 15151 : MeshBase::Preparation::operator== (const Preparation & other) const
2853 : {
2854 15151 : if (is_partitioned != other.is_partitioned)
2855 0 : return false;
2856 15151 : if (has_synched_id_counts != other.has_synched_id_counts)
2857 0 : return false;
2858 15151 : if (has_neighbor_ptrs != other.has_neighbor_ptrs)
2859 0 : return false;
2860 15151 : if (has_cached_elem_data != other.has_cached_elem_data)
2861 0 : return false;
2862 15151 : if (has_interior_parent_ptrs != other.has_interior_parent_ptrs)
2863 0 : return false;
2864 15151 : if (has_removed_remote_elements != other.has_removed_remote_elements)
2865 0 : return false;
2866 15151 : if (has_removed_orphaned_nodes != other.has_removed_orphaned_nodes)
2867 0 : return false;
2868 15151 : if (has_reinit_ghosting_functors != other.has_reinit_ghosting_functors)
2869 0 : return false;
2870 15151 : if (has_boundary_id_sets != other.has_boundary_id_sets)
2871 0 : return false;
2872 :
2873 1062 : return true;
2874 : }
2875 :
2876 : bool
2877 15151 : MeshBase::Preparation::operator!= (const Preparation & other) const
2878 : {
2879 15151 : return !(*this == other);
2880 : }
2881 :
2882 :
2883 : // Explicit instantiations for our template function
2884 : template LIBMESH_EXPORT void
2885 : MeshBase::copy_constraint_rows(const SparseMatrix<Real> & constraint_operator,
2886 : bool precondition_constraint_operator);
2887 :
2888 : #ifdef LIBMESH_USE_COMPLEX_NUMBERS
2889 : template LIBMESH_EXPORT void
2890 : MeshBase::copy_constraint_rows(const SparseMatrix<Complex> & constraint_operator,
2891 : bool precondition_constraint_operator);
2892 : #endif
2893 :
2894 :
2895 : } // namespace libMesh
|