libMesh
Loading...
Searching...
No Matches
mesh_base.C
Go to the documentation of this file.
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
57namespace libMesh
58{
59
60
61
62// ------------------------------------------------------------
63// MeshBase class member functions
65 unsigned char d) :
66 ParallelObject (comm_in),
67 boundary_info (new BoundaryInfo(*this)), // BoundaryInfo has protected ctor, can't use std::make_unique
68 _n_parts (1),
69 _default_mapping_type(LAGRANGE_MAP),
70 _default_mapping_data(0),
71 _preparation (),
72 _element_stored_range (),
73 _const_active_local_element_stored_range (),
74 _point_locator (),
75 _count_lower_dim_elems_in_point_locator(true),
76 _partitioner (),
77#ifdef LIBMESH_ENABLE_UNIQUE_ID
78 _next_unique_id(DofObject::invalid_unique_id),
79#endif
80 _interior_mesh(this),
81 _skip_noncritical_partitioning(false),
82 _skip_all_partitioning(libMesh::on_command_line("--skip-partitioning")),
83 _skip_renumber_nodes_and_elements(false),
84 _skip_find_neighbors(false),
85 _skip_detect_interior_parents(false),
86 _allow_remote_element_removal(true),
87 _allow_node_and_elem_unique_id_overlap(false),
88 _spatial_dimension(d),
89 _default_ghosting(std::make_unique<GhostPointNeighbors>(*this)),
90 _n_constraint_rows(0),
91 _point_locator_close_to_point_tol(0.)
92{
93 _elem_dims.insert(d);
95 libmesh_assert_less_equal (LIBMESH_DIM, 3);
96 libmesh_assert_greater_equal (LIBMESH_DIM, d);
98}
99
100
101
102MeshBase::MeshBase (const MeshBase & other_mesh) :
103 ParallelObject (other_mesh),
104 boundary_info (new BoundaryInfo(*this)), // BoundaryInfo has protected ctor, can't use std::make_unique
105 _n_parts (other_mesh._n_parts),
106 _default_mapping_type(other_mesh._default_mapping_type),
107 _default_mapping_data(other_mesh._default_mapping_data),
108 _preparation (other_mesh._preparation),
109 _element_stored_range (),
110 _const_active_local_element_stored_range (),
111 _point_locator (),
112 _count_lower_dim_elems_in_point_locator(other_mesh._count_lower_dim_elems_in_point_locator),
113 _partitioner (),
114#ifdef LIBMESH_ENABLE_UNIQUE_ID
115 _next_unique_id(other_mesh._next_unique_id),
116#endif
117 // If the other mesh interior_parent pointers just go back to
118 // itself, so should we
119 _interior_mesh((other_mesh._interior_mesh == &other_mesh) ?
120 this : other_mesh._interior_mesh),
121 _skip_noncritical_partitioning(other_mesh._skip_noncritical_partitioning),
122 _skip_all_partitioning(other_mesh._skip_all_partitioning),
123 _skip_renumber_nodes_and_elements(other_mesh._skip_renumber_nodes_and_elements),
124 _skip_find_neighbors(other_mesh._skip_find_neighbors),
125 _skip_detect_interior_parents(other_mesh._skip_detect_interior_parents),
126 _allow_remote_element_removal(other_mesh._allow_remote_element_removal),
127 _allow_node_and_elem_unique_id_overlap(other_mesh._allow_node_and_elem_unique_id_overlap),
128 _elem_dims(other_mesh._elem_dims),
129 _elem_default_orders(other_mesh._elem_default_orders),
130 _supported_nodal_order(other_mesh._supported_nodal_order),
131 _mesh_subdomains(other_mesh._mesh_subdomains),
132 _elemset_codes_inverse_map(other_mesh._elemset_codes_inverse_map),
133 _all_elemset_ids(other_mesh._all_elemset_ids),
134 _spatial_dimension(other_mesh._spatial_dimension),
135 _default_ghosting(std::make_unique<GhostPointNeighbors>(*this)),
136 _n_constraint_rows(0),
137 _point_locator_close_to_point_tol(other_mesh._point_locator_close_to_point_tol)
138{
139 const GhostingFunctor * const other_default_ghosting = other_mesh._default_ghosting.get();
140
141 for (GhostingFunctor * const gf : other_mesh._ghosting_functors)
142 {
143 // If the other mesh is using default ghosting, then we will use our own
144 // default ghosting
145 if (gf == other_default_ghosting)
146 {
147 _ghosting_functors.push_back(_default_ghosting.get());
148 continue;
149 }
150
151 std::shared_ptr<GhostingFunctor> clone_gf = gf->clone();
152 // Some subclasses of GhostingFunctor might not override the
153 // clone function yet. If this is the case, GhostingFunctor will
154 // return nullptr by default. The clone function should be overridden
155 // in all derived classes. This following code ("else") is written
156 // for API upgrade. That will allow users gradually to update their code.
157 // Once the API upgrade is done, we will come back and delete "else."
158 if (clone_gf)
159 {
160 clone_gf->set_mesh(this);
161 add_ghosting_functor(clone_gf);
162 }
163 else
164 {
165 libmesh_deprecated();
167 }
168 }
169
170 if (other_mesh._partitioner.get())
171 _partitioner = other_mesh._partitioner->clone();
172
173#ifdef LIBMESH_ENABLE_PERIODIC
174 // Deep copy of all periodic boundaries
176 {
177 _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
178
179 for (const auto & [id, pb] : *other_mesh._disjoint_neighbor_boundary_pairs)
180 if (pb)
181 (*_disjoint_neighbor_boundary_pairs)[id] = pb->clone();
182 }
183#endif
184
185 // _elemset_codes stores pointers to entries in _elemset_codes_inverse_map,
186 // so it is not possible to simply copy it directly from other_mesh
187 for (const auto & [set, code] : _elemset_codes_inverse_map)
188 _elemset_codes.emplace(code, &set);
189}
190
192{
193 LOG_SCOPE("operator=(&&)", "MeshBase");
194
195 // Move assign as a ParallelObject.
196 this->ParallelObject::operator=(other_mesh);
197
198 _n_parts = other_mesh.n_partitions();
199 _default_mapping_type = other_mesh.default_mapping_type();
200 _default_mapping_data = other_mesh.default_mapping_data();
201 _preparation = other_mesh._preparation;
202 _element_stored_range = std::move(other_mesh._element_stored_range);
203 _const_active_local_element_stored_range = std::move(other_mesh._const_active_local_element_stored_range);
204 _point_locator = std::move(other_mesh._point_locator);
205 _count_lower_dim_elems_in_point_locator = other_mesh.get_count_lower_dim_elems_in_point_locator();
206#ifdef LIBMESH_ENABLE_UNIQUE_ID
207 _next_unique_id = other_mesh.next_unique_id();
208#endif
209 // If the other mesh interior_parent pointers just go back to
210 // itself, so should we
211 _interior_mesh = (other_mesh._interior_mesh == &other_mesh) ?
212 this : other_mesh._interior_mesh;
213 _skip_noncritical_partitioning = other_mesh.skip_noncritical_partitioning();
214 _skip_all_partitioning = other_mesh.skip_partitioning();
215 _skip_renumber_nodes_and_elements = !(other_mesh.allow_renumbering());
216 _skip_find_neighbors = !(other_mesh.allow_find_neighbors());
217 _skip_detect_interior_parents = !(other_mesh.allow_detect_interior_parents());
218 _allow_remote_element_removal = other_mesh.allow_remote_element_removal();
219 _allow_node_and_elem_unique_id_overlap = other_mesh.allow_node_and_elem_unique_id_overlap();
220 _block_id_to_name = std::move(other_mesh._block_id_to_name);
221 _elem_dims = std::move(other_mesh.elem_dimensions());
222 _elem_default_orders = std::move(other_mesh.elem_default_orders());
223 _supported_nodal_order = other_mesh.supported_nodal_order();
224 _mesh_subdomains = other_mesh._mesh_subdomains;
225 _elemset_codes = std::move(other_mesh._elemset_codes);
226 _elemset_codes_inverse_map = std::move(other_mesh._elemset_codes_inverse_map);
227 _all_elemset_ids = std::move(other_mesh._all_elemset_ids);
228 _spatial_dimension = other_mesh.spatial_dimension();
229 _elem_integer_names = std::move(other_mesh._elem_integer_names);
230 _elem_integer_default_values = std::move(other_mesh._elem_integer_default_values);
231 _node_integer_names = std::move(other_mesh._node_integer_names);
232 _node_integer_default_values = std::move(other_mesh._node_integer_default_values);
233 _n_constraint_rows = other_mesh._n_constraint_rows;
234 _point_locator_close_to_point_tol = other_mesh.get_point_locator_close_to_point_tol();
235
236#ifdef LIBMESH_ENABLE_PERIODIC
237 // Deep copy of all periodic boundaries:
238 // We must clone each PeriodicBoundaryBase in the source map,
239 // since unique_ptr cannot be copied and we need independent instances
240 if (other_mesh._disjoint_neighbor_boundary_pairs)
241 {
242 _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
243
244 for (const auto & [id, pb] : *other_mesh._disjoint_neighbor_boundary_pairs)
245 if (pb)
246 (*_disjoint_neighbor_boundary_pairs)[id] = pb->clone();
247 }
248#endif
249
250 // This relies on our subclasses *not* invalidating pointers when we
251 // do their portion of the move assignment later!
252 boundary_info = std::move(other_mesh.boundary_info);
253 boundary_info->set_mesh(*this);
254
255#ifdef DEBUG
256 // Make sure that move assignment worked for pointers
257 for (const auto & [set, code] : _elemset_codes_inverse_map)
258 {
259 auto it = _elemset_codes.find(code);
260 libmesh_assert_msg(it != _elemset_codes.end(),
261 "Elemset code " << code << " not found in _elmset_codes container.");
262 libmesh_assert_equal_to(it->second, &set);
263 }
264#endif
265
266 // We're *not* really done at this point, but we have the problem
267 // that some of our data movement might be expecting subclasses data
268 // movement to happen first. We'll let subclasses handle that by
269 // calling our post_dofobject_moves()
270 return *this;
271}
272
273
274bool MeshBase::operator== (const MeshBase & other_mesh) const
275{
276 LOG_SCOPE("operator==()", "MeshBase");
277
278 bool is_equal = this->locally_equals(other_mesh);
279 this->comm().min(is_equal);
280 return is_equal;
281}
282
283
284bool MeshBase::locally_equals (const MeshBase & other_mesh) const
285{
286 // Check whether (almost) everything in the base is equal
287 //
288 // We don't check _next_unique_id here, because it's expected to
289 // change in a DistributedMesh prepare_for_use(); it's conceptually
290 // "mutable".
291 //
292 // We use separate if statements instead of logical operators here,
293 // to make it easy to see the failing condition when using a
294 // debugger to figure out why a MeshTools::valid_is_prepared(mesh)
295 // is failing.
296 if (_n_parts != other_mesh._n_parts)
297 return false;
299 return false;
301 return false;
302 if (_preparation != other_mesh._preparation)
303 return false;
306 return false;
307
308 // We should either both have our own interior parents or both not;
309 // but if we both don't then we can't really assert anything else
310 // because pointing at the same interior mesh is fair but so is
311 // pointing at two different copies of "the same" interior mesh.
312 if ((_interior_mesh == this) !=
313 (other_mesh._interior_mesh == &other_mesh))
314 return false;
315
317 return false;
319 return false;
321 return false;
323 return false;
325 return false;
327 return false;
329 return false;
330 if (_spatial_dimension != other_mesh._spatial_dimension)
331 return false;
332 if (_n_constraint_rows != other_mesh._n_constraint_rows)
333 return false;
335 return false;
336 if (_block_id_to_name != other_mesh._block_id_to_name)
337 return false;
338 if (_elem_dims != other_mesh._elem_dims)
339 return false;
341 return false;
343 return false;
344 if (_mesh_subdomains != other_mesh._mesh_subdomains)
345 return false;
346 if (_all_elemset_ids != other_mesh._all_elemset_ids)
347 return false;
349 return false;
351 return false;
353 return false;
355 return false;
356 if (static_cast<bool>(_default_ghosting) != static_cast<bool>(other_mesh._default_ghosting))
357 return false;
358 if (static_cast<bool>(_partitioner) != static_cast<bool>(other_mesh._partitioner))
359 return false;
360 if (*boundary_info != *other_mesh.boundary_info)
361 return false;
362
363 // First check whether the "existence" of the two pointers differs (one present, one absent)
364 if (static_cast<bool>(_disjoint_neighbor_boundary_pairs) !=
365 static_cast<bool>(other_mesh._disjoint_neighbor_boundary_pairs))
366 return false;
367 // If both exist, compare the contents (Weak Test: just compare sizes like `_ghosting_functors`)
370 return false;
371
372 const constraint_rows_type & other_rows =
373 other_mesh.get_constraint_rows();
374 for (const auto & [node, row] : this->_constraint_rows)
375 {
376 const dof_id_type node_id = node->id();
377 const Node * other_node = other_mesh.query_node_ptr(node_id);
378 if (!other_node)
379 return false;
380
381 auto it = other_rows.find(other_node);
382 if (it == other_rows.end())
383 return false;
384
385 const auto & other_row = it->second;
386 if (row.size() != other_row.size())
387 return false;
388
389 for (auto i : index_range(row))
390 {
391 const auto & [elem_pair, coef] = row[i];
392 const auto & [other_elem_pair, other_coef] = other_row[i];
393 libmesh_assert(elem_pair.first);
394 libmesh_assert(other_elem_pair.first);
395 if (elem_pair.first->id() !=
396 other_elem_pair.first->id() ||
397 elem_pair.second !=
398 other_elem_pair.second ||
399 coef != other_coef)
400 return false;
401 }
402 }
403
404 for (const auto & [elemset_code, elemset_ptr] : this->_elemset_codes)
405 if (const auto it = other_mesh._elemset_codes.find(elemset_code);
406 it == other_mesh._elemset_codes.end() || *elemset_ptr != *it->second)
407 return false;
408
409 // FIXME: we have no good way to compare ghosting functors, since
410 // they're in a vector of pointers, and we have no way *at all*
411 // to compare ghosting functors, since they don't have operator==
412 // defined and we encourage users to subclass them. We can check if
413 // we have the same number, is all.
414 if (_ghosting_functors.size() !=
415 other_mesh._ghosting_functors.size())
416 return false;
417
418 // Same deal for partitioners. We tested that we both have one or
419 // both don't, but are they equivalent? Let's guess "yes".
420
421 // Now let the subclasses decide whether everything else is equal
422 return this->subclass_locally_equals(other_mesh);
423}
424
425
427{
428 this->MeshBase::clear();
429
430 libmesh_exceptionless_assert (!libMesh::closed());
431}
432
433
434
435unsigned int MeshBase::mesh_dimension() const
436{
437 if (!_elem_dims.empty())
438 return cast_int<unsigned int>(*_elem_dims.rbegin());
439 return 0;
440}
441
442
443
444void MeshBase::set_elem_dimensions(std::set<unsigned char> elem_dims)
445{
446#ifdef DEBUG
447 // In debug mode, we call cache_elem_data() and then make sure
448 // the result actually agrees with what the user specified.
449 parallel_object_only();
450
451 this->cache_elem_data();
452 libmesh_assert_msg(_elem_dims == elem_dims, \
453 "Specified element dimensions does not match true element dimensions!");
454#endif
455
456 _elem_dims = std::move(elem_dims);
457}
458
459
460
462{
463 // Populate inverse map, stealing id_set's resources
464 auto [it1, inserted1] = _elemset_codes_inverse_map.emplace(std::move(id_set), code);
465
466 // Reference to the newly inserted (or previously existing) id_set
467 const auto & inserted_id_set = it1->first;
468
469 // Keep track of all elemset ids ever added for O(1) n_elemsets()
470 // performance. Only need to do this if we didn't know about this
471 // id_set before...
472 if (inserted1)
473 _all_elemset_ids.insert(inserted_id_set.begin(), inserted_id_set.end());
474
475 // Take the address of the newly emplaced set to use in
476 // _elemset_codes, avoid duplicating std::set storage
477 auto [it2, inserted2] = _elemset_codes.emplace(code, &inserted_id_set);
478
479 // Throw an error if this code already exists with a pointer to a
480 // different set of ids.
481 libmesh_error_msg_if(!inserted2 && it2->second != &inserted_id_set,
482 "The elemset code " << code << " already exists with a different id_set.");
483}
484
485
486
487unsigned int MeshBase::n_elemsets() const
488{
489 return _all_elemset_ids.size();
490}
491
492void MeshBase::get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type & id_set_to_fill) const
493{
494 // If we don't recognize this elemset_code, hand back an empty set
495 id_set_to_fill.clear();
496
497 if (const auto it = _elemset_codes.find(elemset_code);
498 it != _elemset_codes.end())
499 id_set_to_fill.insert(it->second->begin(), it->second->end());
500}
501
503{
504 auto it = _elemset_codes_inverse_map.find(id_set);
505 return (it == _elemset_codes_inverse_map.end()) ? DofObject::invalid_id : it->second;
506}
507
508std::vector<dof_id_type> MeshBase::get_elemset_codes() const
509{
510 std::vector<dof_id_type> ret;
511 ret.reserve(_elemset_codes.size());
512 for (const auto & pr : _elemset_codes)
513 ret.push_back(pr.first);
514 return ret;
515}
516
518{
519 // Look up elemset ids for old_code
520 auto it = _elemset_codes.find(old_code);
521
522 // If we don't have the old_code, then do nothing. Alternatively, we
523 // could throw an error since trying to change an elemset code you
524 // don't have could indicate there's a problem...
525 if (it == _elemset_codes.end())
526 return;
527
528 // Make copy of the set of elemset ids. We are not changing these,
529 // only updating the elemset code it corresponds to.
530 elemset_type id_set_copy = *(it->second);
531
532 // Look up the corresponding entry in the inverse map. Note: we want
533 // the iterator because we are going to remove it.
534 auto inverse_it = _elemset_codes_inverse_map.find(id_set_copy);
535 libmesh_error_msg_if(inverse_it == _elemset_codes_inverse_map.end(),
536 "Expected _elemset_codes_inverse_map entry for elemset code " << old_code);
537
538 // Erase entry from inverse map
539 _elemset_codes_inverse_map.erase(inverse_it);
540
541 // Erase entry from forward map
542 _elemset_codes.erase(it);
543
544 // Add new code with original set of ids.
545 this->add_elemset_code(new_code, id_set_copy);
546
547 // We can't update any actual elemset codes if there is no extra integer defined for it.
548 if (!this->has_elem_integer("elemset_code"))
549 return;
550
551 // Get index of elemset_code extra integer
552 unsigned int elemset_index = this->get_elem_integer_index("elemset_code");
553
554 // Loop over all elems and update code
556 (this->element_stored_range(),
557 [elemset_index, old_code, new_code](const ElemRange & range)
558 {
559 for (Elem * elem : range)
560 {
561 dof_id_type elemset_code =
562 elem->get_extra_integer(elemset_index);
563
564 if (elemset_code == old_code)
565 elem->set_extra_integer(elemset_index, new_code);
566 }
567 });
568}
569
571{
572 // Early return if we don't have old_id
573 if (!_all_elemset_ids.count(old_id))
574 return;
575
576 // Throw an error if the new_id is already used
577 libmesh_error_msg_if(_all_elemset_ids.count(new_id),
578 "Cannot change elemset id " << old_id <<
579 " to " << new_id << ", " << new_id << " already exists.");
580
581 // We will build up a new version of the inverse map so we can iterate over
582 // the current one without invalidating anything.
583 std::map<MeshBase::elemset_type, dof_id_type> new_elemset_codes_inverse_map;
584 for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
585 {
586 auto id_set_copy = id_set;
587 if (id_set_copy.count(old_id))
588 {
589 // Remove old_id, insert new_id
590 id_set_copy.erase(old_id);
591 id_set_copy.insert(new_id);
592 }
593
594 // Store in new version of map
595 new_elemset_codes_inverse_map.emplace(id_set_copy, elemset_code);
596 }
597
598 // Swap existing map with newly-built one
599 _elemset_codes_inverse_map.swap(new_elemset_codes_inverse_map);
600
601 // Reconstruct _elemset_codes map
602 _elemset_codes.clear();
603 for (const auto & [id_set, elemset_code] : _elemset_codes_inverse_map)
604 _elemset_codes.emplace(elemset_code, &id_set);
605
606 // Update _all_elemset_ids
607 _all_elemset_ids.erase(old_id);
608 _all_elemset_ids.insert(new_id);
609}
610
611
612
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.
619}
620
621
622
623unsigned int MeshBase::add_elem_integer(std::string name,
624 bool allocate_data,
625 dof_id_type default_value)
626{
627 for (auto i : index_range(_elem_integer_names))
628 if (_elem_integer_names[i] == name)
629 {
630 libmesh_assert_less(i, _elem_integer_default_values.size());
631 _elem_integer_default_values[i] = default_value;
632 return i;
633 }
634
635 libmesh_assert_equal_to(_elem_integer_names.size(),
637 _elem_integer_names.push_back(std::move(name));
638 _elem_integer_default_values.push_back(default_value);
639 if (allocate_data)
641 return _elem_integer_names.size()-1;
642}
643
644
645
646std::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 libmesh_assert(!default_values || default_values->size() == names.size());
651 libmesh_assert_equal_to(_elem_integer_names.size(), _elem_integer_default_values.size());
652
653 std::unordered_map<std::string, std::size_t> name_indices;
654 for (auto i : index_range(_elem_integer_names))
655 name_indices[_elem_integer_names[i]] = i;
656
657 std::vector<unsigned int> returnval(names.size());
658
659 bool added_an_integer = false;
660 for (auto i : index_range(names))
661 {
662 const std::string & name = names[i];
663 if (const auto it = name_indices.find(name);
664 it != name_indices.end())
665 {
666 returnval[i] = it->second;
667 _elem_integer_default_values[it->second] =
668 default_values ? (*default_values)[i] : DofObject::invalid_id;
669 }
670 else
671 {
672 returnval[i] = _elem_integer_names.size();
673 name_indices[name] = returnval[i];
674 _elem_integer_names.push_back(name);
676 (default_values ? (*default_values)[i] : DofObject::invalid_id);
677 added_an_integer = true;
678 }
679 }
680
681 if (allocate_data && added_an_integer)
683
684 return returnval;
685}
686
687
688
689unsigned int MeshBase::get_elem_integer_index(std::string_view name) const
690{
691 for (auto i : index_range(_elem_integer_names))
692 if (_elem_integer_names[i] == name)
693 return i;
694
695 libmesh_error_msg("Unknown elem integer " << name);
697}
698
699
700
701bool MeshBase::has_elem_integer(std::string_view name) const
702{
703 for (auto & entry : _elem_integer_names)
704 if (entry == name)
705 return true;
706
707 return false;
708}
709
710
711
712unsigned int MeshBase::add_node_integer(std::string name,
713 bool allocate_data,
714 dof_id_type default_value)
715{
716 for (auto i : index_range(_node_integer_names))
717 if (_node_integer_names[i] == name)
718 {
719 libmesh_assert_less(i, _node_integer_default_values.size());
720 _node_integer_default_values[i] = default_value;
721 return i;
722 }
723
724 libmesh_assert_equal_to(_node_integer_names.size(),
726 _node_integer_names.push_back(std::move(name));
727 _node_integer_default_values.push_back(default_value);
728 if (allocate_data)
730 return _node_integer_names.size()-1;
731}
732
733
734
735std::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 libmesh_assert(!default_values || default_values->size() == names.size());
740 libmesh_assert_equal_to(_node_integer_names.size(), _node_integer_default_values.size());
741
742 std::unordered_map<std::string, std::size_t> name_indices;
743 for (auto i : index_range(_node_integer_names))
744 name_indices[_node_integer_names[i]] = i;
745
746 std::vector<unsigned int> returnval(names.size());
747
748 bool added_an_integer = false;
749 for (auto i : index_range(names))
750 {
751 const std::string & name = names[i];
752 if (const auto it = name_indices.find(name);
753 it != name_indices.end())
754 {
755 returnval[i] = it->second;
756 _node_integer_default_values[it->second] =
757 default_values ? (*default_values)[i] : DofObject::invalid_id;
758 }
759 else
760 {
761 returnval[i] = _node_integer_names.size();
762 name_indices[name] = returnval[i];
763 _node_integer_names.push_back(name);
765 (default_values ? (*default_values)[i] : DofObject::invalid_id);
766 added_an_integer = true;
767 }
768 }
769
770 if (allocate_data && added_an_integer)
772
773 return returnval;
774}
775
776
777
778unsigned int MeshBase::get_node_integer_index(std::string_view name) const
779{
780 for (auto i : index_range(_node_integer_names))
781 if (_node_integer_names[i] == name)
782 return i;
783
784 libmesh_error_msg("Unknown node integer " << name);
786}
787
788
789
790bool MeshBase::has_node_integer(std::string_view name) const
791{
792 for (auto & entry : _node_integer_names)
793 if (entry == name)
794 return true;
795
796 return false;
797}
798
799
800
802{
803 LOG_SCOPE("remove_orphaned_nodes()", "MeshBase");
804
805 // Will hold the set of nodes that are currently connected to elements
806 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 for (const auto & element : this->element_ptr_range())
811 for (auto & n : element->node_ref_range())
812 connected_nodes.insert(&n);
813
814 for (const auto & node : this->node_ptr_range())
815 if (!connected_nodes.count(node))
816 this->delete_node(node);
817
819}
820
821
822
823#ifdef LIBMESH_ENABLE_DEPRECATED
824void 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 if (skip_renumber_nodes_and_elements)
832 this->allow_renumbering(false);
833
834 // We always accept the user's value for skip_find_neighbors, in contrast to skip_renumber
835 const bool old_allow_find_neighbors = this->allow_find_neighbors();
836 this->allow_find_neighbors(!skip_find_neighbors);
837
838 this->prepare_for_use();
839
840 this->allow_find_neighbors(old_allow_find_neighbors);
841}
842
843void 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 if (skip_renumber_nodes_and_elements)
851 this->allow_renumbering(false);
852
853 this->prepare_for_use();
854}
855#endif // LIBMESH_ENABLE_DEPRECATED
856
857
858
859
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 this->clear_point_locator();
865 this->clear_stored_ranges();
866 _preparation = false;
869
870 this->complete_preparation();
871}
872
873
875{
876 LOG_SCOPE("complete_preparation()", "MeshBase");
877
878 parallel_object_only();
879
880 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
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.
911 {
915 }
916 else
917 {
919 this->remove_orphaned_nodes();
922 }
923
924 // Let all the elements find their neighbors
926 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
934#endif
935
936 // Search the mesh for all the dimensions of the elements
937 // and cache them.
939 this->cache_elem_data();
940
941 // libMesh expects every processor to know about every subdomain
942 // name, but distributed mesh generators may only have set names for
943 // the part of the mesh they know about, so make sure the map is
944 // consistent everywhere.
947
948 // Search the mesh for elements that have a neighboring element
949 // of dim+1 and set that element as the interior parent
951 {
954 else
955 {
956 // We must set the flag that says "interior parent pointers have been set up"
957 // even though we skip detect_interior_parents().
959 }
960 }
961
962 // Fix up node unique ids in case mesh generation code didn't take
963 // exceptional care to do so.
964 // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
965
966 // We're going to still require that mesh generation code gets
967 // element unique ids consistent.
968#if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
970#endif
971
972 // Allow our GhostingFunctor objects to reinit if necessary.
973 // Do this before partitioning and redistributing, and before
974 // deleting remote elements.
977
978 // Partition the mesh unless *all* partitioning is to be skipped.
979 // If only noncritical partitioning is to be skipped, the
980 // partition() call will still check for orphaned nodes.
982 this->partition();
983 else if (!this->n_unpartitioned_elem() &&
984 !this->n_unpartitioned_nodes())
986
987 // If we're using DistributedMesh, we'll probably want it
988 // parallelized.
992 else
994
995 // Much of our boundary info may have been for now-remote parts of the mesh,
996 // in which case we don't want to keep local copies of data meant to be
997 // local. On the other hand we may have deleted, or the user may have added in
998 // a distributed fashion, boundary data that is meant to be global. So we
999 // handle both of those scenarios here
1002
1005
1006 // The mesh is now prepared for use, with the possible exception of
1007 // partitioning that was supposed to be skipped, and it should know
1008 // it.
1009#ifndef NDEBUG
1010 Preparation completed_preparation = _preparation;
1011 if (skip_partitioning())
1012 completed_preparation.is_partitioned = true;
1013 libmesh_assert(completed_preparation);
1014#endif
1015
1016#ifdef DEBUG
1018#ifdef LIBMESH_ENABLE_UNIQUE_ID
1020#endif
1021#endif
1022}
1023
1024void
1026{
1027 for (auto & gf : _ghosting_functors)
1028 {
1029 libmesh_assert(gf);
1030 gf->mesh_reinit();
1031 }
1032
1034}
1035
1037{
1038 // Reset the number of partitions
1039 _n_parts = 1;
1040
1041 // Reset the preparation flags
1042 _preparation = false;
1043
1044 // Clear boundary information
1045 if (boundary_info)
1046 boundary_info->clear();
1047
1048 // Clear cached element data
1049 _elem_dims.clear();
1050 _elem_default_orders.clear();
1052
1053 _elemset_codes.clear();
1055
1056 _constraint_rows.clear();
1058
1059 // Clear our point locator.
1060 this->clear_point_locator();
1061 this->clear_stored_ranges();
1062}
1063
1064
1066{
1067 return static_cast<bool>(_preparation);
1068}
1069
1070
1072{
1073 _preparation = false;
1074 this->clear_point_locator();
1075 this->clear_stored_ranges();
1076}
1077
1078
1080{
1081 // We used to implicitly support duplicate inserts to std::set
1082#ifdef LIBMESH_ENABLE_DEPRECATED
1083 _ghosting_functors.erase
1084 (std::remove(_ghosting_functors.begin(),
1085 _ghosting_functors.end(),
1086 &ghosting_functor),
1087 _ghosting_functors.end());
1088#endif
1089
1090 // We shouldn't have two copies of the same functor
1091 libmesh_assert(std::find(_ghosting_functors.begin(),
1092 _ghosting_functors.end(),
1093 &ghosting_functor) ==
1094 _ghosting_functors.end());
1095
1096 _ghosting_functors.push_back(&ghosting_functor);
1097}
1098
1099
1100
1102{
1103 auto raw_it = std::find(_ghosting_functors.begin(),
1104 _ghosting_functors.end(), &ghosting_functor);
1105
1106 // The DofMap has a "to_mesh" parameter that tells it to avoid
1107 // registering a new functor with the mesh, but it doesn't keep
1108 // track of which functors weren't added, so we'll support "remove a
1109 // functor that isn't there" just like we did with set::erase
1110 // before.
1111 if (raw_it != _ghosting_functors.end())
1112 _ghosting_functors.erase(raw_it);
1113
1114 // We shouldn't have had two copies of the same functor
1115 libmesh_assert(std::find(_ghosting_functors.begin(),
1116 _ghosting_functors.end(),
1117 &ghosting_functor) ==
1118 _ghosting_functors.end());
1119
1120 if (const auto it = _shared_functors.find(&ghosting_functor);
1121 it != _shared_functors.end())
1122 _shared_functors.erase(it);
1123}
1124
1125
1126
1127void MeshBase::subdomain_ids (std::set<subdomain_id_type> & ids, const bool global /* = true */) const
1128{
1129 // This requires an inspection on every processor
1130 if (global)
1131 parallel_object_only();
1132
1133 struct SBDInserter {
1134 std::set<subdomain_id_type> my_ids;
1135
1136 SBDInserter () {}
1137 SBDInserter (SBDInserter &, Threads::split) {}
1138
1139 void operator()(const ConstElemRange & range) {
1140 for (const Elem * elem : range)
1141 my_ids.insert(elem->subdomain_id());
1142 }
1143
1144 void join(SBDInserter & other) {
1145 my_ids.merge(other.my_ids);
1146 }
1147 };
1148
1149 SBDInserter inserter;
1151
1152 ids.swap(inserter.my_ids);
1153
1154 if (global)
1155 {
1156 // Only include the unpartitioned elements if the user requests the global IDs.
1157 // In the case of the local subdomain IDs, it doesn't make sense to include the
1158 // unpartitioned elements because said elements do not have a sense of locality.
1159 for (const auto & elem : this->active_unpartitioned_element_ptr_range())
1160 ids.insert(elem->subdomain_id());
1161
1162 // Some subdomains may only live on other processors
1163 this->comm().set_union(ids);
1164 }
1165}
1166
1167
1168
1170{
1171 // We now have all elements and nodes redistributed; our ghosting
1172 // functors should be ready to redistribute and/or recompute any
1173 // cached data they use too.
1174 for (auto & gf : as_range(this->ghosting_functors_begin(),
1175 this->ghosting_functors_end()))
1176 gf->redistribute();
1177}
1178
1179
1180
1182{
1183 // A range over all elements might still be fine here, but any range
1184 // over local elements is obsolete if our partitioner changed the
1185 // definition of "local".
1187}
1188
1189
1190
1192{
1193 // This requires an inspection on every processor
1194 parallel_object_only();
1195
1196 std::set<subdomain_id_type> ids;
1197
1198 this->subdomain_ids (ids);
1199
1200 return cast_int<subdomain_id_type>(ids.size());
1201}
1202
1203
1204
1206{
1207 std::set<subdomain_id_type> ids;
1208
1209 this->subdomain_ids (ids, /* global = */ false);
1210
1211 return cast_int<subdomain_id_type>(ids.size());
1212}
1213
1214
1215
1216
1218{
1219 // We're either counting a processor's nodes or unpartitioned
1220 // nodes
1221 libmesh_assert (proc_id < this->n_processors() ||
1223
1224 return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
1225 this->pid_nodes_end (proc_id)));
1226}
1227
1228
1229
1231{
1232 // We're either counting a processor's elements or unpartitioned
1233 // elements
1234 libmesh_assert (proc_id < this->n_processors() ||
1236
1237 return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
1238 this->pid_elements_end (proc_id)));
1239}
1240
1241
1242
1244{
1245 libmesh_assert_less (proc_id, this->n_processors());
1246 return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
1247 this->active_pid_elements_end (proc_id)));
1248}
1249
1250
1251
1253{
1254 dof_id_type ne=0;
1255
1256 for (const auto & elem : this->element_ptr_range())
1257 ne += elem->n_sub_elem();
1258
1259 return ne;
1260}
1261
1262
1263
1265{
1266 dof_id_type ne=0;
1267
1268 for (const auto & elem : this->active_element_ptr_range())
1269 ne += elem->n_sub_elem();
1270
1271 return ne;
1272}
1273
1274
1275
1276std::string MeshBase::get_info(const unsigned int verbosity /* = 0 */, const bool global /* = true */) const
1277{
1278 std::ostringstream oss;
1279
1280 oss << " Mesh Information:" << '\n';
1281
1282 if (!_elem_dims.empty())
1283 {
1284 oss << " elem_dimensions()={";
1285 std::copy(_elem_dims.begin(),
1286 --_elem_dims.end(), // --end() is valid if the set is non-empty
1287 std::ostream_iterator<unsigned int>(oss, ", "));
1288 oss << cast_int<unsigned int>(*_elem_dims.rbegin());
1289 oss << "}";
1290 if (!this->preparation().has_cached_elem_data)
1291 oss << " (may be out of date)";
1292 oss << '\n';
1293 }
1294
1295 if (!_elem_default_orders.empty())
1296 {
1297 oss << " elem_default_orders()={";
1298 std::transform(_elem_default_orders.begin(),
1299 --_elem_default_orders.end(),
1300 std::ostream_iterator<std::string>(oss, ", "),
1301 [](Order o)
1302 { return Utility::enum_to_string<Order>(o); });
1303 oss << Utility::enum_to_string<Order>(*_elem_default_orders.rbegin());
1304 oss << "}";
1305 if (!this->preparation().has_cached_elem_data)
1306 oss << " (may be out of date)";
1307 oss << '\n';
1308 }
1309
1310 oss << " supported_nodal_order()=" << this->_supported_nodal_order;
1311 if (!this->preparation().has_cached_elem_data)
1312 oss << " (may be out of date)";
1313 oss << '\n';
1314
1315 oss << " spatial_dimension()=" << int(this->_spatial_dimension);
1316 if (!this->preparation().has_cached_elem_data)
1317 oss << " (may be out of date)";
1318 oss << '\n';
1319
1320 oss << " n_nodes()=" << this->n_nodes() << '\n'
1321 << " n_local_nodes()=" << this->n_local_nodes() << '\n'
1322 << " n_elem()=" << this->n_elem() << '\n'
1323 << " n_local_elem()=" << this->n_local_elem() << '\n';
1324#ifdef LIBMESH_ENABLE_AMR
1325 oss << " n_active_elem()=" << this->n_active_elem() << '\n';
1326#endif
1327 if (global)
1328 oss << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n';
1329 else
1330 oss << " n_local_subdomains()= " << static_cast<std::size_t>(this->n_local_subdomains()) << '\n';
1331 oss << " n_elemsets()=" << static_cast<std::size_t>(this->n_elemsets()) << '\n';
1332 if (!_elemset_codes.empty())
1333 oss << " n_elemset_codes=" << _elemset_codes.size() << '\n';
1334 oss << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
1335 << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
1336 << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
1337 << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n'
1338 << " is_prepared()=" << (this->is_prepared() ? "true" : "false") << '\n'
1339 << " is_replicated()=" << (this->is_replicated() ? "true" : "false") << '\n';
1340
1341 if (verbosity > 0)
1342 {
1343 if (global)
1344 {
1345 libmesh_parallel_only(this->comm());
1346 if (this->processor_id() != 0)
1347 oss << "\n Detailed global get_info() (verbosity > 0) is reduced and output to only rank 0.";
1348 }
1349
1350 // Helper for printing element types
1351 const auto elem_type_helper = [](const std::set<int> & elem_types) {
1352 std::stringstream ss;
1353 for (auto it = elem_types.begin(); it != elem_types.end();)
1354 {
1356 if (++it != elem_types.end())
1357 ss << ", ";
1358 }
1359 return ss.str();
1360 };
1361
1362 // Helper for whether or not the given DofObject is to be included. If we're doing
1363 // a global reduction, we also count unpartitioned objects on rank 0.
1364 const auto include_object = [this, &global](const DofObject & dof_object) {
1365 return this->processor_id() == dof_object.processor_id() ||
1366 (global &&
1367 this->processor_id() == 0 &&
1368 dof_object.processor_id() == DofObject::invalid_processor_id);
1369 };
1370
1371 Real volume = 0;
1372
1373 // Add bounding box information
1374 const auto bbox = global ? MeshTools::create_bounding_box(*this) : MeshTools::create_local_bounding_box(*this);
1375 if (!global || this->processor_id() == 0)
1376 oss << "\n " << (global ? "" : "Local ") << "Mesh Bounding Box:\n"
1377 << " Minimum: " << bbox.min() << "\n"
1378 << " Maximum: " << bbox.max() << "\n"
1379 << " Delta: " << (bbox.max() - bbox.min()) << "\n";
1380
1381 // Obtain the global or local element types
1382 std::set<int> elem_types;
1383 for (const Elem * elem : this->active_local_element_ptr_range())
1384 elem_types.insert(elem->type());
1385 if (global)
1386 {
1387 // Pick up unpartitioned elems on rank 0
1388 if (this->processor_id() == 0)
1389 for (const Elem * elem : this->active_unpartitioned_element_ptr_range())
1390 elem_types.insert(elem->type());
1391
1392 this->comm().set_union(elem_types);
1393 }
1394
1395 // Add element types
1396 if (!global || this->processor_id() == 0)
1397 oss << "\n " << (global ? "" : "Local ") << "Mesh Element Type(s):\n "
1398 << elem_type_helper(elem_types) << "\n";
1399
1400 // Reduce the nodeset ids
1401 auto nodeset_ids = this->get_boundary_info().get_node_boundary_ids();
1402 if (global)
1403 this->comm().set_union(nodeset_ids);
1404
1405 // Accumulate local information for each nodeset
1406 struct NodesetInfo
1407 {
1408 std::size_t num_nodes = 0;
1409 BoundingBox bbox;
1410 };
1411 std::map<boundary_id_type, NodesetInfo> nodeset_info_map;
1412 for (const auto & [node, id] : this->get_boundary_info().get_nodeset_map())
1413 {
1414 if (!include_object(*node))
1415 continue;
1416
1417 NodesetInfo & info = nodeset_info_map[id];
1418
1419 ++info.num_nodes;
1420
1421 if (verbosity > 1)
1422 info.bbox.union_with(*node);
1423 }
1424
1425 // Add nodeset info
1426 if (!global || this->processor_id() == 0)
1427 {
1428 oss << "\n " << (global ? "" : "Local ") << "Mesh Nodesets:\n";
1429 if (nodeset_ids.empty())
1430 oss << " None\n";
1431 }
1432
1433 const auto & nodeset_name_map = this->get_boundary_info().get_nodeset_name_map();
1434 for (const auto id : nodeset_ids)
1435 {
1436 NodesetInfo & info = nodeset_info_map[id];
1437
1438 // Reduce the local information for this nodeset if required
1439 if (global)
1440 {
1441 this->comm().sum(info.num_nodes);
1442 if (verbosity > 1)
1443 {
1444 this->comm().min(info.bbox.min());
1445 this->comm().max(info.bbox.max());
1446 }
1447 }
1448
1449 const bool has_name = nodeset_name_map.count(id) && nodeset_name_map.at(id).size();
1450 const std::string name = has_name ? nodeset_name_map.at(id) : "";
1451 if (global)
1452 libmesh_assert(this->comm().verify(name));
1453
1454 if (global ? this->processor_id() == 0 : info.num_nodes > 0)
1455 {
1456 oss << " Nodeset " << id;
1457 if (has_name)
1458 oss << " (" << name << ")";
1459 oss << ", " << info.num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1460
1461 if (verbosity > 1)
1462 {
1463 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1464 << info.bbox.min() << "\n"
1465 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1466 << info.bbox.max() << "\n"
1467 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1468 << (info.bbox.max() - info.bbox.min()) << "\n";
1469 }
1470 }
1471 }
1472
1473 // Reduce the sideset ids
1474 auto sideset_ids = this->get_boundary_info().get_side_boundary_ids();
1475 if (global)
1476 this->comm().set_union(sideset_ids);
1477
1478 // Accumulate local information for each sideset
1479 struct SidesetInfo
1480 {
1481 std::size_t num_sides = 0;
1482 Real volume = 0;
1483 std::set<int> side_elem_types;
1484 std::set<int> elem_types;
1485 std::set<dof_id_type> elem_ids;
1486 std::set<dof_id_type> node_ids;
1487 BoundingBox bbox;
1488 };
1489 ElemSideBuilder side_builder;
1490 std::map<boundary_id_type, SidesetInfo> sideset_info_map;
1491 for (const auto & pair : this->get_boundary_info().get_sideset_map())
1492 {
1493 const Elem * elem = pair.first;
1494 if (!include_object(*elem))
1495 continue;
1496
1497 const auto id = pair.second.second;
1498 SidesetInfo & info = sideset_info_map[id];
1499
1500 const auto s = pair.second.first;
1501 const Elem & side = side_builder(*elem, s);
1502
1503 ++info.num_sides;
1504 info.side_elem_types.insert(side.type());
1505 info.elem_types.insert(elem->type());
1506 info.elem_ids.insert(elem->id());
1507
1508 for (const Node & node : side.node_ref_range())
1509 if (include_object(node))
1510 info.node_ids.insert(node.id());
1511
1512 if (verbosity > 1)
1513 {
1514 info.volume += side.volume();
1515 info.bbox.union_with(side.loose_bounding_box());
1516 }
1517 }
1518
1519 // Add sideset info
1520 if (!global || this->processor_id() == 0)
1521 {
1522 oss << "\n " << (global ? "" : "Local ") << "Mesh Sidesets:\n";
1523 if (sideset_ids.empty())
1524 oss << " None\n";
1525 }
1526 const auto & sideset_name_map = this->get_boundary_info().get_sideset_name_map();
1527 for (const auto id : sideset_ids)
1528 {
1529 SidesetInfo & info = sideset_info_map[id];
1530
1531 auto num_elems = info.elem_ids.size();
1532 auto num_nodes = info.node_ids.size();
1533
1534 // Reduce the local information for this sideset if required
1535 if (global)
1536 {
1537 this->comm().sum(info.num_sides);
1538 this->comm().set_union(info.side_elem_types, 0);
1539 this->comm().sum(num_elems);
1540 this->comm().set_union(info.elem_types, 0);
1541 this->comm().sum(num_nodes);
1542 if (verbosity > 1)
1543 {
1544 this->comm().sum(info.volume);
1545 this->comm().min(info.bbox.min());
1546 this->comm().max(info.bbox.max());
1547 }
1548 }
1549
1550 const bool has_name = sideset_name_map.count(id) && sideset_name_map.at(id).size();
1551 const std::string name = has_name ? sideset_name_map.at(id) : "";
1552 if (global)
1553 libmesh_assert(this->comm().verify(name));
1554
1555 if (global ? this->processor_id() == 0 : info.num_sides > 0)
1556 {
1557 oss << " Sideset " << id;
1558 if (has_name)
1559 oss << " (" << name << ")";
1560 oss << ", " << info.num_sides << " sides (" << elem_type_helper(info.side_elem_types) << ")"
1561 << ", " << num_elems << " " << (global ? "" : "local ") << "elems (" << elem_type_helper(info.elem_types) << ")"
1562 << ", " << num_nodes << " " << (global ? "" : "local ") << "nodes\n";
1563
1564 if (verbosity > 1)
1565 {
1566 oss << " " << (global ? "Side" : "Local side") << " volume: " << info.volume << "\n"
1567 << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1568 << info.bbox.min() << "\n"
1569 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1570 << info.bbox.max() << "\n"
1571 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1572 << (info.bbox.max() - info.bbox.min()) << "\n";
1573 }
1574 }
1575 }
1576
1577 // Reduce the edgeset ids
1578 auto edgeset_ids = this->get_boundary_info().get_edge_boundary_ids();
1579 if (global)
1580 this->comm().set_union(edgeset_ids);
1581
1582 // Accumulate local information for each edgeset
1583 struct EdgesetInfo
1584 {
1585 std::size_t num_edges = 0;
1586 std::set<int> edge_elem_types;
1587 BoundingBox bbox;
1588 };
1589 std::map<boundary_id_type, EdgesetInfo> edgeset_info_map;
1590 std::unique_ptr<const Elem> edge;
1591
1592 for (const auto & pair : this->get_boundary_info().get_edgeset_map())
1593 {
1594 const Elem * elem = pair.first;
1595 if (!include_object(*elem))
1596 continue;
1597
1598 const auto id = pair.second.second;
1599 EdgesetInfo & info = edgeset_info_map[id];
1600
1601 elem->build_edge_ptr(edge, pair.second.first);
1602
1603 ++info.num_edges;
1604 info.edge_elem_types.insert(edge->type());
1605
1606 if (verbosity > 1)
1607 info.bbox.union_with(edge->loose_bounding_box());
1608 }
1609
1610 // Add edgeset info
1611 if (!global || this->processor_id() == 0)
1612 {
1613 oss << "\n " << (global ? "" : "Local ") << "Mesh Edgesets:\n";
1614 if (edgeset_ids.empty())
1615 oss << " None\n";
1616 }
1617
1618 const auto & edgeset_name_map = this->get_boundary_info().get_edgeset_name_map();
1619 for (const auto id : edgeset_ids)
1620 {
1621 EdgesetInfo & info = edgeset_info_map[id];
1622
1623 // Reduce the local information for this edgeset if required
1624 if (global)
1625 {
1626 this->comm().sum(info.num_edges);
1627 this->comm().set_union(info.edge_elem_types, 0);
1628 if (verbosity > 1)
1629 {
1630 this->comm().min(info.bbox.min());
1631 this->comm().min(info.bbox.max());
1632 }
1633 }
1634
1635 const bool has_name = edgeset_name_map.count(id) && edgeset_name_map.at(id).size();
1636 const std::string name = has_name ? edgeset_name_map.at(id) : "";
1637 if (global)
1638 libmesh_assert(this->comm().verify(name));
1639
1640 if (global ? this->processor_id() == 0 : info.num_edges > 0)
1641 {
1642 oss << " Edgeset " << id;
1643 if (has_name)
1644 oss << " (" << name << ")";
1645 oss << ", " << info.num_edges << " " << (global ? "" : "local ") << "edges ("
1646 << elem_type_helper(info.edge_elem_types) << ")\n";
1647
1648 if (verbosity > 1)
1649 {
1650 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1651 << info.bbox.min() << "\n"
1652 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1653 << info.bbox.max() << "\n"
1654 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1655 << (info.bbox.max() - info.bbox.min()) << "\n";
1656 }
1657 }
1658 }
1659
1660 // Reduce the block IDs and block names
1661 std::set<subdomain_id_type> subdomains;
1662 for (const Elem * elem : this->active_element_ptr_range())
1663 if (include_object(*elem))
1664 subdomains.insert(elem->subdomain_id());
1665 if (global)
1666 this->comm().set_union(subdomains);
1667
1668 // Accumulate local information for each subdomain
1669 struct SubdomainInfo
1670 {
1671 std::size_t num_elems = 0;
1672 Real volume = 0;
1673 std::set<int> elem_types;
1674 std::set<dof_id_type> active_node_ids;
1675#ifdef LIBMESH_ENABLE_AMR
1676 std::size_t num_active_elems = 0;
1677#endif
1678 BoundingBox bbox;
1679 };
1680 std::map<subdomain_id_type, SubdomainInfo> subdomain_info_map;
1681 for (const Elem * elem : this->element_ptr_range())
1682 if (include_object(*elem))
1683 {
1684 SubdomainInfo & info = subdomain_info_map[elem->subdomain_id()];
1685
1686 ++info.num_elems;
1687 info.elem_types.insert(elem->type());
1688
1689#ifdef LIBMESH_ENABLE_AMR
1690 if (elem->active())
1691 ++info.num_active_elems;
1692#endif
1693
1694 for (const Node & node : elem->node_ref_range())
1695 if (include_object(node) && node.active())
1696 info.active_node_ids.insert(node.id());
1697
1698 if (verbosity > 1 && elem->active())
1699 {
1700 info.volume += elem->volume();
1701 info.bbox.union_with(elem->loose_bounding_box());
1702 }
1703 }
1704
1705 // Add subdomain info
1706 oss << "\n " << (global ? "" : "Local ") << "Mesh Subdomains:\n";
1707 const auto & subdomain_name_map = this->get_subdomain_name_map();
1708 for (const auto id : subdomains)
1709 {
1710 SubdomainInfo & info = subdomain_info_map[id];
1711
1712 auto num_active_nodes = info.active_node_ids.size();
1713
1714 // Reduce the information for this subdomain if needed
1715 if (global)
1716 {
1717 this->comm().sum(info.num_elems);
1718#ifdef LIBMESH_ENABLE_AMR
1719 this->comm().sum(info.num_active_elems);
1720#endif
1721 this->comm().sum(num_active_nodes);
1722 this->comm().set_union(info.elem_types, 0);
1723 if (verbosity > 1)
1724 {
1725 this->comm().min(info.bbox.min());
1726 this->comm().max(info.bbox.max());
1727 this->comm().sum(info.volume);
1728 }
1729 }
1730 if (verbosity > 1)
1731 volume += info.volume;
1732
1733 const bool has_name = subdomain_name_map.count(id);
1734 const std::string name = has_name ? subdomain_name_map.at(id) : "";
1735 if (global)
1736 libmesh_assert(this->comm().verify(name));
1737
1738 if (!global || this->processor_id() == 0)
1739 {
1740 oss << " Subdomain " << id;
1741 if (has_name)
1742 oss << " (" << name << ")";
1743 oss << ": " << info.num_elems << " " << (global ? "" : "local ") << "elems "
1744 << "(" << elem_type_helper(info.elem_types);
1745#ifdef LIBMESH_ENABLE_AMR
1746 oss << ", " << info.num_active_elems << " active";
1747#endif
1748 oss << "), " << num_active_nodes << " " << (global ? "" : "local ") << "active nodes\n";
1749 if (verbosity > 1)
1750 {
1751 oss << " " << (global ? "Volume" : "Local volume") << ": " << info.volume << "\n";
1752 oss << " " << (global ? "Bounding" : "Local bounding") << " box minimum: "
1753 << info.bbox.min() << "\n"
1754 << " " << (global ? "Bounding" : "Local bounding") << " box maximum: "
1755 << info.bbox.max() << "\n"
1756 << " " << (global ? "Bounding" : "Local bounding") << " box delta: "
1757 << (info.bbox.max() - info.bbox.min()) << "\n";
1758 }
1759 }
1760 }
1761
1762 oss << " " << (global ? "Global" : "Local") << " mesh volume = " << volume << "\n";
1763
1764 }
1765
1766 return oss.str();
1767}
1768
1769
1770void MeshBase::print_info(std::ostream & os, const unsigned int verbosity /* = 0 */, const bool global /* = true */) const
1771{
1772 os << this->get_info(verbosity, global)
1773 << std::endl;
1774}
1775
1776
1777std::ostream & operator << (std::ostream & os, const MeshBase & m)
1778{
1779 m.print_info(os);
1780 return os;
1781}
1782
1783
1784void MeshBase::partition (const unsigned int n_parts)
1785{
1786 // If we get here and we have unpartitioned elements, we need that
1787 // fixed.
1788 if (this->n_unpartitioned_elem() > 0)
1789 {
1790 libmesh_assert (partitioner().get());
1791 libmesh_assert (this->is_serial());
1792 partitioner()->partition (*this, n_parts);
1793 }
1794 // A nullptr partitioner or a skip_partitioning(true) call or a
1795 // skip_noncritical_partitioning(true) call means don't repartition;
1796 // skip_noncritical_partitioning() checks all these.
1798 {
1799 partitioner()->partition (*this, n_parts);
1800 }
1801 else
1802 {
1803 // Adaptive coarsening may have "orphaned" nodes on processors
1804 // whose elements no longer share them. We need to check for
1805 // and possibly fix that.
1807
1808 // Make sure locally cached partition count is correct
1810
1811 // Make sure any other locally cached data is correct
1813 }
1814
1816}
1817
1818void MeshBase::all_second_order (const bool full_ordered)
1819{
1820 this->all_second_order_range(this->element_ptr_range(), full_ordered);
1821}
1822
1824{
1825 this->all_complete_order_range(this->element_ptr_range());
1826}
1827
1829{
1830 // This requires an inspection on every processor
1831 parallel_object_only();
1832
1833 unsigned int max_proc_id=0;
1834
1835 for (const auto & elem : this->active_local_element_ptr_range())
1836 max_proc_id = std::max(max_proc_id, static_cast<unsigned int>(elem->processor_id()));
1837
1838 // The number of partitions is one more than the max processor ID.
1839 _n_parts = max_proc_id+1;
1840
1841 this->comm().max(_n_parts);
1842
1843 return _n_parts;
1844}
1845
1846
1847
1848std::unique_ptr<PointLocatorBase> MeshBase::sub_point_locator () const
1849{
1850 // If there's no master point locator, then we need one.
1851 if (_point_locator.get() == nullptr)
1852 {
1853 // PointLocator construction may not be safe within threads
1855
1856 // And it may require parallel communication
1857 parallel_object_only();
1858
1859#ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1861#else
1863#endif
1864
1866 _point_locator->set_close_to_point_tol(_point_locator_close_to_point_tol);
1867 }
1868
1869 // Otherwise there was a master point locator, and we can grab a
1870 // sub-locator easily.
1871 return
1872#ifdef LIBMESH_ENABLE_NANOFLANN_POINTLOCATOR
1874#else
1876#endif
1877}
1878
1879
1880
1882{
1883 _point_locator.reset(nullptr);
1884}
1885
1886
1887
1889{
1890 _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
1891}
1892
1893
1894
1899
1900
1901#ifdef LIBMESH_ENABLE_DEPRECATED
1903{
1904 // Use set_subdomain_name() instead
1905 libmesh_deprecated();
1906
1907 // We'd like to do this so our preparation isn't invalidated by a
1908 // write, but for all we know the user is just reading from a
1909 // non-const mesh!
1910 // this->unset_has_synched_subdomain_name_map();
1911
1912 return _block_id_to_name[id];
1913}
1914#endif // LIBMESH_ENABLE_DEPRECATED
1915
1916
1917const std::string & MeshBase::subdomain_name(subdomain_id_type id) const
1918{
1919 // An empty string to return when no matching subdomain name is found
1920 static const std::string empty;
1921
1922 if (const auto iter = _block_id_to_name.find(id);
1923 iter == _block_id_to_name.end())
1924 return empty;
1925 else
1926 return iter->second;
1927}
1928
1930 const std::string & name,
1931 const bool synchronous)
1932{
1933 if (synchronous)
1934 parallel_object_only();
1935 else
1937 _block_id_to_name[id] = name;
1938}
1939
1940
1942{
1943 // Linear search over the map values.
1944 for (const auto & [sbd_id, sbd_name] : _block_id_to_name)
1945 if (sbd_name == name)
1946 return sbd_id;
1947
1948 // If we made it here without returning, we don't have a subdomain
1949 // with the requested name, so return Elem::invalid_subdomain_id.
1951}
1952
1953
1955{
1957 {
1958 // Range construction may not be safe within threads
1960
1962 std::make_unique<ElemRange>(this->elements_begin(),
1963 this->elements_end());
1964 }
1965
1966 return *_element_stored_range;
1967}
1968
1970{
1972 {
1973 // Range construction may not be safe within threads
1975
1977 std::make_unique<ConstElemRange>(this->active_local_elements_begin(),
1978 this->active_local_elements_end());
1979 }
1980
1982}
1983
1985{
1986 _element_stored_range.reset(nullptr);
1988}
1989
1990
1991#ifdef LIBMESH_ENABLE_DEPRECATED
1993{
1994 libmesh_deprecated();
1995
1996 this->cache_elem_data();
1997}
1998#endif // LIBMESH_ENABLE_DEPRECATED
1999
2001{
2002 // This requires an inspection on every processor
2003 parallel_object_only();
2004
2005 // Need to clear containers first in case all elements of a
2006 // particular dimension/order/subdomain have been deleted.
2007 _elem_dims.clear();
2008 _elem_default_orders.clear();
2009 _mesh_subdomains.clear();
2011
2012 for (const auto & elem : this->active_element_ptr_range())
2013 {
2014 _elem_dims.insert(cast_int<unsigned char>(elem->dim()));
2015 _elem_default_orders.insert(elem->default_order());
2016 _mesh_subdomains.insert(elem->subdomain_id());
2018 static_cast<Order>
2019 (std::min(static_cast<int>(_supported_nodal_order),
2020 static_cast<int>(elem->supported_nodal_order())));
2021 }
2022
2023 if (!this->is_serial())
2024 {
2025 // Some different dimension/order/subdomain elements may only live
2026 // on other processors
2027 this->comm().set_union(_elem_dims);
2031 }
2032
2033 // If the largest element dimension found is larger than the current
2034 // _spatial_dimension, increase _spatial_dimension.
2035 unsigned int max_dim = this->mesh_dimension();
2036 if (max_dim > _spatial_dimension)
2037 _spatial_dimension = cast_int<unsigned char>(max_dim);
2038
2039 // _spatial_dimension may need to increase from 1->2 or 2->3 if the
2040 // mesh is full of 1D elements but they are not x-aligned, or the
2041 // mesh is full of 2D elements but they are not in the x-y plane.
2042 // If the mesh is x-aligned or x-y planar, we will end up checking
2043 // every node's coordinates and not breaking out of the loop
2044 // early...
2045 if (_spatial_dimension < LIBMESH_DIM)
2046 {
2047 for (const auto & node : this->node_ptr_range())
2048 {
2049 // Note: the exact floating point comparison is intentional,
2050 // we don't want to get tripped up by tolerances.
2051 if ((*node)(0) != 0. && _spatial_dimension < 1)
2053
2054 if ((*node)(1) != 0. && _spatial_dimension < 2)
2055 {
2057#if LIBMESH_DIM == 2
2058 // If libmesh is compiled in 2D mode, this is the
2059 // largest spatial dimension possible so we can break
2060 // out.
2061 break;
2062#endif
2063 }
2064
2065#if LIBMESH_DIM > 2
2066 if ((*node)(2) != 0.)
2067 {
2068 // Spatial dimension can't get any higher than this, so
2069 // we can break out.
2071 break;
2072 }
2073#endif
2074 }
2075 }
2076
2078}
2079
2080
2082{
2083 // This requires every processor
2084 parallel_object_only();
2085
2087
2089}
2090
2091
2093{
2094 LOG_SCOPE("detect_interior_parents()", "MeshBase");
2095
2096 // This requires an inspection on every processor
2097 parallel_object_only();
2098
2099 // This requires up-to-date mesh dimensions, but if we don't have
2100 // them cached then we can't update them without changing the mesh
2101 // in unexpected ways that interfere with our tests of
2102 // partially-prepared meshes in MeshTools::*valid_is_prepared
2103 std::set<unsigned char> elem_dims_copy;
2105 elem_dims_copy = this->elem_dimensions();
2106 else
2107 {
2108 for (const auto & elem : this->active_element_ptr_range())
2109 elem_dims_copy.insert(cast_int<unsigned char>(elem->dim()));
2110 if (!this->is_serial())
2111 this->comm().set_union(elem_dims_copy);
2112 }
2113
2114 // Early return if the mesh is empty or has elements of a single spatial dimension.
2115 if (elem_dims_copy.size() <= 1)
2116 {
2118 return;
2119 }
2120
2121 // Convenient elem_dimensions iterators
2122 const auto dim_start = elem_dims_copy.begin();
2123 const auto dim_end = elem_dims_copy.end();
2124
2125 // In this function we find only +1 dimensional interior parents,
2126 // (so, for a given element el, the interior parent p must satisfy p.dim() == el.dim() + 1).
2127 // Therefore, we can avoid checking the existence of interior parents
2128 // for all those elements el such there there is no p with p.dim() == el.dim() + 1.
2129 // We store whether to skip any given dimension in the construction of interior parents
2130 // inside the vector in dimensions_to_skip_for_interior_parents.
2131 std::vector<bool> skip_dimension_for_interior_parents(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2132 skip_dimension_for_interior_parents.back() = true;
2133
2134 // Moreover, in the following, we will build a node-to-elem map.
2135 // It is among the elems of this map that we will look for interior parents.
2136 // Therefore, we can skip all elems p such that there is no el with el.dim() == p.dim() - 1.
2137 // We store whether to skip any given dimension in the construction of the node-to-elem map
2138 // in the vector skip_dimensions_for_node_to_el_map.
2139 std::vector<bool> skip_dimensions_for_node_to_el_map(/*count=*/LIBMESH_DIM+1, /*value=*/false);
2140 skip_dimensions_for_node_to_el_map[*dim_start] = true;
2141
2142 // We also create a flag to know if all dimensions should be skipped,
2143 // and if we should therefore return early.
2144 bool skip_all_dimensions = true;
2145
2146 // Fill dimensions_to_skip_for_interior_parents and dimensions_to_skip_for_node_to_el_map.
2147 for (auto [it, next] = std::make_tuple(dim_start, std::next(dim_start));
2148 next != dim_end; ++it, ++next)
2149 {
2150 if (*it + 1 != *next) // if sequential dimensions differ by exactly 1
2151 {
2152 skip_dimension_for_interior_parents[*it] = true;
2153 skip_dimensions_for_node_to_el_map[*next] = true;
2154 }
2155 else if (!skip_dimension_for_interior_parents[*it])
2156 skip_all_dimensions = false;
2157 }
2158
2159 // There is nothing to do if all dimensions should be
2160 // skipped. Before returning, we must also set the flag that says
2161 // "interior parent pointers have been set up" even though we
2162 // determined there was no work to be done.
2163 if (skip_all_dimensions)
2164 {
2166 return;
2167 }
2168
2169 // Do we have interior parent pointers going to a different mesh?
2170 // If so then we'll still check to make sure that's the only place
2171 // they go, so we can libmesh_not_implemented() if not.
2172 const bool separate_interior_mesh = (&(this->interior_mesh()) != this);
2173
2174 // This map will be used to set interior parents
2175 std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
2176
2177 for (const auto & elem : this->element_ptr_range())
2178 {
2179 // Ignore element if it cannot be interior parent of any other elem.
2180 if (skip_dimensions_for_node_to_el_map[elem->dim()])
2181 continue;
2182
2183 // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
2184 for (auto n : make_range(elem->n_vertices()))
2185 {
2186 libmesh_assert_less (elem->id(), this->max_elem_id());
2187
2188 node_to_elem[elem->node_id(n)].push_back(elem->id());
2189 }
2190 }
2191
2192 // Automatically set interior parents
2193 for (const auto & element : this->element_ptr_range())
2194 {
2195 // Ignore elements with dimensions to skip
2196 // or elements that already have an interior parent.
2197 if (skip_dimension_for_interior_parents[element->dim()] || element->interior_parent())
2198 continue;
2199
2200 // Start by generating sets of dim+1 dimensional elements that
2201 // touch each vertex of the current element. If we encounter a
2202 // vertex not connected to _any_ dim+1 dimensional elements,
2203 // then we can exit the loop without checking the remaining
2204 // vertices since an interior parent (if it exists) will be
2205 // connected to all vertices of the current element.
2206 std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
2207
2208 bool found_interior_parents = true;
2209
2210 for (auto n : make_range(element->n_vertices()))
2211 {
2212 auto it = node_to_elem.find(element->node_id(n));
2213
2214 // Check at first that this node is not isolated.
2215 if (it == node_to_elem.end())
2216 {
2217 found_interior_parents = false;
2218 break; // out of n-loop
2219 }
2220
2221 for (const auto & vertex_neighbor_id : it->second)
2222 if (this->elem_ref(vertex_neighbor_id).dim() == element->dim()+1)
2223 neighbors[n].insert(vertex_neighbor_id);
2224
2225 if (neighbors[n].empty())
2226 {
2227 // We have found an empty set for one vertex, no reason
2228 // to continue.
2229 found_interior_parents = false;
2230 break; // out of n-loop
2231 }
2232 }
2233
2234 // If we have generated a non-empty set of elements for each
2235 // vertex, we will now look for a vertex_neighbor_id that
2236 // appears in _all_ of those sets. If found, this is our interior
2237 // parent id. If multiple such common ids are found, we will
2238 // take the lowest such id to be the interior parent id.
2239 if (found_interior_parents)
2240 {
2241 std::set<dof_id_type> & neighbors_0 = neighbors[0];
2242 for (const auto & interior_parent_id : neighbors_0)
2243 {
2244 found_interior_parents = false;
2245 for (auto n : make_range(1u, element->n_vertices()))
2246 {
2247 if (neighbors[n].count(interior_parent_id))
2248 {
2249 found_interior_parents = true;
2250 }
2251 else
2252 {
2253 found_interior_parents = false;
2254 break;
2255 }
2256 }
2257
2258 if (found_interior_parents)
2259 {
2260 element->set_interior_parent(this->elem_ptr(interior_parent_id));
2261 break;
2262 }
2263 }
2264
2265 // Do we have a mixed dimensional mesh that contains some of
2266 // its own interior parents, but we already expect to have
2267 // interior parents on a different mesh? That's going to
2268 // take some work to support if anyone needs it.
2269 if (separate_interior_mesh)
2270 libmesh_not_implemented_msg
2271 ("interior_parent() values in multiple meshes are unsupported.");
2272 }
2273 }
2274
2275 // This flag doesn't necessarily mean any Elems actually have
2276 // interior parent pointers, just that we did all the work to
2277 // determine whether or not they do.
2279}
2280
2281
2282
2283#ifdef LIBMESH_ENABLE_PERIODIC
2288 const boundary_id_type b2,
2289 const RealVectorValue & translation)
2290 {
2291 // Lazily allocate the container the first time it’s needed
2293 _disjoint_neighbor_boundary_pairs = std::make_unique<PeriodicBoundaries>();
2294
2296
2297 // Create forward and inverse boundary mappings
2298 PeriodicBoundary forward(translation);
2299 PeriodicBoundary inverse(translation * -1.0);
2300
2301 forward.myboundary = b1;
2302 forward.pairedboundary = b2;
2303 inverse.myboundary = b2;
2304 inverse.pairedboundary = b1;
2305
2306 // Add both directions into the container
2307 db.emplace(b1, forward.clone());
2308 db.emplace(b2, inverse.clone());
2309 }
2310
2315
2320
2322 const boundary_id_type b2)
2323 {
2324 // Nothing to remove if not allocated or empty
2326 return;
2327
2328 auto & pairs = *_disjoint_neighbor_boundary_pairs;
2329
2330 // Helper to check and erase both directions
2331 auto erase_if_match = [](boundary_id_type key,
2332 boundary_id_type pair,
2333 PeriodicBoundaries & pb_map)
2334 {
2335 auto it = pb_map.find(key);
2336 if (it != pb_map.end())
2337 {
2338 const auto & pb = *(it->second);
2339 // Check both directions
2340 if ((pb.myboundary == key && pb.pairedboundary == pair) ||
2341 (pb.pairedboundary == key && pb.myboundary == pair))
2342 pb_map.erase(it);
2343 }
2344 };
2345
2346 erase_if_match(b1, b2, pairs);
2347 erase_if_match(b2, b1, pairs);
2348 }
2349
2350
2351#endif
2352
2353
2354
2356{
2358 if (_point_locator)
2359 {
2360 if (val > 0.)
2361 _point_locator->set_close_to_point_tol(val);
2362 else
2363 _point_locator->unset_close_to_point_tol();
2364 }
2365}
2366
2367
2368
2373
2374
2375
2377{
2378 const std::size_t new_size = _elem_integer_names.size();
2379
2381 (this->element_stored_range(),
2382 [new_size, this](const ElemRange & range)
2383 {
2384 for (Elem * elem : range)
2385 elem->add_extra_integers(new_size, this->_elem_integer_default_values);
2386 });
2387}
2388
2389
2390
2392{
2393 const std::size_t new_size = _node_integer_names.size();
2394 for (auto node : this->node_ptr_range())
2395 node->add_extra_integers(new_size, _node_integer_default_values);
2396}
2397
2398
2399std::pair<std::vector<unsigned int>, std::vector<unsigned int>>
2401{
2402 std::pair<std::vector<unsigned int>, std::vector<unsigned int>> returnval;
2403 returnval.first = this->add_elem_integers(other._elem_integer_names, true, &other._elem_integer_default_values);
2404 returnval.second = this->add_node_integers(other._node_integer_names, true, &other._node_integer_default_values);
2405 return returnval;
2406}
2407
2408
2409
2410void
2412{
2413 // Now that all the DofObject moving is done, we can move the GhostingFunctor objects
2414 // which include the _default_ghosting,_ghosting_functors and _shared_functors. We also need
2415 // to set the mesh object associated with these functors to the assignee mesh.
2416
2417 // _default_ghosting
2418 _default_ghosting = std::move(other_mesh._default_ghosting);
2419 _default_ghosting->set_mesh(this);
2420
2421 // _ghosting_functors
2422 _ghosting_functors = std::move(other_mesh._ghosting_functors);
2423
2424 for (const auto gf : _ghosting_functors )
2425 {
2426 gf->set_mesh(this);
2427 }
2428
2429 // _shared_functors
2430 _shared_functors = std::move(other_mesh._shared_functors);
2431
2432 for (const auto & sf : _shared_functors )
2433 {
2434 (sf.second)->set_mesh(this);
2435 }
2436
2437 // _constraint_rows
2438 _constraint_rows = std::move(other_mesh._constraint_rows);
2439 _n_constraint_rows = other_mesh._n_constraint_rows;
2440
2441 if (other_mesh.partitioner())
2442 _partitioner = std::move(other_mesh.partitioner());
2443}
2444
2445
2446void
2448{
2449 this->_spatial_dimension = other_mesh._spatial_dimension;
2450 this->_elem_dims = other_mesh._elem_dims;
2451 this->_elem_default_orders = other_mesh._elem_default_orders;
2453 this->_mesh_subdomains = other_mesh._mesh_subdomains;
2454}
2455
2456
2457bool MeshBase::nodes_and_elements_equal(const MeshBase & other_mesh) const
2458{
2459 for (const auto & other_node : other_mesh.node_ptr_range())
2460 {
2461 const Node * node = this->query_node_ptr(other_node->id());
2462 if (!node)
2463 return false;
2464 if (*other_node != *node)
2465 return false;
2466 }
2467 for (const auto & node : this->node_ptr_range())
2468 if (!other_mesh.query_node_ptr(node->id()))
2469 return false;
2470
2471 for (const auto & other_elem : other_mesh.element_ptr_range())
2472 {
2473 const Elem * elem = this->query_elem_ptr(other_elem->id());
2474 if (!elem)
2475 return false;
2476 if (!other_elem->topologically_equal(*elem))
2477 return false;
2478 }
2479 for (const auto & elem : this->element_ptr_range())
2480 if (!other_mesh.query_elem_ptr(elem->id()))
2481 return false;
2482
2483 return true;
2484}
2485
2486
2488{
2489 dof_id_type n_local_rows=0, n_unpartitioned_rows=0;
2490 for (const auto & [node, node_constraints] : _constraint_rows)
2491 {
2492 // Unpartitioned nodes
2493 if (node->processor_id() == DofObject::invalid_processor_id)
2494 n_unpartitioned_rows++;
2495 else if (node->processor_id() == this->processor_id())
2496 n_local_rows++;
2497 }
2498
2499 this->comm().sum(n_local_rows);
2500
2501 return n_unpartitioned_rows + n_local_rows;
2502}
2503
2504
2505void
2507{
2508 LOG_SCOPE("copy_constraint_rows(mesh)", "MeshBase");
2509
2511
2512 _constraint_rows.clear();
2513
2514 const auto & other_constraint_rows = other_mesh.get_constraint_rows();
2515 for (const auto & [other_node, other_node_constraints] : other_constraint_rows)
2516 {
2517 const Node * const our_node = this->node_ptr(other_node->id());
2518 constraint_rows_mapped_type our_node_constraints;
2519 for (const auto & [other_inner_key_pair, constraint_value] : other_node_constraints)
2520 {
2521 const auto & [other_elem, local_node_id] = other_inner_key_pair;
2522 const Elem * const our_elem = this->elem_ptr(other_elem->id());
2523 our_node_constraints.emplace_back(std::make_pair(our_elem, local_node_id), constraint_value);
2524 }
2525 _constraint_rows[our_node] = std::move(our_node_constraints);
2526 }
2527}
2528
2529
2530template <typename T>
2531void
2533 bool precondition_constraint_operator)
2534{
2535 LOG_SCOPE("copy_constraint_rows(mat)", "MeshBase");
2536
2537 this->_constraint_rows.clear();
2538
2539 // We're not going to support doing this distributed yet; it'd be
2540 // pointless unless we temporarily had a linear partitioning to
2541 // better match the constraint operator.
2542 MeshSerializer serialize(*this);
2543
2544 // Our current mesh should already reflect the desired assembly space
2545 libmesh_error_msg_if(this->n_nodes() != constraint_operator.m(),
2546 "Constraint operator matrix with " <<
2547 constraint_operator.m() <<
2548 "rows does not match this mesh with " <<
2549 this->n_nodes() << " nodes");
2550
2551 // First, find what new unconstrained DoFs we need to add. We can't
2552 // iterate over columns in a SparseMatrix, so we'll iterate over
2553 // rows and keep track of columns.
2554
2555 // If we have nodes that will work unconstrained, keep track of
2556 // their node ids and corresponding column indices.
2557 // existing_unconstrained_nodes[column_id] = node_id
2558 std::map<dof_id_type, dof_id_type> existing_unconstrained_columns;
2559 std::set<dof_id_type> existing_unconstrained_nodes;
2560
2561 // In case we need new nodes, keep track of their columns.
2562 // columns[j][k] will be the kth row index and value of column j
2563 typedef
2564 std::unordered_map<dof_id_type,
2565 std::vector<std::pair<dof_id_type, Real>>>
2566 columns_type;
2567 columns_type columns(constraint_operator.n());
2568
2569 // If we need to precondition the constraint operator (e.g. it's an
2570 // unpreconditioned extraction operator for a Flex IGA matrix),
2571 // we'll want to keep track of the sum of each column, because we'll
2572 // be dividing each column by that sum (Jacobi preconditioning on
2573 // the right, which then leads to symmetric preconditioning on a
2574 // physics Jacobian).
2575 std::unordered_map<dof_id_type, Real> column_sums;
2576
2577 // Work in parallel, though we'll have to sync shortly
2578 for (auto i : make_range(constraint_operator.row_start(),
2579 constraint_operator.row_stop()))
2580 {
2581 std::vector<numeric_index_type> indices;
2582 std::vector<T> values;
2583
2584 constraint_operator.get_row(i, indices, values);
2585 libmesh_assert_equal_to(indices.size(), values.size());
2586
2587 if (indices.size() == 1 &&
2588 values[0] == T(1))
2589 {
2590 // If we have multiple simple Ui=Uj constraints, let the
2591 // first one be our "unconstrained" node and let the others
2592 // be constrained to it.
2593 if (existing_unconstrained_columns.find(indices[0]) !=
2594 existing_unconstrained_columns.end())
2595 {
2596 const auto j = indices[0];
2597 columns[j].emplace_back(i, 1);
2598 }
2599 else
2600 {
2601 existing_unconstrained_nodes.insert(i);
2602 existing_unconstrained_columns.emplace(indices[0],i);
2603 }
2604 }
2605 else
2606 for (auto jj : index_range(indices))
2607 {
2608 const auto j = indices[jj];
2609 const Real coef = libmesh_real(values[jj]);
2610 libmesh_assert_equal_to(coef, values[jj]);
2611 columns[j].emplace_back(i, coef);
2612 }
2613 }
2614
2615 // Merge data from different processors' slabs of the matrix
2616 this->comm().set_union(existing_unconstrained_nodes);
2617 this->comm().set_union(existing_unconstrained_columns);
2618
2619 std::vector<columns_type> all_columns;
2620 this->comm().allgather(columns, all_columns);
2621
2622 columns.clear();
2623 for (auto p : index_range(all_columns))
2624 for (auto & [j, subcol] : all_columns[p])
2625 for (auto [i, v] : subcol)
2626 columns[j].emplace_back(i,v);
2627
2628 // Keep track of elements on which unconstrained nodes exist, and
2629 // their local node indices.
2630 // node_to_elem_ptrs[node] = [elem_id, local_node_num]
2631 std::unordered_map<const Node *, std::pair<dof_id_type, unsigned int>> node_to_elem_ptrs;
2632
2633 // Find elements attached to any existing nodes that will stay
2634 // unconstrained. We'll also build a subdomain set here so we don't
2635 // have to assert that the mesh is already prepared before we pick a
2636 // new subdomain for any NodeElems we need to add.
2637 std::set<subdomain_id_type> subdomain_ids;
2638 for (const Elem * elem : this->element_ptr_range())
2639 {
2640 subdomain_ids.insert(elem->subdomain_id());
2641 for (auto n : make_range(elem->n_nodes()))
2642 {
2643 const Node * node = elem->node_ptr(n);
2644 if (existing_unconstrained_nodes.count(node->id()))
2645 node_to_elem_ptrs.emplace(node, std::make_pair(elem->id(), n));
2646 }
2647 }
2648
2649 const subdomain_id_type new_sbd_id = *subdomain_ids.rbegin() + 1;
2650
2651 for (auto j : make_range(constraint_operator.n()))
2652 {
2653 // If we already have a good node for this then we're done
2654 if (existing_unconstrained_columns.count(j))
2655 continue;
2656
2657 // Get a half-decent spot to place a new NodeElem for
2658 // unconstrained DoF(s) here. Getting a *fully*-decent spot
2659 // would require finding a Moore-Penrose pseudoinverse, and I'm
2660 // not going to do that, but scaling a transpose will at least
2661 // get us a little uniqueness to make visualization reasonable.
2662 Point newpt;
2663 Real total_scaling = 0;
2664 unsigned int total_entries = 0;
2665
2666 // We'll get a decent initial pid choice here too, if only to
2667 // aid in later repartitioning.
2668 std::map<processor_id_type, int> pids;
2669
2670 auto & column = columns[j];
2671 for (auto [i, r] : column)
2672 {
2673 Node & constrained_node = this->node_ref(i);
2674 const Point constrained_pt = constrained_node;
2675 newpt += r*constrained_pt;
2676 total_scaling += r;
2677 ++total_entries;
2678 ++pids[constrained_node.processor_id()];
2679 }
2680
2681 if (precondition_constraint_operator)
2682 column_sums[j] = total_scaling;
2683
2684 libmesh_error_msg_if
2685 (!total_entries,
2686 "Empty column " << j <<
2687 " found in constraint operator matrix");
2688
2689 // If we have *cancellation* here then we can end up dividing by
2690 // zero; try just evenly scaling across all constrained node
2691 // points instead.
2692 if (total_scaling > TOLERANCE)
2693 newpt /= total_scaling;
2694 else
2695 newpt /= total_entries;
2696
2697 Node *n = this->add_point(newpt);
2698 std::unique_ptr<Elem> elem = Elem::build(NODEELEM);
2699 elem->set_node(0, n);
2700 elem->subdomain_id() = new_sbd_id;
2701
2702 Elem * added_elem = this->add_elem(std::move(elem));
2703 this->_elem_dims.insert(0);
2704 this->_elem_default_orders.insert(added_elem->default_order());
2706 static_cast<Order>
2707 (std::min(static_cast<int>(this->_supported_nodal_order),
2708 static_cast<int>(added_elem->supported_nodal_order())));
2709 this->_mesh_subdomains.insert(new_sbd_id);
2710 node_to_elem_ptrs.emplace(n, std::make_pair(added_elem->id(), 0));
2711 existing_unconstrained_columns.emplace(j,n->id());
2712
2713 // Repartition the new objects *after* adding them, so a
2714 // DistributedMesh doesn't get confused and think you're not
2715 // adding them on all processors at once.
2716 int n_pids = 0;
2717 for (auto [pid, count] : pids)
2718 if (count >= n_pids)
2719 {
2720 n_pids = count;
2721 added_elem->processor_id() = pid;
2722 n->processor_id() = pid;
2723 }
2724 }
2725
2726 // Calculate constraint rows in an indexed form that's easy for us
2727 // to allgather
2728 std::unordered_map<dof_id_type,
2729 std::vector<std::pair<std::pair<dof_id_type, unsigned int>,Real>>>
2730 indexed_constraint_rows;
2731
2732 for (auto i : make_range(constraint_operator.row_start(),
2733 constraint_operator.row_stop()))
2734 {
2735 if (existing_unconstrained_nodes.count(i))
2736 continue;
2737
2738 std::vector<numeric_index_type> indices;
2739 std::vector<T> values;
2740
2741 constraint_operator.get_row(i, indices, values);
2742
2743 std::vector<std::pair<std::pair<dof_id_type, unsigned int>, Real>> constraint_row;
2744
2745 for (auto jj : index_range(indices))
2746 {
2747 const dof_id_type node_id =
2748 existing_unconstrained_columns[indices[jj]];
2749
2750 Node & constraining_node = this->node_ref(node_id);
2751
2752 libmesh_assert(node_to_elem_ptrs.count(&constraining_node));
2753
2754 auto p = node_to_elem_ptrs[&constraining_node];
2755
2756 Real coef = libmesh_real(values[jj]);
2757 libmesh_assert_equal_to(coef, values[jj]);
2758
2759 // If we're preconditioning and we created a nodeelem then
2760 // we can scale the meaning of that nodeelem's value to give
2761 // us a better-conditioned matrix after the constraints are
2762 // applied.
2763 if (precondition_constraint_operator)
2764 if (auto sum_it = column_sums.find(indices[jj]);
2765 sum_it != column_sums.end())
2766 {
2767 const Real scaling = sum_it->second;
2768
2769 if (scaling > TOLERANCE)
2770 coef /= scaling;
2771 }
2772
2773 constraint_row.emplace_back(std::make_pair(p, coef));
2774 }
2775
2776 indexed_constraint_rows.emplace(i, std::move(constraint_row));
2777 }
2778
2779 this->comm().set_union(indexed_constraint_rows);
2780
2781 // Add constraint rows as mesh constraint rows
2782 for (auto & [node_id, indexed_row] : indexed_constraint_rows)
2783 {
2784 Node * constrained_node = this->node_ptr(node_id);
2785
2786 constraint_rows_mapped_type constraint_row;
2787
2788 for (auto [p, coef] : indexed_row)
2789 {
2790 const Elem * elem = this->elem_ptr(p.first);
2791 constraint_row.emplace_back
2792 (std::make_pair(std::make_pair(elem, p.second), coef));
2793 }
2794
2795 this->_constraint_rows.emplace(constrained_node,
2796 std::move(constraint_row));
2797 }
2798
2800}
2801
2802
2803void MeshBase::print_constraint_rows(std::ostream & os,
2804 bool print_nonlocal) const
2805{
2806 parallel_object_only();
2807
2808 std::string local_constraints =
2809 this->get_local_constraints(print_nonlocal);
2810
2811 if (this->processor_id())
2812 {
2813 this->comm().send(0, local_constraints);
2814 }
2815 else
2816 {
2817 os << "Processor 0:\n";
2818 os << local_constraints;
2819
2820 for (auto p : IntRange<processor_id_type>(1, this->n_processors()))
2821 {
2822 this->comm().receive(p, local_constraints);
2823 os << "Processor " << p << ":\n";
2824 os << local_constraints;
2825 }
2826 }
2827}
2828
2829
2830
2831std::string MeshBase::get_local_constraints(bool print_nonlocal) const
2832{
2833 std::ostringstream os;
2834
2835 if (print_nonlocal)
2836 os << "All ";
2837 else
2838 os << "Local ";
2839
2840 os << "Mesh Constraint Rows:"
2841 << std::endl;
2842
2843 for (const auto & [node, row] : _constraint_rows)
2844 {
2845 const bool local = (node->processor_id() == this->processor_id());
2846
2847 // Skip non-local dofs if requested
2848 if (!print_nonlocal && !local)
2849 continue;
2850
2851 os << "Constraints for " << (local ? "Local" : "Ghost") << " Node " << node->id()
2852 << ": \t";
2853
2854 for (const auto & [elem_and_node, coef] : row)
2855 os << " ((" << elem_and_node.first->id() << ',' << elem_and_node.second << "), " << coef << ")\t";
2856
2857 os << std::endl;
2858 }
2859
2860 return os.str();
2861}
2862
2864 is_partitioned(false),
2865 has_synched_id_counts(false),
2866 has_neighbor_ptrs(false),
2867 has_cached_elem_data(false),
2868 has_interior_parent_ptrs(false),
2869 has_removed_remote_elements(false),
2870 has_removed_orphaned_nodes(false),
2871 has_boundary_id_sets(false),
2872 has_reinit_ghosting_functors(false),
2873 has_synched_subdomain_name_map(false)
2874{}
2875
2876MeshBase::Preparation::operator bool() const
2877{
2878 return is_partitioned &&
2879 has_synched_id_counts &&
2880 has_neighbor_ptrs &&
2881 has_cached_elem_data &&
2882 has_interior_parent_ptrs &&
2883 has_removed_remote_elements &&
2884 has_removed_orphaned_nodes &&
2885 has_reinit_ghosting_functors &&
2886 has_boundary_id_sets &&
2887 has_synched_subdomain_name_map;
2888}
2889
2892{
2893 is_partitioned = set_all;
2894 has_synched_id_counts = set_all;
2895 has_neighbor_ptrs = set_all;
2896 has_cached_elem_data = set_all;
2897 has_interior_parent_ptrs = set_all;
2898 has_removed_remote_elements = set_all;
2899 has_removed_orphaned_nodes = set_all;
2900 has_reinit_ghosting_functors = set_all;
2901 has_boundary_id_sets = set_all;
2902 has_synched_subdomain_name_map = set_all;
2903
2904 return *this;
2905}
2906
2907bool
2909{
2910 if (is_partitioned != other.is_partitioned)
2911 return false;
2912 if (has_synched_id_counts != other.has_synched_id_counts)
2913 return false;
2914 if (has_neighbor_ptrs != other.has_neighbor_ptrs)
2915 return false;
2916 if (has_cached_elem_data != other.has_cached_elem_data)
2917 return false;
2918 if (has_interior_parent_ptrs != other.has_interior_parent_ptrs)
2919 return false;
2920 if (has_removed_remote_elements != other.has_removed_remote_elements)
2921 return false;
2922 if (has_removed_orphaned_nodes != other.has_removed_orphaned_nodes)
2923 return false;
2924 if (has_reinit_ghosting_functors != other.has_reinit_ghosting_functors)
2925 return false;
2926 if (has_boundary_id_sets != other.has_boundary_id_sets)
2927 return false;
2928 if (has_synched_subdomain_name_map != other.has_synched_subdomain_name_map)
2929 return false;
2930
2931 return true;
2932}
2933
2934bool
2936{
2937 return !(*this == other);
2938}
2939
2940
2941// Explicit instantiations for our template function
2942template LIBMESH_EXPORT void
2943MeshBase::copy_constraint_rows(const SparseMatrix<Real> & constraint_operator,
2944 bool precondition_constraint_operator);
2945
2946#ifdef LIBMESH_USE_COMPLEX_NUMBERS
2947template LIBMESH_EXPORT void
2948MeshBase::copy_constraint_rows(const SparseMatrix<Complex> & constraint_operator,
2949 bool precondition_constraint_operator);
2950#endif
2951
2952
2953} // namespace libMesh
void ErrorVector unsigned int
void max(const T &r, T &o, Request &req) const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void min(const T &r, T &o, Request &req) const
void set_union(T &data, const unsigned int root_id) const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
const std::set< boundary_id_type > & get_edge_boundary_ids() const
const std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > & get_edgeset_map() const
const std::multimap< const Node *, boundary_id_type > & get_nodeset_map() const
const std::multimap< const Elem *, std::pair< unsigned short int, boundary_id_type > > & get_sideset_map() const
const std::set< boundary_id_type > & get_node_boundary_ids() const
const std::set< boundary_id_type > & get_side_boundary_ids() const
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
const std::map< boundary_id_type, std::string > & get_edgeset_name_map() const
const std::map< boundary_id_type, std::string > & get_nodeset_name_map() const
const std::map< boundary_id_type, std::string > & get_sideset_name_map() const
Defines a Cartesian bounding box by the two corner extremum.
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition dof_object.h:55
processor_id_type processor_id() const
Definition dof_object.h:895
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
dof_id_type id() const
Definition dof_object.h:833
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484
Helper for building element sides that minimizes the construction of new elements.
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual BoundingBox loose_bounding_box() const
Definition elem.C:3901
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
Definition elem.h:2803
virtual Order default_order() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
virtual Order supported_nodal_order() const
Definition elem.h:1103
static constexpr subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition elem.h:246
virtual unsigned short dim() const =0
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i)=0
virtual Real volume() const
Definition elem.C:3865
virtual ElemType type() const =0
This class implements the original default geometry ghosting requirements in libMesh: point neighbors...
This abstract base class defines the interface by which library code and user code can report associa...
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition int_range.h:54
This is the MeshBase class.
Definition mesh_base.h:81
void set_subdomain_name(subdomain_id_type id, const std::string &name, bool synchronous=false)
Sets the name for the provided id.
Definition mesh_base.C:1929
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:742
virtual bool is_serial() const
Definition mesh_base.h:357
void size_elem_extra_integers()
Size extra-integer arrays of all elements in the mesh.
Definition mesh_base.C:2376
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
void set_spatial_dimension(unsigned char d)
Sets the "spatial dimension" of the Mesh.
Definition mesh_base.C:613
Preparation preparation() const
Definition mesh_base.h:213
bool is_prepared() const
Definition mesh_base.C:1065
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each partitioning.
Definition mesh_base.h:165
bool allow_renumbering() const
Definition mesh_base.h:1360
virtual const Node * node_ptr(const dof_id_type i) const =0
MeshBase::elemset_type _all_elemset_ids
Definition mesh_base.h:2371
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition mesh_base.C:64
unsigned int mesh_dimension() const
Definition mesh_base.C:435
bool _allow_node_and_elem_unique_id_overlap
The Exodus reader (and potentially other readers in the future?) now supports setting Node and Elem u...
Definition mesh_base.h:2313
virtual dof_id_type n_elem() const =0
virtual bool is_replicated() const
Definition mesh_base.h:379
void complete_preparation()
Definition mesh_base.C:874
bool _skip_detect_interior_parents
If this is true then we will skip detect_interior_parents in prepare_for_use.
Definition mesh_base.h:2292
bool operator==(const MeshBase &other_mesh) const
This tests for exactly-equal data in all the senses that a mathematician would care about (element co...
Definition mesh_base.C:274
void set_elem_dimensions(std::set< unsigned char > elem_dims)
Most of the time you should not need to call this, as the element dimensions will be set automaticall...
Definition mesh_base.C:444
const std::set< unsigned char > & elem_dimensions() const
Definition mesh_base.h:2650
void print_constraint_rows(std::ostream &os=libMesh::out, bool print_nonlocal=false) const
Prints (from processor 0) all mesh constraint rows.
Definition mesh_base.C:2803
bool skip_partitioning() const
Definition mesh_base.h:1435
Order _supported_nodal_order
We cache the maximum nodal order supported by all the mesh's elements (the minimum supported_nodal_or...
Definition mesh_base.h:2340
void subdomain_ids(std::set< subdomain_id_type > &ids, const bool global=true) const
Constructs a list of all subdomain identifiers in the local mesh if global == false,...
Definition mesh_base.C:1127
unsigned int recalculate_n_partitions()
In a few (very rare) cases, the user may have manually tagged the elements with specific processor ID...
Definition mesh_base.C:1828
virtual void renumber_nodes_and_elements()=0
After partitioning a mesh it is useful to renumber the nodes and elements so that they lie in contigu...
void set_point_locator_close_to_point_tol(Real val)
Set value used by PointLocatorBase::close_to_point_tol().
Definition mesh_base.C:2355
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1243
bool has_node_integer(std::string_view name) const
Definition mesh_base.C:790
PeriodicBoundaries * get_disjoint_neighbor_boundary_pairs()
Definition mesh_base.C:2311
void change_elemset_id(elemset_id_type old_id, elemset_id_type new_id)
Replace elemset id "old_id" with "new_id".
Definition mesh_base.C:570
unsigned int get_elem_integer_index(std::string_view name) const
Definition mesh_base.C:689
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1930
subdomain_id_type n_local_subdomains() const
Definition mesh_base.C:1205
void all_second_order(const bool full_ordered=true)
Calls the range-based version of this function with a range consisting of all elements in the mesh.
Definition mesh_base.C:1818
virtual void delete_node(Node *n)=0
Removes the Node n from the mesh.
unsigned int get_node_integer_index(std::string_view name) const
Definition mesh_base.C:778
std::map< dof_id_type, const MeshBase::elemset_type * > _elemset_codes
Map from "element set code" to list of set ids to which that element belongs (and vice-versa).
Definition mesh_base.h:2369
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
Definition mesh_base.C:502
dof_id_type n_sub_elem() const
Definition mesh_base.C:1252
const ConstElemRange & active_local_element_stored_range() const
Definition mesh_base.C:1969
virtual void redistribute()
Redistribute elements between processors.
Definition mesh_base.C:1169
const ElemRange & element_stored_range()
Definition mesh_base.C:1954
std::unique_ptr< PeriodicBoundaries > _disjoint_neighbor_boundary_pairs
The disjoint neighbor boundary id pairs.
Definition mesh_base.h:2131
std::vector< unsigned int > add_node_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each node in the mesh.
Definition mesh_base.C:735
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition mesh_base.h:2377
virtual ~MeshBase()
Destructor.
Definition mesh_base.C:426
std::map< MeshBase::elemset_type, dof_id_type > _elemset_codes_inverse_map
Definition mesh_base.h:2370
bool _count_lower_dim_elems_in_point_locator
Do we count lower dimensional elements in point locator refinement? This is relevant in tree-based po...
Definition mesh_base.h:2243
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
Definition mesh_base.C:1264
bool _allow_remote_element_removal
If this is false then even on DistributedMesh remote elements will not be deleted during mesh prepara...
Definition mesh_base.h:2300
unsigned int add_node_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each node in the mesh.
Definition mesh_base.C:712
void change_elemset_code(dof_id_type old_code, dof_id_type new_code)
Replace elemset code "old_code" with "new_code".
Definition mesh_base.C:517
std::vector< dof_id_type > get_elemset_codes() const
Return a vector of all elemset codes defined on the mesh.
Definition mesh_base.C:508
virtual dof_id_type n_nodes() const =0
std::vector< dof_id_type > _node_integer_default_values
The array of default initialization values for integer data associated with each node in the mesh.
Definition mesh_base.h:2401
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition mesh_base.h:2257
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition mesh_base.h:2282
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition mesh_base.C:1101
virtual const Node * query_node_ptr(const dof_id_type i) const =0
std::vector< std::pair< std::pair< const Elem *, unsigned int >, Real > > constraint_rows_mapped_type
Definition mesh_base.h:1933
virtual void all_second_order_range(const SimpleRange< element_iterator > &range, const bool full_ordered=true)=0
Converts a set of this Mesh's elements defined by range from FIRST order to SECOND order.
GhostingFunctorIterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition mesh_base.h:1476
void unset_has_synched_subdomain_name_map()
Tells this we have done some operation which may have left the subdomain id to name map inconsistent ...
Definition mesh_base.h:350
std::map< GhostingFunctor *, std::shared_ptr< GhostingFunctor > > _shared_functors
Hang on to references to any GhostingFunctor objects we were passed in shared_ptr form.
Definition mesh_base.h:2442
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
std::set< subdomain_id_type > _mesh_subdomains
We cache the subdomain ids of the elements present in the mesh.
Definition mesh_base.h:2345
dof_id_type n_unpartitioned_elem() const
Definition mesh_base.h:700
virtual void update_post_partitioning()
Recalculate any cached data (or invalidate any caches that are computed on the fly) after elements an...
Definition mesh_base.C:1181
bool get_count_lower_dim_elems_in_point_locator() const
Get the current value of _count_lower_dim_elems_in_point_locator.
Definition mesh_base.C:1895
std::unique_ptr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition mesh_base.h:2237
virtual const Elem * elem_ptr(const dof_id_type i) const =0
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh.
Definition mesh_base.C:623
bool _skip_all_partitioning
If this is true then no partitioning should be done.
Definition mesh_base.h:2275
virtual void all_complete_order_range(const SimpleRange< element_iterator > &range)=0
Converts a set of elements in this (conforming, non-refined) mesh into "complete" order elements,...
std::vector< std::string > _elem_integer_names
The array of names for integer data associated with each element in the mesh.
Definition mesh_base.h:2383
void prepare_for_use()
Definition mesh_base.C:860
std::vector< dof_id_type > _elem_integer_default_values
The array of default initialization values for integer data associated with each element in the mesh.
Definition mesh_base.h:2389
void remove_orphaned_nodes()
Removes any orphaned nodes, nodes not connected to any elements.
Definition mesh_base.C:801
Real get_point_locator_close_to_point_tol() const
Definition mesh_base.C:2369
unsigned int n_partitions() const
Definition mesh_base.h:1530
bool has_elem_integer(std::string_view name) const
Definition mesh_base.C:701
dof_id_type n_local_elem() const
Definition mesh_base.h:694
dof_id_type n_unpartitioned_nodes() const
Definition mesh_base.h:594
bool _skip_noncritical_partitioning
If this is true then no partitioning should be done with the possible exception of orphaned nodes.
Definition mesh_base.h:2270
bool _skip_find_neighbors
If this is true then we will skip find_neighbors in prepare_for_use.
Definition mesh_base.h:2287
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1230
virtual void delete_remote_elements()
When supported, deletes all nonlocal elements of the mesh except for "ghosts" which touch a local ele...
Definition mesh_base.h:399
MeshBase & operator=(const MeshBase &)=delete
Copy and move assignment are not allowed because MeshBase subclasses manually manage memory (Elems an...
ElemMappingType _default_mapping_type
The default mapping type (typically Lagrange) between master and physical space to assign to newly ad...
Definition mesh_base.h:2195
std::unique_ptr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition mesh_base.h:2143
std::set< Order > _elem_default_orders
We cache the (default) order of the geometric elements present in the mesh.
Definition mesh_base.h:2334
bool skip_noncritical_partitioning() const
Definition mesh_base.h:1418
MeshBase * _interior_mesh
Defaulting to this, a pointer to the mesh used to generate boundary elements on this.
Definition mesh_base.h:2264
std::vector< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition mesh_base.h:2436
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition mesh_base.C:1036
std::pair< std::vector< unsigned int >, std::vector< unsigned int > > merge_extra_integer_names(const MeshBase &other)
Merge extra-integer arrays from an other mesh.
Definition mesh_base.C:2400
dof_id_type n_local_nodes() const
Definition mesh_base.h:588
std::unique_ptr< ConstElemRange > _const_active_local_element_stored_range
A cached ConstElemRange for threaded calculation on all local elements of this mesh.
Definition mesh_base.h:2228
std::map< subdomain_id_type, std::string > _block_id_to_name
This structure maintains the mapping of named blocks for file formats that support named blocks.
Definition mesh_base.h:2320
virtual bool subclass_locally_equals(const MeshBase &other_mesh) const =0
Shim to allow operator == (&) to behave like a virtual function without having to be one.
constraint_rows_type _constraint_rows
Definition mesh_base.h:2454
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition mesh_base.h:2251
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(),...
Definition mesh_base.C:487
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
Definition mesh_base.h:1940
const MeshBase & interior_mesh() const
Definition mesh_base.h:2053
std::unique_ptr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior.
Definition mesh_base.h:2427
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set.
Definition mesh_base.C:461
unsigned char _default_mapping_data
The default mapping data (unused with Lagrange, used for nodal weight lookup index with rational base...
Definition mesh_base.h:2202
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual void all_complete_order()
Calls the range-based version of this function with a range consisting of all elements in the mesh.
Definition mesh_base.C:1823
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
Real _point_locator_close_to_point_tol
If nonzero, we will call PointLocatorBase::set_close_to_point_tol() on any PointLocators that we crea...
Definition mesh_base.h:2467
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition mesh_base.C:1217
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true, const bool assert_valid=true, const bool check_non_remote=true)=0
Locate element face (edge in 2D) neighbors.
std::string & subdomain_name(subdomain_id_type id)
Definition mesh_base.C:1902
bool allow_find_neighbors() const
Definition mesh_base.h:1367
void sync_subdomain_name_map()
libMesh often expects all processors to know about names of all subdomain ids, but distributed mesh g...
Definition mesh_base.C:2081
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:785
dof_id_type _n_constraint_rows
Definition mesh_base.h:2456
void size_node_extra_integers()
Size extra-integer arrays of all nodes in the mesh.
Definition mesh_base.C:2391
unsigned int _n_parts
The number of partitions the mesh has.
Definition mesh_base.h:2189
std::map< const Node *, constraint_rows_mapped_type > constraint_rows_type
Definition mesh_base.h:1934
void get_elemsets(dof_id_type elemset_code, MeshBase::elemset_type &id_set_to_fill) const
Look up the element sets for a given elemset code and vice-versa.
Definition mesh_base.C:492
void remove_disjoint_boundary_pair(const boundary_id_type b1, const boundary_id_type b2)
Definition mesh_base.C:2321
void clear_point_locator()
Releases the current PointLocator object.
Definition mesh_base.C:1881
GhostingFunctorIterator ghosting_functors_end() const
End of range of ghosting functors.
Definition mesh_base.h:1482
void set_count_lower_dim_elems_in_point_locator(bool count_lower_dim_elems)
In the point locator, do we count lower dimensional elements when we refine point locator regions?...
Definition mesh_base.C:1888
void add_ghosting_functor(GhostingFunctor &ghosting_functor)
Adds a functor which can specify ghosting requirements for use on distributed meshes.
Definition mesh_base.C:1079
void copy_constraint_rows(const MeshBase &other_mesh)
Copy the constraints from the other mesh to this mesh.
Definition mesh_base.C:2506
std::set< elemset_id_type > elemset_type
Typedef for the "set" container used to store elemset ids.
Definition mesh_base.h:463
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition mesh_base.h:2327
std::vector< unsigned int > add_elem_integers(const std::vector< std::string > &names, bool allocate_data=true, const std::vector< dof_id_type > *default_values=nullptr)
Register integer data (of type dof_id_type) to be added to each element in the mesh,...
Definition mesh_base.C:646
std::vector< std::string > _node_integer_names
The array of names for integer data associated with each node in the mesh.
Definition mesh_base.h:2395
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition mesh_base.C:1848
void add_disjoint_neighbor_boundary_pairs(const boundary_id_type b1, const boundary_id_type b2, const RealVectorValue &translation)
Register a pair of boundaries as disjoint neighbor boundary pairs.
Definition mesh_base.C:2287
subdomain_id_type get_id_by_name(std::string_view name) const
Definition mesh_base.C:1941
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1770
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
bool locally_equals(const MeshBase &other_mesh) const
This behaves the same as operator==, but only for the local and ghosted aspects of the mesh; i....
Definition mesh_base.C:284
dof_id_type count_constraint_rows()
Helper function for subclasses to use to set _n_constraint_rows.
Definition mesh_base.C:2487
virtual dof_id_type n_active_elem() const =0
void reinit_ghosting_functors()
Loops over ghosting functors and calls mesh_reinit()
Definition mesh_base.C:1025
Preparation _preparation
Flags indicating in what ways this mesh has been prepared.
Definition mesh_base.h:2207
subdomain_id_type n_subdomains() const
Definition mesh_base.C:1191
std::string get_info(const unsigned int verbosity=0, const bool global=true) const
Definition mesh_base.C:1276
std::string get_local_constraints(bool print_nonlocal=false) const
Gets a string reporting all mesh constraint rows local to this processor.
Definition mesh_base.C:2831
bool nodes_and_elements_equal(const MeshBase &other_mesh) const
Tests for equality of all elements and nodes in the mesh.
Definition mesh_base.C:2457
void copy_cached_data(const MeshBase &other_mesh)
Helper class to copy cached data, to synchronize with a possibly unprepared other_mesh.
Definition mesh_base.C:2447
void unset_is_prepared()
Tells this we have done some operation where we should no longer consider ourself prepared.
Definition mesh_base.C:1071
void post_dofobject_moves(MeshBase &&other_mesh)
Moves any superclass data (e.g.
Definition mesh_base.C:2411
void detect_interior_parents()
Search the mesh for elements that have a neighboring element of dim+1 and set that element as the int...
Definition mesh_base.C:2092
void clear_stored_ranges()
Clears stored ranges, to indicate that the mesh has changed and they should be regenerated when next ...
Definition mesh_base.C:1984
std::unique_ptr< ElemRange > _element_stored_range
A cached ElemRange for threaded mutation of all semilocal elements of this mesh.
Definition mesh_base.h:2217
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
A Node is like a Point, but with more information.
Definition node.h:55
An object whose state is distributed along a set of processors.
processor_id_type processor_id() const
ParallelObject & operator=(const ParallelObject &libmesh_dbg_var(other))
"Assignment" operator.
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
We're using a class instead of a typedef to allow forward declarations and future flexibility.
boundary_id_type myboundary
The boundary ID of this boundary and its counterpart.
The definition of a periodic boundary.
virtual std::unique_ptr< PeriodicBoundaryBase > clone(TransformationType t=FORWARD) const override
If we want the DofMap to be able to make copies of references and store them in the underlying map,...
static std::unique_ptr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=nullptr)
Builds an PointLocator for the mesh mesh.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
Generic sparse matrix.
virtual void get_row(numeric_index_type i, std::vector< numeric_index_type > &indices, std::vector< T > &values) const =0
Get a row from the matrix.
virtual numeric_index_type n() const =0
virtual numeric_index_type row_stop() const =0
virtual numeric_index_type m() const =0
virtual numeric_index_type row_start() const =0
The StoredRange class defines a contiguous, divisible set of objects.
Dummy "splitting object" used to distinguish splitting constructors from copy constructors.
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
A function for verifying that unique ids match across processors.
libMesh::BoundingBox create_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:566
libMesh::BoundingBox create_local_bounding_box(const MeshBase &mesh)
Definition mesh_tools.C:631
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
void libmesh_assert_valid_constraint_rows(const MeshBase &mesh)
A function for verifying that all mesh constraint rows express relations between nodes and elements t...
void correct_node_proc_ids(MeshBase &)
Changes the processor ids on each node so be the same as the id of the lowest element touching that n...
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!...
Definition threads.C:33
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided reduction operation in parallel on the specified range.
void parallel_for(const Range &range, const Body &body, unsigned int n_threads=libMesh::n_threads())
Execute the provided function object in parallel on the specified range.
std::string enum_to_string(const T e)
The libMesh namespace provides an interface to certain functionality in the library.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Helper function that allows us to treat a homogenous pair as a range.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
bool closed()
Checks that the library has been closed.
Definition libmesh.C:331
ElemType
Defines an enum for geometric element types.
int8_t boundary_id_type
Definition id_types.h:51
libmesh_assert(ctx)
std::ostream & operator<<(std::ostream &os, const OrderWrapper &order)
Overload stream operators.
Definition fe_type.h:182
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
LIBMESH_DEVICE_INLINE T libmesh_real(T a)
bool initialized()
Checks that library initialization has been done.
Definition libmesh.C:324
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
bool on_command_line(std::string arg)
Definition libmesh.C:934
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176
unsigned int n_threads()
Flags indicating in what ways a mesh has been prepared for use.
Definition mesh_base.h:2092
bool operator!=(const Preparation &other) const
Definition mesh_base.C:2935
Preparation & operator=(bool set_all)
Set all flags to the "set_all" value.
Definition mesh_base.C:2891
bool operator==(const Preparation &other) const
Two Preparation objects are equivalent iff all the flags match, regardless of the true/false status o...
Definition mesh_base.C:2908