libMesh
Loading...
Searching...
No Matches
distributed_mesh.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 it 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// Local includes
21#include "libmesh/distributed_mesh.h"
22
23// libMesh includes
24#include "libmesh/boundary_info.h"
25#include "libmesh/elem.h"
26#include "libmesh/libmesh_logging.h"
27#include "libmesh/mesh_communication.h"
28#include "libmesh/mesh_tools.h"
29#include "libmesh/partitioner.h"
30#include "libmesh/string_to_enum.h"
31
32// TIMPI includes
34#include "timpi/parallel_sync.h"
35
36
37namespace libMesh
38{
39
40// ------------------------------------------------------------
41// DistributedMesh class member functions
43 unsigned char d) :
44 UnstructuredMesh (comm_in,d), _is_serial(true),
45 _is_serial_on_proc_0(true),
46 _deleted_coarse_elements(false),
47 _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0),
48 _next_free_local_node_id(this->processor_id()),
49 _next_free_local_elem_id(this->processor_id()),
50 _next_free_unpartitioned_node_id(this->n_processors()),
51 _next_free_unpartitioned_elem_id(this->n_processors())
52#ifdef LIBMESH_ENABLE_UNIQUE_ID
53 , _next_unpartitioned_unique_id(this->n_processors())
54#endif
55{
56#ifdef LIBMESH_ENABLE_UNIQUE_ID
58#endif
59
60 const std::string default_partitioner = "parmetis";
61 const std::string my_partitioner =
62 libMesh::command_line_value("--default-partitioner",
63 default_partitioner);
65 (Utility::string_to_enum<PartitionerType>(my_partitioner));
66}
67
69{
70 LOG_SCOPE("operator=(&&)", "DistributedMesh");
71
72 // Move assign as an UnstructuredMesh.
73 this->UnstructuredMesh::operator=(std::move(other_mesh));
74
75 // Nodes and elements belong to DistributedMesh and have to be
76 // moved before we can move arbitrary GhostingFunctor, Partitioner,
77 // etc. subclasses.
78 this->move_nodes_and_elements(std::move(other_mesh));
79
80 // But move_nodes_and_elems misses (or guesses about) some of our
81 // subclass values, and we want more precision than a guess.
82 _deleted_coarse_elements = other_mesh._deleted_coarse_elements;
83 _extra_ghost_elems = std::move(other_mesh._extra_ghost_elems);
84
85 // Handle remaining MeshBase moves.
86 this->post_dofobject_moves(std::move(other_mesh));
87
88 return *this;
89}
90
92{
93 *this = std::move(cast_ref<DistributedMesh&>(other_mesh));
94
95 return *this;
96}
97
98std::string_view DistributedMesh::subclass_first_difference_from (const MeshBase & other_mesh_base) const
99{
100 const DistributedMesh * dist_mesh_ptr =
101 dynamic_cast<const DistributedMesh *>(&other_mesh_base);
102 if (!dist_mesh_ptr)
103 return "DistributedMesh class";
104 const DistributedMesh & other_mesh = *dist_mesh_ptr;
105
106#define CHECK_MEMBER(member_name) \
107 if (member_name != other_mesh.member_name) \
108 return #member_name;
109
110 CHECK_MEMBER(_is_serial);
111 CHECK_MEMBER(_is_serial_on_proc_0);
112 CHECK_MEMBER(_deleted_coarse_elements);
113 CHECK_MEMBER(_n_nodes);
114 CHECK_MEMBER(_n_elem);
115 CHECK_MEMBER(_max_node_id);
116 CHECK_MEMBER(_max_elem_id);
117 // We expect these things to change in a prepare_for_use();
118 // they're conceptually "mutable"...
119/*
120 CHECK_MEMBER(_next_free_local_node_id);
121 CHECK_MEMBER(_next_free_local_elem_id);
122 CHECK_MEMBER(_next_free_unpartitioned_node_id);
123 CHECK_MEMBER(_next_free_unpartitioned_elem_id);
124#ifdef LIBMESH_ENABLE_UNIQUE_ID
125 CHECK_MEMBER(_next_unpartitioned_unique_id);
126#endif
127*/
128 if (!this->nodes_and_elements_equal(other_mesh))
129 return "nodes and/or elements";
130
131 if (_extra_ghost_elems.size() !=
132 other_mesh._extra_ghost_elems.size())
133 return "_extra_ghost_elems size";
134 for (auto & elem : _extra_ghost_elems)
135 {
136 libmesh_assert(this->query_elem_ptr(elem->id()) == elem);
137 const Elem * other_elem = other_mesh.query_elem_ptr(elem->id());
138 if (!other_elem ||
139 !other_mesh._extra_ghost_elems.count(const_cast<Elem *>(other_elem)))
140 return "_extra_ghost_elems entry";
141 }
142
143 return "";
144}
145
147{
148 this->DistributedMesh::clear(); // Free nodes and elements
149}
150
151
152// This might be specialized later, but right now it's just here to
153// make sure the compiler doesn't give us a default (non-deep) copy
154// constructor instead.
156 DistributedMesh(static_cast<const MeshBase &>(other_mesh),
157 /*bool other_is_distributed_type=*/true)
158{
161 other_mesh._next_free_local_node_id;
163 other_mesh._next_free_local_elem_id;
168#ifdef LIBMESH_ENABLE_UNIQUE_ID
170 other_mesh._next_unique_id;
173#endif
174
175 // Need to copy extra_ghost_elems
176 for (auto & elem : other_mesh._extra_ghost_elems)
177 _extra_ghost_elems.insert(this->elem_ptr(elem->id()));
178}
179
180
181
182DistributedMesh::DistributedMesh (const MeshBase & other_mesh, bool other_is_distributed_type) :
183 UnstructuredMesh (other_mesh), _is_serial(other_mesh.is_serial()),
184 _is_serial_on_proc_0(other_mesh.is_serial_on_zero()),
185 _deleted_coarse_elements(true), // better safe than sorry...
186 _n_nodes(0), _n_elem(0), _max_node_id(0), _max_elem_id(0), // recomputed below
187 _next_free_local_node_id(this->processor_id()),
188 _next_free_local_elem_id(this->processor_id()),
189 _next_free_unpartitioned_node_id(this->n_processors()),
190 _next_free_unpartitioned_elem_id(this->n_processors())
191{
192 // Just copy, skipping preparation
193 this->copy_nodes_and_elements(other_mesh, true, 0, 0, 0, nullptr, true);
194
195 this->allow_find_neighbors(other_mesh.allow_find_neighbors());
197 this->allow_renumbering(other_mesh.allow_renumbering());
199 this->skip_partitioning(other_mesh.skip_partitioning());
200
201 this->copy_constraint_rows(other_mesh);
202
203 auto & this_boundary_info = this->get_boundary_info();
204 const auto & other_boundary_info = other_mesh.get_boundary_info();
205
206 this_boundary_info = other_boundary_info;
207
208 this->set_subdomain_name_map() = other_mesh.get_subdomain_name_map();
209
210 // add_node()/add_elem() only increment _n_nodes/_n_elem for
211 // nodes/elements they consider locally owned (or unpartitioned), so after
212 // copying only the objects visible to this processor, those counts
213 // reflect an incomplete local view rather than other_mesh's totals,
214 // and need to be copied afresh.
215 _n_nodes = other_mesh.n_nodes();
216 _n_elem = other_mesh.n_elem();
217 _max_node_id = other_mesh.max_node_id();
218 _max_elem_id = other_mesh.max_elem_id();
219
220 // If other_mesh is actually a DistributedMesh, we can just copy its raw
221 // counters directly, mirroring other_mesh's own bookkeeping exactly. This
222 // is done in the DistributedMesh copy constructor.
223 // For any other MeshBase subclass (e.g. ReplicatedMesh) we have no
224 // raw counterpart fields to copy, so derive the free-id-range
225 // counters from _max_elem_id/_max_node_id the same way
226 // update_parallel_id_counts() does via the set_next_ids() method. For
227 // the unique id counters we copy other_mesh's own local next_unique_id()
228 // and derive the next available unique ids
229 // (partitioned and unpartitioned) via set_next_unique_ids().
230 if (!other_is_distributed_type)
231 {
232 this->set_next_ids();
233#ifdef LIBMESH_ENABLE_UNIQUE_ID
234 this->set_next_unique_ids(other_mesh.next_unique_id());
235#endif
236 }
237
238 // Copy other_mesh's actual preparation state, including whatever it
239 // reports for has_synched_id_counts: the counts above are a faithful copy
240 // of other_mesh's own (possibly not-yet-synced) counts, not a freshly
241 // verified computation, so our synced-ness should match other_mesh's.
242 this->_preparation = other_mesh.preparation();
243}
244
246{
247 DistributedMesh & other_mesh = cast_ref<DistributedMesh&>(other_meshbase);
248
249 this->_nodes = std::move(other_mesh._nodes);
250 this->_n_nodes = other_mesh.n_nodes();
251
252 this->_elements = std::move(other_mesh._elements);
253 this->_n_elem = other_mesh.n_elem();
254
255 _is_serial = other_mesh.is_serial();
257 _deleted_coarse_elements = true; // Better safe than sorry
258
259 _max_node_id = other_mesh.max_node_id();
260 _max_elem_id = other_mesh.max_elem_id();
261
266
267 #ifdef LIBMESH_ENABLE_UNIQUE_ID
269 #endif
270}
271
273{
275 ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
276 (this->n_processors() + 1) + this->n_processors();
278 ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
279 (this->n_processors() + 1) + this->processor_id();
280
282 ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
283 (this->n_processors() + 1) + this->n_processors();
285 ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
286 (this->n_processors() + 1) + this->processor_id();
287}
288
289#ifdef LIBMESH_ENABLE_UNIQUE_ID
291{
292 // Unique ids are laid out in repeating groups of (n_processors()+1)
293 // consecutive integers ("alignment" here means a value's position, i.e.
294 // its residue mod (n_processors()+1), within one of these groups). In
295 // every group, the first n_processors() slots (residues 0..n_processors()-1)
296 // are each permanently earmarked for one processor's locally-owned
297 // objects, and the last slot (residue n_processors()) is permanently
298 // earmarked for unpartitioned objects.
299 //
300 // parallel_max_unique_id carries no guarantee of landing on any
301 // particular residue, so rather than simply offsetting it by
302 // processor_id()/n_processors(), we have to explicitly round up to the
303 // start of the next full, entirely-unused group before adding this
304 // processor's (or the unpartitioned pool's) fixed offset into that group.
305 //
306 // (parallel_max_unique_id - 1) / (n_processors()+1) + 1 is the standard
307 // integer idiom for ceil(parallel_max_unique_id / (n_processors()+1)):
308 // the number of complete groups needed to reach at least past the
309 // current max id. Multiplying back by (n_processors()+1) gives the first
310 // id of the next group that is guaranteed to be entirely unused; adding
311 // n_processors(), the unpartitioned pool's fixed offset within a group,
312 // lands on that pool's reserved slot in that group.
314 ((parallel_max_unique_id - 1) / (this->n_processors() + 1) + 1) *
315 (this->n_processors() + 1) +
316 this->n_processors();
317
318 // Same idiom, but shifted by (n_processors()-1) before dividing so that
319 // the rounding accounts for processor_id() possibly being less than the
320 // residue the raw max id already occupies within its group; this can
321 // land this processor's slot in the same group as the unpartitioned
322 // pool's above, or push it into the following group, depending on where
323 // the max id and this processor's offset happen to fall.
325 ((parallel_max_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
326 (this->n_processors() + 1) +
327 this->processor_id();
328}
329#endif
330
331// We use cached values for these so they can be called
332// from one processor without bothering the rest, but
333// we may need to update those caches before doing a full
334// renumbering
336{
337 // This function must be run on all processors at once
338 parallel_object_only();
339
340 _n_elem = this->parallel_n_elem();
341 _n_nodes = this->parallel_n_nodes();
344
345 this->set_next_ids();
346
347 // set_next_unique_ids() needs the true parallel max unique id (not just
348 // this processor's possibly-stale cached _next_unique_id) since the whole
349 // point of this function is to recompute counters that may have drifted
350 // out of sync.
351#ifdef LIBMESH_ENABLE_UNIQUE_ID
353#endif
354
356
358}
359
360
361// Or in debug mode we may want to test the uncached values without
362// changing the cache
364{
365 // This function must be run on all processors at once
366 parallel_object_only();
367
368 dof_id_type n_local = this->n_local_elem();
369 this->comm().sum(n_local);
370 n_local += this->n_unpartitioned_elem();
371 return n_local;
372}
373
374
375
377{
378 // This function must be run on all processors at once
379 parallel_object_only();
380
381 dof_id_type max_local = 0;
382
384 rit = _elements.rbegin();
385
387 rend = _elements.rend();
388
389 // Look for the maximum element id. Search backwards through
390 // elements so we can break out early. Beware of nullptr entries that
391 // haven't yet been cleared from _elements.
392 for (; rit != rend; ++rit)
393 {
394 const DofObject *d = *rit;
395 if (d)
396 {
397 libmesh_assert(_elements[d->id()] == d);
398 max_local = d->id() + 1;
399 break;
400 }
401 }
402
403 this->comm().max(max_local);
404 return max_local;
405}
406
407
408
409#ifdef LIBMESH_ENABLE_UNIQUE_ID
411{
412 // This function must be run on all processors at once
413 parallel_object_only();
414
415 unique_id_type max_local = std::max(_next_unique_id,
417 this->comm().max(max_local);
418 return max_local;
419}
420
421
422
424{
425 _next_unique_id = id;
427 ((_next_unique_id-1) / (this->n_processors() + 1) + 1) *
428 (this->n_processors() + 1) + this->n_processors();
430 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
431 (this->n_processors() + 1) + this->processor_id();
432}
433#endif
434
435
436
438{
439 // This function must be run on all processors at once
440 parallel_object_only();
441
442 dof_id_type n_local = this->n_local_nodes();
443 this->comm().sum(n_local);
444 n_local += this->n_unpartitioned_nodes();
445 return n_local;
446}
447
448
449
451{
452 // This function must be run on all processors at once
453 parallel_object_only();
454
455 dof_id_type max_local = 0;
456
458 rit = _nodes.rbegin();
459
461 rend = _nodes.rend();
462
463 // Look for the maximum node id. Search backwards through
464 // nodes so we can break out early. Beware of nullptr entries that
465 // haven't yet been cleared from _nodes
466 for (; rit != rend; ++rit)
467 {
468 const DofObject *d = *rit;
469 if (d)
470 {
471 libmesh_assert(_nodes[d->id()] == d);
472 max_local = d->id() + 1;
473 break;
474 }
475 }
476
477 this->comm().max(max_local);
478 return max_local;
479}
480
481
482
484{
485 return this->node_ref(i);
486}
487
488
489
491{
493 libmesh_assert_equal_to (_nodes[i]->id(), i);
494
495 return _nodes[i];
496}
497
498
499
500
502{
504 libmesh_assert_equal_to (_nodes[i]->id(), i);
505
506 return _nodes[i];
507}
508
509
510
511
513{
514 if (const auto it = _nodes.find(i);
515 it != _nodes.end())
516 {
517 const Node * n = *it;
518 libmesh_assert (!n || n->id() == i);
519 return n;
520 }
521
522 return nullptr;
523}
524
525
526
527
529{
530 if (auto it = _nodes.find(i);
531 it != _nodes.end())
532 {
533 Node * n = *it;
534 libmesh_assert (!n || n->id() == i);
535 return n;
536 }
537
538 return nullptr;
539}
540
541
542
543
545{
547 libmesh_assert_equal_to (_elements[i]->id(), i);
548
549 return _elements[i];
550}
551
552
553
554
556{
558 libmesh_assert_equal_to (_elements[i]->id(), i);
559
560 return _elements[i];
561}
562
563
564
565
567{
568 if (const auto it = _elements.find(i);
569 it != _elements.end())
570 {
571 const Elem * e = *it;
572 libmesh_assert (!e || e->id() == i);
573 return e;
574 }
575
576 return nullptr;
577}
578
579
580
581
583{
584 if (auto it = _elements.find(i);
585 it != _elements.end())
586 {
587 Elem * e = *it;
588 libmesh_assert (!e || e->id() == i);
589 return e;
590 }
591
592 return nullptr;
593}
594
595
596
597
599{
600 // Don't try to add nullptrs!
602
603 // Trying to add an existing element is a no-op
604 if (e->valid_id() && _elements[e->id()] == e)
605 return e;
606
607 const processor_id_type elem_procid = e->processor_id();
608
609 if (!e->valid_id())
610 {
611 // We should only be creating new ids past the end of the range
612 // of existing ids
613 libmesh_assert_greater_equal(_next_free_unpartitioned_elem_id,
615 libmesh_assert_greater_equal(_next_free_local_elem_id, _max_elem_id);
616
617 // Use the unpartitioned ids for unpartitioned elems, and
618 // temporarily for ghost elems
620 if (elem_procid == this->processor_id())
621 next_id = &_next_free_local_elem_id;
622 e->set_id (*next_id);
623 }
624
625 {
626 // Advance next_ids up high enough that each is pointing to an
627 // unused id and any subsequent increments will still point us
628 // to unused ids
629 _max_elem_id = std::max(_max_elem_id,
630 static_cast<dof_id_type>(e->id()+1));
631
634 ((_max_elem_id-1) / (this->n_processors() + 1) + 1) *
635 (this->n_processors() + 1) + this->n_processors();
638 ((_max_elem_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
639 (this->n_processors() + 1) + this->processor_id();
640
641#ifndef NDEBUG
642 // We need a const dofobject_container so we don't inadvertently create
643 // nullptr entries when testing for non-nullptr ones
644 const dofobject_container<Elem> & const_elements = _elements;
645#endif
648 }
649
650 // Don't try to overwrite existing elems
651 libmesh_assert (!_elements[e->id()]);
652
653 _elements[e->id()] = e;
654
655 // We actually added a new element. Some of our caches might still
656 // be valid, but we should clear the ones which definitely are not.
657 this->clear_point_locator();
658 this->clear_stored_ranges();
659
660 // Try to make the cached elem data more accurate
661 if (elem_procid == this->processor_id() ||
662 elem_procid == DofObject::invalid_processor_id)
663 _n_elem++;
664
665#ifdef LIBMESH_ENABLE_UNIQUE_ID
666 if (!e->valid_unique_id())
667 {
668 if (processor_id() == e->processor_id())
669 {
671 _next_unique_id += this->n_processors() + 1;
672 }
673 else
674 {
677 }
678 }
679 else
680 {
681 _next_unique_id = std::max(_next_unique_id, e->unique_id()+1);
683 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
684 (this->n_processors() + 1) + this->processor_id();
685 }
686#endif
687
688 // Unpartitioned elems should be added on every processor
689 // And shouldn't be added in the same batch as ghost elems
690 // But we might be just adding on processor 0 to
691 // broadcast later
692 // #ifdef DEBUG
693 // if (elem_procid == DofObject::invalid_processor_id)
694 // {
695 // dof_id_type elem_id = e->id();
696 // this->comm().max(elem_id);
697 // libmesh_assert_equal_to (elem_id, e->id());
698 // }
699 // #endif
700
701 // Make sure any new element is given space for any extra integers
702 // we've requested
705
706 // And set mapping type and data on any new element
709
710 return e;
711}
712
713
714
715Elem * DistributedMesh::add_elem (std::unique_ptr<Elem> e)
716{
717 // The mesh now takes ownership of the Elem. Eventually the guts of
718 // add_elem() will get moved to a private helper function, and
719 // calling add_elem() directly will be deprecated.
720 return add_elem(e.release());
721}
722
723
724
726{
727 if (_elements[e->id()])
728 this->delete_elem(_elements[e->id()]);
729
730#ifdef LIBMESH_ENABLE_UNIQUE_ID
731 if (!e->valid_unique_id())
732 {
733 if (processor_id() == e->processor_id())
734 {
736 _next_unique_id += this->n_processors() + 1;
737 }
738 else
739 {
742 }
743 }
744 else
745 {
746 _next_unique_id = std::max(_next_unique_id, e->unique_id()+1);
748 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
749 (this->n_processors() + 1) + this->processor_id();
750 }
751#endif
752
753 // Try to make the cached elem data more accurate
754 processor_id_type elem_procid = e->processor_id();
755 if (elem_procid == this->processor_id() ||
756 elem_procid == DofObject::invalid_processor_id)
757 _n_elem++;
758
759 _elements[e->id()] = e;
760
761 // We actually added a new element. Some of our caches might still
762 // be valid, but we should clear the ones which definitely are not.
763 this->clear_point_locator();
764 this->clear_stored_ranges();
765
766 // Make sure any new element is given space for any extra integers
767 // we've requested
770
771 // And set mapping type and data on any new element
774
775 return e;
776}
777
778Elem * DistributedMesh::insert_elem (std::unique_ptr<Elem> e)
779{
780 // The mesh now takes ownership of the Elem. Eventually the guts of
781 // insert_elem(Elem*) will get moved to a private helper function, and
782 // calling insert_elem(Elem*) directly will be deprecated.
783 return insert_elem(e.release());
784}
785
786
788{
789 libmesh_assert (e);
790
791 // Try to make the cached elem data more accurate
792 _n_elem--;
793
794 // Was this a coarse element, not just a coarsening where we still
795 // have some ancestor structure? Was it a *local* element, that we
796 // might have been depending on as an owner of local nodes? We'll
797 // have to be more careful with our nodes in contract() later; no
798 // telling if we just locally orphaned a node that should be
799 // globally retained.
800 if (e->processor_id() == this->processor_id() &&
801 !e->parent())
803
804 // Delete the element from the BoundaryInfo object
805 this->get_boundary_info().remove(e);
806
807 // But not yet from the container; we might invalidate
808 // an iterator that way!
809
810 //_elements.erase(e->id());
811
812 // Instead, we set it to nullptr for now
813
814 _elements[e->id()] = nullptr;
815
816 // delete the element
817 delete e;
818
819 // Some of our caches might still be valid, but we should clear the
820 // ones which definitely are not.
821 this->clear_point_locator();
822 this->clear_stored_ranges();
823}
824
825
826
828 const dof_id_type new_id)
829{
830 // This could be a no-op
831 if (old_id == new_id)
832 return;
833
834 Elem * el = _elements[old_id];
835 libmesh_assert (el);
836 libmesh_assert_equal_to (el->id(), old_id);
837
838 el->set_id(new_id);
839 libmesh_assert (!_elements[new_id]);
840 _elements[new_id] = el;
841 _elements.erase(old_id);
842
843 // Should we delete any caches here? Our point locator indexes by
844 // element pointer and should be fine with an id change. Our stored
845 // ranges are no longer sorted, which is *probably* fine, but let's
846 // just be safe.
847 this->clear_stored_ranges();
848}
849
850
851
853 const dof_id_type id,
854 const processor_id_type proc_id)
855{
856 Node * old_n = this->query_node_ptr(id);
857
858 if (old_n)
859 {
860 *old_n = p;
861 old_n->processor_id() = proc_id;
862
863 return old_n;
864 }
865
866 Node * n = Node::build(p, id).release();
867 n->processor_id() = proc_id;
868
870}
871
872
874{
875 // This had better be a node in our mesh
876 libmesh_assert(_nodes[n.id()] == &n);
877
878 _nodes[n.id()] = nullptr;
879 _n_nodes--;
880
882 n.processor_id() = this->processor_id();
883
884 this->add_node(&n);
885}
886
887
889{
890 // Don't try to add nullptrs!
892
893 // Trying to add an existing node is a no-op
894 if (n->valid_id() && _nodes[n->id()] == n)
895 return n;
896
897 const processor_id_type node_procid = n->processor_id();
898
899 if (!n->valid_id())
900 {
901 // We should only be creating new ids past the end of the range
902 // of existing ids
903 libmesh_assert_greater_equal(_next_free_unpartitioned_node_id,
905 libmesh_assert_greater_equal(_next_free_local_node_id, _max_node_id);
906
907 // Use the unpartitioned ids for unpartitioned nodes,
908 // and temporarily for ghost nodes
910 if (node_procid == this->processor_id())
911 next_id = &_next_free_local_node_id;
912 n->set_id (*next_id);
913 }
914
915 {
916 // Advance next_ids up high enough that each is pointing to an
917 // unused id and any subsequent increments will still point us
918 // to unused ids
919 _max_node_id = std::max(_max_node_id,
920 static_cast<dof_id_type>(n->id()+1));
921
924 ((_max_node_id-1) / (this->n_processors() + 1) + 1) *
925 (this->n_processors() + 1) + this->n_processors();
928 ((_max_node_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
929 (this->n_processors() + 1) + this->processor_id();
930
931#ifndef NDEBUG
932 // We need a const dofobject_container so we don't inadvertently create
933 // nullptr entries when testing for non-nullptr ones
934 const dofobject_container<Node> & const_nodes = _nodes;
935#endif
938 }
939
940 // Don't try to overwrite existing nodes
941 libmesh_assert (!_nodes[n->id()]);
942
943 _nodes[n->id()] = n;
944
945 // Try to make the cached node data more accurate
946 if (node_procid == this->processor_id() ||
947 node_procid == DofObject::invalid_processor_id)
948 _n_nodes++;
949
950#ifdef LIBMESH_ENABLE_UNIQUE_ID
951 if (!n->valid_unique_id())
952 {
953 if (processor_id() == n->processor_id())
954 {
956 _next_unique_id += this->n_processors() + 1;
957 }
958 else
959 {
962 }
963 }
964 else
965 {
966 _next_unique_id = std::max(_next_unique_id, n->unique_id()+1);
968 ((_next_unique_id + this->n_processors() - 1) / (this->n_processors() + 1) + 1) *
969 (this->n_processors() + 1) + this->processor_id();
970 }
971#endif
972
973 // A new node invalidates any cached node ranges
974 this->clear_stored_ranges();
975
978
979 // Unpartitioned nodes should be added on every processor
980 // And shouldn't be added in the same batch as ghost nodes
981 // But we might be just adding on processor 0 to
982 // broadcast later
983 // #ifdef DEBUG
984 // if (node_procid == DofObject::invalid_processor_id)
985 // {
986 // dof_id_type node_id = n->id();
987 // this->comm().max(node_id);
988 // libmesh_assert_equal_to (node_id, n->id());
989 // }
990 // #endif
991
992 return n;
993}
994
995Node * DistributedMesh::add_node (std::unique_ptr<Node> n)
996{
997 // The mesh now takes ownership of the Node. Eventually the guts of
998 // add_node() will get moved to a private helper function, and
999 // calling add_node() directly will be deprecated.
1000 return add_node(n.release());
1001}
1002
1004{
1005 libmesh_assert(n);
1006 libmesh_assert(_nodes[n->id()]);
1007
1008 // Try to make the cached elem data more accurate
1009 _n_nodes--;
1010
1011 // Delete the node from the BoundaryInfo object
1012 this->get_boundary_info().remove(n);
1013 _constraint_rows.erase(n);
1014
1015 // But not yet from the container; we might invalidate
1016 // an iterator that way!
1017
1018 //_nodes.erase(n->id());
1019
1020 // Instead, we set it to nullptr for now
1021
1022 _nodes[n->id()] = nullptr;
1023
1024 // delete the node
1025 delete n;
1026
1027 // We've invalidated any ranges that contained this node
1028 this->clear_stored_ranges();
1029}
1030
1031
1032
1034 const dof_id_type new_id)
1035{
1036 // This could be a no-op
1037 if (old_id == new_id)
1038 return;
1039
1040 Node * nd = _nodes[old_id];
1041 libmesh_assert (nd);
1042 libmesh_assert_equal_to (nd->id(), old_id);
1043
1044 // If we have nodes shipped to this processor for NodeConstraints
1045 // use, then those nodes will exist in _nodes, but may not be
1046 // locatable via a TopologyMap due to the insufficiency of elements
1047 // connecting to them. If local refinement then wants to create a
1048 // *new* node in the same location, it will initially get a temporary
1049 // id, and then make_node_ids_parallel_consistent() will try to move
1050 // it to the canonical id. We need to account for this case to
1051 // avoid false positives and memory leaks.
1052#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1053 if (_nodes[new_id])
1054 {
1055 libmesh_assert_equal_to (*(Point *)_nodes[new_id],
1056 *(Point *)_nodes[old_id]);
1057 _nodes.erase(new_id);
1058 }
1059#else
1060 // If we aren't shipping nodes for NodeConstraints, there should be
1061 // no reason for renumbering one node onto another.
1062 libmesh_assert (!_nodes[new_id]);
1063#endif
1064 _nodes[new_id] = nd;
1065 nd->set_id(new_id);
1066
1067 _nodes.erase(old_id);
1068}
1069
1070
1071
1073{
1074 // Call parent clear function
1076
1077 // Clear our elements and nodes
1078 // There is no need to remove them from
1079 // the BoundaryInfo data structure since we
1080 // already cleared it.
1082
1083 for (auto & node : _nodes)
1084 delete node;
1085
1086 _nodes.clear();
1087
1088 // We're no longer distributed if we were before
1089 _is_serial = true;
1090 _is_serial_on_proc_0 = true;
1091
1092 // We deleted a ton of coarse elements, but their nodes got deleted too so
1093 // all is copacetic.
1095
1096 // Correct our caches
1097 _n_nodes = 0;
1098 _max_node_id = 0;
1101}
1102
1103
1104
1106{
1107 for (auto & elem : _elements)
1108 delete elem;
1109
1110 _elements.clear();
1111
1112 // Correct our caches
1113 _n_elem = 0;
1114 _max_elem_id = 0;
1117}
1118
1119
1120
1122{
1123 // If this is a truly parallel mesh, go through the redistribution/gather/delete remote steps
1124 if (!this->is_serial())
1125 {
1126 // Construct a MeshCommunication object to actually redistribute the nodes
1127 // and elements according to the partitioner, and then to re-gather the neighbors.
1129 mc.redistribute(*this);
1130
1132
1133 // We communicate valid neighbor links for newly-redistributed
1134 // elements, but we may still have remote_elem links that should
1135 // be corrected but whose correction wasn't communicated.
1136 this->find_neighbors(/*reset_remote_elements*/ false,
1137 /*reset_current_list*/ false /*non-default*/,
1138 /*assert_valid*/ false,
1139 /*check_non_remote*/ false /*non-default!*/);
1140
1141 // Is this necessary? If we are called from prepare_for_use(), this will be called
1142 // anyway... but users can always call partition directly, in which case we do need
1143 // to call delete_remote_elements()...
1144 //
1145 // Regardless of whether it's necessary, it isn't safe. We
1146 // haven't communicated new node processor_ids yet, and we can't
1147 // delete nodes until we do.
1148 // this->delete_remote_elements();
1149 }
1150 else
1151 // The base class can handle non-distributed things, like
1152 // notifying any GhostingFunctors of changes
1154}
1155
1156
1157
1159{
1160 // this->recalculate_n_partitions();
1161
1162 // Let's do the base class cache clearing first, just in case our
1163 // later computations are ever changed to make use of a local
1164 // elements range cache
1166
1167 // Partitioning changes our numbers of unpartitioned objects
1169}
1170
1171
1172
1173template <typename T>
1175{
1176 // This function must be run on all processors at once
1177 parallel_object_only();
1178
1179 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1180 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1181 const dof_id_type pmax_id = std::max(pmax_node_id, pmax_elem_id);
1182
1183 for (dof_id_type i=0; i != pmax_id; ++i)
1184 {
1185 T * obj = objects[i]; // Returns nullptr if there's no map entry
1186
1187 // Local lookups by id should return the requested object
1188 libmesh_assert(!obj || obj->id() == i);
1189
1190 // All processors with an object should agree on id
1191#ifndef NDEBUG
1192 const dof_id_type dofid = obj && obj->valid_id() ?
1193 obj->id() : DofObject::invalid_id;
1194 libmesh_assert(this->comm().semiverify(obj ? &dofid : nullptr));
1195#endif
1196
1197 // All processors with an object should agree on processor id
1198 const dof_id_type procid = obj && obj->valid_processor_id() ?
1199 obj->processor_id() : DofObject::invalid_processor_id;
1200 libmesh_assert(this->comm().semiverify(obj ? &procid : nullptr));
1201
1202 dof_id_type min_procid = procid;
1203 this->comm().min(min_procid);
1204
1205 // Either:
1206 // 1.) I own this elem (min_procid == this->processor_id()) *and* I have a valid pointer to it (obj != nullptr)
1207 // or
1208 // 2.) I don't own this elem (min_procid != this->processor_id()). (In this case I may or may not have a valid pointer to it.)
1209
1210 // Original assert logic
1211 // libmesh_assert (min_procid != this->processor_id() || obj);
1212
1213 // More human-understandable logic...
1215 ((min_procid == this->processor_id()) && obj)
1216 ||
1217 (min_procid != this->processor_id())
1218 );
1219
1220#if defined(LIBMESH_ENABLE_UNIQUE_ID) && !defined(NDEBUG)
1221 // All processors with an object should agree on unique id
1222 const unique_id_type uniqueid = obj ? obj->unique_id() : 0;
1223 libmesh_assert(this->comm().semiverify(obj ? &uniqueid : nullptr));
1224#endif
1225 }
1226}
1227
1228
1229
1235
1236
1237
1239{
1240#ifndef NDEBUG
1241 // This function must be run on all processors at once
1242 parallel_object_only();
1243
1244 dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1245
1246 for (dof_id_type i=0; i != pmax_elem_id; ++i)
1247 {
1248 Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1249
1250 unsigned int p_level = el ? (el->p_level()) : libMesh::invalid_uint;
1251
1252 // All processors with an active element should agree on p level
1253 libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_level : nullptr));
1254 }
1255#endif
1256}
1257
1258
1259
1260
1262{
1263#if defined(LIBMESH_ENABLE_AMR) && !defined(NDEBUG)
1264 // This function must be run on all processors at once
1265 parallel_object_only();
1266
1267 dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1268
1269 for (dof_id_type i=0; i != pmax_elem_id; ++i)
1270 {
1271 Elem * el = _elements[i]; // Returns nullptr if there's no map entry
1272
1273 unsigned int refinement_flag = el ?
1274 static_cast<unsigned int> (el->refinement_flag()) : libMesh::invalid_uint;
1275 unsigned int p_refinement_flag = el ?
1276 static_cast<unsigned int> (el->p_refinement_flag()) : libMesh::invalid_uint;
1277
1278 libmesh_assert(this->comm().semiverify(el ? &refinement_flag : nullptr));
1279
1280 // p refinement flags aren't always kept correct on inactive
1281 // ghost elements
1282 libmesh_assert(this->comm().semiverify((el && el->active()) ? &p_refinement_flag : nullptr));
1283 }
1284#endif // LIBMESH_ENABLE_AMR
1285}
1286
1287
1288
1289template <typename T>
1292{
1293 // This function must be run on all processors at once
1294 parallel_object_only();
1295
1296 typedef typename dofobject_container<T>::veclike_iterator object_iterator;
1297
1298 // In parallel we may not know what objects other processors have.
1299 // Start by figuring out how many
1300 dof_id_type unpartitioned_objects = 0;
1301
1302 std::unordered_map<processor_id_type, dof_id_type>
1303 ghost_objects_from_proc;
1304
1305 object_iterator it = objects.begin();
1306 object_iterator end = objects.end();
1307
1308 while (it != end)
1309 {
1310 T * obj = *it;
1311
1312 // Remove any nullptr container entries while we're here.
1313 if (!obj)
1314 it = objects.erase(it);
1315 else
1316 {
1317 processor_id_type obj_procid = obj->processor_id();
1318 if (obj_procid == DofObject::invalid_processor_id)
1319 unpartitioned_objects++;
1320 else
1321 ghost_objects_from_proc[obj_procid]++;
1322
1323 // Finally, increment the iterator
1324 ++it;
1325 }
1326 }
1327
1328 std::vector<dof_id_type> objects_on_proc(this->n_processors(), 0);
1329 auto this_it = ghost_objects_from_proc.find(this->processor_id());
1330 this->comm().allgather
1331 ((this_it == ghost_objects_from_proc.end()) ?
1332 dof_id_type(0) : this_it->second, objects_on_proc);
1333
1334#ifndef NDEBUG
1335 libmesh_assert(this->comm().verify(unpartitioned_objects));
1336 for (processor_id_type p=0, np=this->n_processors(); p != np; ++p)
1337 if (ghost_objects_from_proc.count(p))
1338 libmesh_assert_less_equal (ghost_objects_from_proc[p], objects_on_proc[p]);
1339 else
1340 libmesh_assert_less_equal (0, objects_on_proc[p]);
1341#endif
1342
1343 // We'll renumber objects in blocks by processor id
1344 std::vector<dof_id_type> first_object_on_proc(this->n_processors());
1345 for (processor_id_type i=1, np=this->n_processors(); i != np; ++i)
1346 first_object_on_proc[i] = first_object_on_proc[i-1] +
1347 objects_on_proc[i-1];
1348 dof_id_type next_id = first_object_on_proc[this->processor_id()];
1349 dof_id_type first_free_id =
1350 first_object_on_proc[this->n_processors()-1] +
1351 objects_on_proc[this->n_processors()-1] +
1352 unpartitioned_objects;
1353
1354 // First set new local object ids and build request sets
1355 // for non-local object ids
1356
1357 // Request sets to send to each processor
1358 std::map<processor_id_type, std::vector<dof_id_type>>
1359 requested_ids;
1360
1361 // We know how many objects live on each processor, so reserve() space for
1362 // each.
1363 auto ghost_end = ghost_objects_from_proc.end();
1364 for (auto p : make_range(this->n_processors()))
1365 if (p != this->processor_id())
1366 {
1367 if (const auto p_it = ghost_objects_from_proc.find(p);
1368 p_it != ghost_end)
1369 requested_ids[p].reserve(p_it->second);
1370 }
1371
1372 end = objects.end();
1373 for (it = objects.begin(); it != end; ++it)
1374 {
1375 T * obj = *it;
1376 if (!obj)
1377 continue;
1378 if (obj->processor_id() == this->processor_id())
1379 obj->set_id(next_id++);
1380 else if (obj->processor_id() != DofObject::invalid_processor_id)
1381 requested_ids[obj->processor_id()].push_back(obj->id());
1382 }
1383
1384 // Next set ghost object ids from other processors
1385
1386 auto gather_functor =
1387 [
1388#ifndef NDEBUG
1389 this,
1390 &first_object_on_proc,
1391 &objects_on_proc,
1392#endif
1393 &objects]
1394 (processor_id_type, const std::vector<dof_id_type> & ids,
1395 std::vector<dof_id_type> & new_ids)
1396 {
1397 std::size_t ids_size = ids.size();
1398 new_ids.resize(ids_size);
1399
1400 for (std::size_t i=0; i != ids_size; ++i)
1401 {
1402 T * obj = objects[ids[i]];
1403 libmesh_assert(obj);
1404 libmesh_assert_equal_to (obj->processor_id(), this->processor_id());
1405 new_ids[i] = obj->id();
1406
1407 libmesh_assert_greater_equal (new_ids[i],
1408 first_object_on_proc[this->processor_id()]);
1409 libmesh_assert_less (new_ids[i],
1410 first_object_on_proc[this->processor_id()] +
1411 objects_on_proc[this->processor_id()]);
1412 }
1413 };
1414
1415 auto action_functor =
1416 [
1417#ifndef NDEBUG
1418 &first_object_on_proc,
1419 &objects_on_proc,
1420#endif
1421 &objects]
1422 (processor_id_type libmesh_dbg_var(pid),
1423 const std::vector<dof_id_type> & ids,
1424 const std::vector<dof_id_type> & data)
1425 {
1426 // Copy the id changes we've now been informed of
1427 for (auto i : index_range(ids))
1428 {
1429 T * obj = objects[ids[i]];
1430 libmesh_assert (obj);
1431 libmesh_assert_equal_to (obj->processor_id(), pid);
1432 libmesh_assert_greater_equal (data[i],
1433 first_object_on_proc[pid]);
1434 libmesh_assert_less (data[i],
1435 first_object_on_proc[pid] +
1436 objects_on_proc[pid]);
1437 obj->set_id(data[i]);
1438 }
1439 };
1440
1441 const dof_id_type * ex = nullptr;
1443 (this->comm(), requested_ids, gather_functor, action_functor, ex);
1444
1445#ifdef LIBMESH_ENABLE_UNIQUE_ID
1446 auto unique_gather_functor =
1447 [
1448#ifndef NDEBUG
1449 this,
1450#endif
1451 &objects]
1452 (processor_id_type, const std::vector<dof_id_type> & ids,
1453 std::vector<unique_id_type> & data)
1454 {
1455 std::size_t ids_size = ids.size();
1456 data.resize(ids_size);
1457
1458 for (std::size_t i=0; i != ids_size; ++i)
1459 {
1460 T * obj = objects[ids[i]];
1461 libmesh_assert(obj);
1462 libmesh_assert_equal_to (obj->processor_id(), this->processor_id());
1463 data[i] = obj->valid_unique_id() ? obj->unique_id() : DofObject::invalid_unique_id;
1464 }
1465 };
1466
1467 auto unique_action_functor =
1468 [&objects]
1469 (processor_id_type libmesh_dbg_var(pid),
1470 const std::vector<dof_id_type> & ids,
1471 const std::vector<unique_id_type> & data)
1472 {
1473 for (auto i : index_range(ids))
1474 {
1475 T * obj = objects[ids[i]];
1476 libmesh_assert (obj);
1477 libmesh_assert_equal_to (obj->processor_id(), pid);
1478 if (!obj->valid_unique_id() && data[i] != DofObject::invalid_unique_id)
1479 obj->set_unique_id(data[i]);
1480 }
1481 };
1482
1483 const unique_id_type * unique_ex = nullptr;
1485 (this->comm(), requested_ids, unique_gather_functor,
1486 unique_action_functor, unique_ex);
1487#endif
1488
1489 // Next set unpartitioned object ids
1490 next_id = 0;
1491 for (auto i : make_range(this->n_processors()))
1492 next_id += objects_on_proc[i];
1493 for (it = objects.begin(); it != end; ++it)
1494 {
1495 T * obj = *it;
1496 if (!obj)
1497 continue;
1498 if (obj->processor_id() == DofObject::invalid_processor_id)
1499 obj->set_id(next_id++);
1500 }
1501
1502 // Finally shuffle around objects so that container indices
1503 // match ids
1504 it = objects.begin();
1505 end = objects.end();
1506 while (it != end)
1507 {
1508 T * obj = *it;
1509 if (obj) // don't try shuffling already-nullptr entries
1510 {
1511 T * next = objects[obj->id()];
1512 // If we have to move this object
1513 if (next != obj)
1514 {
1515 // nullptr out its original position for now
1516 // (our shuffling may put another object there shortly)
1517 *it = nullptr;
1518
1519 // There may already be another object with this id that
1520 // needs to be moved itself
1521 while (next)
1522 {
1523 // We shouldn't be trying to give two objects the
1524 // same id
1525 libmesh_assert_not_equal_to (next->id(), obj->id());
1526 objects[obj->id()] = obj;
1527 obj = next;
1528 next = objects[obj->id()];
1529 }
1530 objects[obj->id()] = obj;
1531 }
1532 }
1533
1534 // Remove any container entries that were left as nullptr.
1535 if (!obj)
1536 it = objects.erase(it);
1537 else
1538 ++it;
1539 }
1540
1541 return first_free_id;
1542}
1543
1544
1546{
1547 parallel_object_only();
1548
1549#ifdef DEBUG
1550 // Make sure our ids and flags are consistent
1554#endif
1555
1556 LOG_SCOPE("renumber_nodes_and_elements()", "DistributedMesh");
1557
1558 // Nodes not connected to any elements, and nullptr node entries
1559 // in our container, should be deleted. But wait! If we've deleted coarse
1560 // local elements on some processor, other processors might have ghosted
1561 // nodes from it that are now no longer connected to any elements on it, but
1562 // that are connected to their own semilocal elements. We'll have to
1563 // communicate to ascertain if that's the case.
1565
1566 // What used nodes do we see on our proc?
1567 std::set<dof_id_type> used_nodes;
1568
1569 // What used node info should we send from our proc? Could we take ownership
1570 // of each node if we needed to?
1571 std::map<processor_id_type, std::map<dof_id_type, bool>>
1572 used_nodes_on_proc;
1573
1574 // flag the nodes we need
1575 for (auto & elem : this->element_ptr_range())
1576 for (const Node & node : elem->node_ref_range())
1577 {
1578 const dof_id_type n = node.id();
1579 used_nodes.insert(n);
1581 {
1582 const processor_id_type p = node.processor_id();
1583 if (p != this->processor_id())
1584 {
1585 auto & used_nodes_on_p = used_nodes_on_proc[p];
1586 if (elem->processor_id() == this->processor_id())
1587 used_nodes_on_p[n] = true;
1588 else
1589 if (!used_nodes_on_p.count(n))
1590 used_nodes_on_p[n] = false;
1591 }
1592 }
1593 }
1594
1596 {
1597 // "unsigned char" == "bool, but MPI::BOOL is iffy to use"
1598 typedef unsigned char boolish;
1599 std::map<processor_id_type, std::vector<std::pair<dof_id_type, boolish>>>
1600 used_nodes_on_proc_vecs;
1601 for (auto & [pid, nodemap] : used_nodes_on_proc)
1602 used_nodes_on_proc_vecs[pid].assign(nodemap.begin(), nodemap.end());
1603
1604 std::map<dof_id_type,processor_id_type> repartitioned_node_pids;
1605 std::map<processor_id_type, std::set<dof_id_type>>
1606 repartitioned_node_sets_to_push;
1607
1608 auto ids_action_functor =
1609 [&used_nodes, &repartitioned_node_pids,
1610 &repartitioned_node_sets_to_push]
1612 const std::vector<std::pair<dof_id_type, boolish>> & ids_and_bools)
1613 {
1614 for (auto [n, sender_could_become_owner] : ids_and_bools)
1615 {
1616 // If we don't see a use for our own node, but someone
1617 // else does, better figure out who should own it next.
1618 if (!used_nodes.count(n))
1619 {
1620 if (auto it = repartitioned_node_pids.find(n);
1621 sender_could_become_owner)
1622 {
1623 if (it != repartitioned_node_pids.end() &&
1624 pid < it->second)
1625 it->second = pid;
1626 else
1627 repartitioned_node_pids[n] = pid;
1628 }
1629 else
1630 if (it == repartitioned_node_pids.end())
1631 repartitioned_node_pids[n] =
1633
1634 repartitioned_node_sets_to_push[pid].insert(n);
1635 }
1636 }
1637 };
1638
1639 // We need two pushes instead of a pull here because we need to
1640 // know *all* the queries for a particular node before we can
1641 // respond to *any* of them.
1643 (this->comm(), used_nodes_on_proc_vecs, ids_action_functor);
1644
1645 // Repartition (what used to be) our own nodes first
1646 for (auto & [n, p] : repartitioned_node_pids)
1647 {
1648 Node & node = this->node_ref(n);
1649 libmesh_assert_equal_to(node.processor_id(), this->processor_id());
1650 libmesh_assert_not_equal_to_msg(p, DofObject::invalid_processor_id, "Node " << n << " is lost?");
1651 node.processor_id() = p;
1652 }
1653
1654 // Then push to repartition others' ghosted copies.
1655
1656 std::map<processor_id_type, std::vector<std::pair<dof_id_type,processor_id_type>>>
1657 repartitioned_node_vecs;
1658
1659 for (auto & [p, nodeset] : repartitioned_node_sets_to_push)
1660 {
1661 auto & rn_vec = repartitioned_node_vecs[p];
1662 for (auto n : nodeset)
1663 rn_vec.emplace_back(n, repartitioned_node_pids[n]);
1664 }
1665
1666 auto repartition_node_functor =
1667 [this]
1668 (processor_id_type libmesh_dbg_var(pid),
1669 const std::vector<std::pair<dof_id_type, processor_id_type>> & ids_and_pids)
1670 {
1671 for (auto [n, p] : ids_and_pids)
1672 {
1673 libmesh_assert_not_equal_to(p, DofObject::invalid_processor_id);
1674 Node & node = this->node_ref(n);
1675 libmesh_assert_equal_to(node.processor_id(), pid);
1676 node.processor_id() = p;
1677 }
1678 };
1679
1681 (this->comm(), repartitioned_node_vecs, repartition_node_functor);
1682 }
1683
1685
1686 // Nodes not connected to any local elements, and nullptr node entries
1687 // in our container, are deleted
1688 {
1689 node_iterator_imp it = _nodes.begin();
1690 node_iterator_imp end = _nodes.end();
1691
1692 while (it != end)
1693 {
1694 Node * nd = *it;
1695 if (!nd)
1696 it = _nodes.erase(it);
1697 else if (!used_nodes.count(nd->id()))
1698 {
1699 // remove any boundary information associated with
1700 // this node
1701 this->get_boundary_info().remove (nd);
1702 _constraint_rows.erase(nd);
1703
1704 // delete the node
1705 delete nd;
1706
1707 it = _nodes.erase(it);
1708 }
1709 else
1710 ++it;
1711 }
1712 }
1713
1715
1717 {
1719 return;
1720 }
1721
1722 // Finally renumber all the elements
1723 _n_elem = this->renumber_dof_objects (this->_elements);
1724
1725 // and all the remaining nodes
1726 _n_nodes = this->renumber_dof_objects (this->_nodes);
1727
1728 // And figure out what IDs we should use when adding new nodes and
1729 // new elements
1731
1732 // We've probably done *some* node removal and/or renumbering; let's
1733 // clear caches to be safe.
1734 this->clear_stored_ranges();
1735
1736 // Make sure our caches are up to date and our
1737 // DofObjects are well packed
1738#ifdef DEBUG
1739 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1740 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1741 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1742 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1743 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1744 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1745 libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1746 libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1747
1748 // Make sure our ids and flags are consistent
1751
1752 // And make sure we've made our numbering monotonic
1754#endif
1755}
1756
1757
1758
1760{
1761 // We can't use range-for here because we need access to the special
1762 // iterators' methods, not just to their dereferenced values.
1763
1764 // Nodes first
1765 for (auto pr = this->_nodes.begin(),
1766 end = this->_nodes.end(); pr != end; ++pr)
1767 {
1768 Node * n = *pr;
1769 if (n != nullptr)
1770 {
1771 const dof_id_type id = pr.index();
1772 n->set_id() = id;
1773 libmesh_assert_equal_to(this->node_ptr(id), n);
1774 }
1775 }
1776
1777 // Elements next
1778 for (auto pr = this->_elements.begin(),
1779 end = this->_elements.end(); pr != end; ++pr)
1780 {
1781 Elem * e = *pr;
1782 if (e != nullptr)
1783 {
1784 const dof_id_type id = pr.index();
1785 e->set_id() = id;
1786 libmesh_assert_equal_to(this->elem_ptr(id), e);
1787 }
1788 }
1789}
1790
1791
1792
1794{
1795 parallel_object_only();
1796
1797 // Get local active elements first
1798 dof_id_type active_elements =
1799 static_cast<dof_id_type>(std::distance (this->active_local_elements_begin(),
1800 this->active_local_elements_end()));
1801 this->comm().sum(active_elements);
1802
1803 // Then add unpartitioned active elements, which should exist on
1804 // every processor
1805 active_elements +=
1806 static_cast<dof_id_type>(std::distance
1807 (this->active_pid_elements_begin(DofObject::invalid_processor_id),
1808 this->active_pid_elements_end(DofObject::invalid_processor_id)));
1809 return active_elements;
1810}
1811
1812
1813
1815{
1816#ifdef DEBUG
1817 // Make sure our neighbor links are all fine
1819
1820 // And our child/parent links, and our flags
1822
1823 // Make sure our ids and flags are consistent
1826
1827 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1828 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1829 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1830 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1831 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1832 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1833#endif
1834
1835 _is_serial = false;
1836 _is_serial_on_proc_0 = false;
1837
1839
1840 libmesh_assert_equal_to (this->max_elem_id(), this->parallel_max_elem_id());
1841
1842 // Now make sure the containers actually shrink - strip
1843 // any newly-created nullptr voids out of the element array
1846 while (e_it != e_end)
1847 if (!*e_it)
1848 e_it = _elements.erase(e_it);
1849 else
1850 ++e_it;
1851
1854 while (n_it != n_end)
1855 if (!*n_it)
1856 n_it = _nodes.erase(n_it);
1857 else
1858 ++n_it;
1859
1860 // We may have deleted no-longer-connected nodes or coarsened-away
1861 // elements; let's update our caches if they're expected to be up to
1862 // date.
1865
1866 // We may have deleted nodes or elements that were the only local
1867 // representatives of some particular boundary id(s); let's update
1868 // those caches if they're expected to be up to date.
1871
1872#ifdef DEBUG
1873 // We might not have well-packed objects if the user didn't allow us
1874 // to renumber
1875 // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1876 // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1877
1878 // Make sure our neighbor links are all fine
1880
1881 // And our child/parent links, and our flags
1883
1884 // Make sure our ids and flags are consistent
1887#endif
1888
1890}
1891
1892
1894{
1895 // First add the elem like normal
1896 add_elem(e);
1897
1898 // Now add it to the set that won't be deleted when we call
1899 // delete_remote_elements()
1900 _extra_ghost_elems.insert(e);
1901}
1902
1903void
1904DistributedMesh::clear_extra_ghost_elems(const std::set<Elem *> & extra_ghost_elems)
1905{
1906 std::set<Elem *> tmp;
1907 std::set_difference(_extra_ghost_elems.begin(), _extra_ghost_elems.end(),
1908 extra_ghost_elems.begin(), extra_ghost_elems.end(),
1909 std::inserter(tmp, tmp.begin()));
1910 _extra_ghost_elems = tmp;
1911}
1912
1914{
1915 if (_is_serial)
1916 return;
1918 _is_serial = true;
1919 _is_serial_on_proc_0 = true;
1920
1921 // Make sure our caches are up to date and our
1922 // DofObjects are well packed
1923#ifdef DEBUG
1924 libmesh_assert_equal_to (this->n_nodes(), this->parallel_n_nodes());
1925 libmesh_assert_equal_to (this->n_elem(), this->parallel_n_elem());
1926 const dof_id_type pmax_node_id = this->parallel_max_node_id();
1927 const dof_id_type pmax_elem_id = this->parallel_max_elem_id();
1928 libmesh_assert_equal_to (this->max_node_id(), pmax_node_id);
1929 libmesh_assert_equal_to (this->max_elem_id(), pmax_elem_id);
1930
1931 // If we've disabled renumbering we can't be sure we're contiguous
1932 // libmesh_assert_equal_to (this->n_nodes(), this->max_node_id());
1933 // libmesh_assert_equal_to (this->n_elem(), this->max_elem_id());
1934
1935 // Make sure our neighbor links are all fine
1937
1938 // Make sure our ids and flags are consistent
1941#endif
1942}
1943
1945{
1947 return;
1948
1949 _is_serial_on_proc_0 = true;
1950 MeshCommunication().gather(0, *this);
1951}
1952
1953
1954} // namespace libMesh
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
void remove(const Node *node)
Removes the boundary conditions associated with node node, if any exist.
The DistributedMesh class is derived from the MeshBase class, and is intended to provide identical fu...
virtual Elem * add_elem(Elem *e) override final
Add elem e to the end of the element array.
virtual void delete_elem(Elem *e) override final
Removes element e from the mesh.
dof_id_type parallel_max_node_id() const
virtual dof_id_type n_active_elem() const override final
virtual dof_id_type n_nodes() const override final
dof_id_type _n_nodes
Cached data from the last renumber_nodes_and_elements call.
virtual const Point & point(const dof_id_type i) const override final
virtual void redistribute() override
Redistribute elements between processors.
dof_id_type renumber_dof_objects(dofobject_container< T > &)
Renumber a parallel objects container.
virtual void fix_broken_node_and_element_numbering() override
There is no reason for a user to ever call this function.
virtual void clear() override
Clear all internal data.
void set_next_ids()
Derives _next_free_local_node_id, _next_free_local_elem_id, _next_free_unpartitioned_node_id,...
dof_id_type _next_free_unpartitioned_node_id
virtual void clear_extra_ghost_elems()
Clears extra ghost elements.
virtual void renumber_elem(dof_id_type old_id, dof_id_type new_id) override final
Changes the id of element old_id, both by changing elem(old_id)->id() and by moving elem(old_id) in t...
virtual const Elem * elem_ptr(const dof_id_type i) const override final
virtual void delete_node(Node *n) override final
Removes the Node n from the mesh.
virtual const Node * query_node_ptr(const dof_id_type i) const override final
void libmesh_assert_valid_parallel_flags() const
Verify refinement_flag and p_refinement_flag consistency of our elements containers.
void libmesh_assert_valid_parallel_p_levels() const
Verify p_level consistency of our elements containers.
void set_next_unique_ids(unique_id_type parallel_max_unique_id)
Derives _next_unique_id and _next_unpartitioned_unique_id from parallel_max_unique_id,...
std::set< Elem * > _extra_ghost_elems
These are extra ghost elements that we want to make sure not to delete when we call delete_remote_ele...
virtual void renumber_nodes_and_elements() override
Remove nullptr elements from arrays.
virtual dof_id_type parallel_n_elem() const override
virtual unique_id_type parallel_max_unique_id() const override
virtual dof_id_type max_node_id() const override final
virtual void set_next_unique_id(unique_id_type id) override
Sets the next available unique id to be used.
virtual bool is_serial() const override final
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) override final
functions for adding /deleting nodes elements.
virtual dof_id_type parallel_n_nodes() const override
const std::set< Elem * > & extra_ghost_elems() const
Const accessor to the ghosted elements.
dof_id_type _next_free_unpartitioned_elem_id
virtual Elem * insert_elem(Elem *e) override final
Insert elem e to the element array, preserving its id and replacing/deleting any existing element wit...
virtual std::string_view subclass_first_difference_from(const MeshBase &other_mesh_base) const override
Shim to allow operator == (&) to behave like a virtual function without having to be one.
DistributedMesh & operator=(const DistributedMesh &)=delete
Copy assignment is not allowed.
virtual dof_id_type max_elem_id() const override final
dofobject_container< Elem > _elements
The elements in the mesh.
processor_id_type pid unsigned int level std::set< subdomain_id_type > ss const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num unsigned char rflag processor_id_type pid const DofMap &dof_map LIBMESH_COMMA unsigned int dof_map LIBMESH_COMMA var_num DECLARE_NODE_ITERATORS(multi_evaluable_, std::vector< const DofMap * > dof_maps, dof_maps) protected dofobject_container< Node > _nodes
Move node and elements from a DistributedMesh.
virtual void clear_elems() override
Clear internal Elem data.
virtual void update_post_partitioning() override
Recalculate cached data after elements and nodes have been repartitioned.
virtual ~DistributedMesh()
Destructor.
virtual bool is_serial_on_zero() const override final
dof_id_type parallel_max_elem_id() const
virtual void delete_remote_elements() override
Deletes all nonlocal elements of the mesh except for "ghosts" which touch a local element,...
dof_id_type _next_free_local_node_id
Guaranteed globally unused IDs for use when adding new nodes or elements.
virtual void add_extra_ghost_elem(Elem *e)
Inserts the element and adds it to a list of elements that should not get deleted or have their desce...
bool _is_serial
A boolean remembering whether we're serialized or not.
bool _deleted_coarse_elements
A boolean remembering whether we've recently deleted top-level elements or not.
DistributedMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
virtual void own_node(Node &n) override final
Takes ownership of node n on this partition of a distributed mesh, by setting n.processor_id() to thi...
virtual dof_id_type n_elem() const override final
virtual void update_parallel_id_counts() override
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors.
virtual void libmesh_assert_valid_parallel_ids() const override
Verify id and processor_id consistency of our elements and nodes containers.
virtual const Elem * query_elem_ptr(const dof_id_type i) const override final
unique_id_type _next_unpartitioned_unique_id
The next available unique id for assigning ids to unpartitioned DOF objects.
virtual void gather_to_zero() override
Gathers all elements and nodes of the mesh onto processor zero.
virtual void allgather() override
Gathers all elements and nodes of the mesh onto every processor.
virtual void renumber_node(dof_id_type old_id, dof_id_type new_id) override final
Changes the id of node old_id, both by changing node(old_id)->id() and by moving node(old_id) in the ...
void libmesh_assert_valid_parallel_object_ids(const dofobject_container< T > &) const
Verify id, processor_id, and if applicable unique_id consistency of a parallel objects container.
bool _is_serial_on_proc_0
A boolean remembering whether we're serialized to proc 0 or not.
virtual Node * add_node(Node *n) override final
Add Node n to the end of the vertex array.
virtual MeshBase & assign(MeshBase &&other_mesh) override
Shim to call the move assignment operator for this class.
virtual const Node * node_ptr(const dof_id_type i) const override final
virtual void clear() override
Free all new memory associated with the object, but restore its original state, with the mesh pointer...
Definition dof_map.C:892
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition dof_object.h:55
bool valid_id() const
Definition dof_object.h:875
processor_id_type processor_id() const
Definition dof_object.h:895
dof_id_type & set_id()
Definition dof_object.h:841
void add_extra_integers(const unsigned int n_integers)
Assigns a set of extra integers to this DofObject.
Definition dof_object.C:482
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
unique_id_type unique_id() const
Definition dof_object.h:849
static constexpr unique_id_type invalid_unique_id
An invalid unique_id to distinguish an uninitialized DofObject.
Definition dof_object.h:478
bool valid_unique_id() const
Definition dof_object.h:883
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
void set_unique_id(unique_id_type new_id)
Sets the unique_id for this DofObject.
Definition dof_object.h:862
This is the base class from which all geometric element types are derived.
Definition elem.h:96
RefinementState refinement_flag() const
Definition elem.h:3348
bool active() const
Definition elem.h:3079
const Elem * parent() const
Definition elem.h:3168
void set_mapping_type(const ElemMappingType type)
Sets the value of the mapping type for the element.
Definition elem.h:3266
unsigned int p_level() const
Definition elem.h:3246
void set_mapping_data(const unsigned char data)
Sets the value of the mapping data for the element.
Definition elem.h:3282
RefinementState p_refinement_flag() const
Definition elem.h:3364
This is the MeshBase class.
Definition mesh_base.h:81
void allow_remote_element_removal(bool allow)
If false is passed in then this mesh will no longer have remote elements deleted when being prepared ...
Definition mesh_base.h:1390
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:750
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:178
Preparation preparation() const
Definition mesh_base.h:221
bool allow_renumbering() const
Definition mesh_base.h:1368
virtual dof_id_type n_elem() const =0
bool skip_partitioning() const
Definition mesh_base.h:1450
bool allow_detect_interior_parents() const
Definition mesh_base.h:1382
void allow_find_neighbors(bool allow)
If false is passed then this mesh will no longer work to find element neighbors when being prepared f...
Definition mesh_base.h:1374
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
Definition mesh_base.h:1367
const std::map< subdomain_id_type, std::string > & get_subdomain_name_map() const
Definition mesh_base.h:1984
virtual void redistribute()
Redistribute elements between processors.
Definition mesh_base.C:1256
virtual dof_id_type n_nodes() const =0
ElemMappingType default_mapping_type() const
Returns the default master space to physical space mapping basis functions to be used on newly added ...
Definition mesh_base.h:946
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:2552
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition mesh_base.h:2402
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition mesh_base.h:2427
virtual dof_id_type max_node_id() const =0
dof_id_type n_unpartitioned_elem() const
Definition mesh_base.h:708
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:1268
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:2534
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:2540
dof_id_type n_local_elem() const
Definition mesh_base.h:702
dof_id_type n_unpartitioned_nodes() const
Definition mesh_base.h:602
virtual dof_id_type max_elem_id() const =0
virtual void clear()
Deletes all the element and node data that is currently stored.
Definition mesh_base.C:1123
dof_id_type n_local_nodes() const
Definition mesh_base.h:596
constraint_rows_type _constraint_rows
Definition mesh_base.h:2605
std::unique_ptr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition mesh_base.h:2396
bool allow_remote_element_removal() const
Definition mesh_base.h:1391
bool allow_find_neighbors() const
Definition mesh_base.h:1375
dof_id_type _n_constraint_rows
Definition mesh_base.h:2607
unsigned char default_mapping_data() const
Returns any default data value used by the master space to physical space mapping.
Definition mesh_base.h:964
void clear_point_locator()
Releases the current PointLocator object.
Definition mesh_base.C:1985
void copy_constraint_rows(const MeshBase &other_mesh)
Copy the constraints from the other mesh to this mesh.
Definition mesh_base.C:2838
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:2546
std::map< subdomain_id_type, std::string > & set_subdomain_name_map()
Definition mesh_base.h:1982
unique_id_type next_unique_id() const
Definition mesh_base.h:615
dof_id_type count_constraint_rows()
Helper function for subclasses to use to set _n_constraint_rows.
Definition mesh_base.C:2819
Preparation _preparation
Flags indicating in what ways this mesh has been prepared.
Definition mesh_base.h:2278
void skip_partitioning(bool skip)
If true is passed in then nothing on this mesh will be (re)partitioned.
Definition mesh_base.h:1448
void allow_detect_interior_parents(bool allow)
If false is passed then this mesh will no longer work to detect interior parents when being prepared ...
Definition mesh_base.h:1381
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:2789
void post_dofobject_moves(MeshBase &&other_mesh)
Moves any superclass data (e.g.
Definition mesh_base.C:2743
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:2302
This is the MeshCommunication class.
void delete_remote_elements(DistributedMesh &, const std::set< Elem * > &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void redistribute(DistributedMesh &mesh, bool newly_coarsened_only=false) const
This method takes a parallel distributed mesh and redistributes the elements.
void allgather(MeshBase &mesh) const
This method takes an input DistributedMesh which may be distributed among all the processors.
void gather(const processor_id_type root_id, MeshBase &) const
This method takes an input DistributedMesh which may be distributed among all the processors.
A Node is like a Point, but with more information.
Definition node.h:55
static std::unique_ptr< Node > build(const Node &n)
Definition node.h:315
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
static std::unique_ptr< Partitioner > build(const PartitionerType solver_package)
Builds a Partitioner of the type specified by partitioner_type.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
The UnstructuredMesh class is derived from the MeshBase class.
virtual void copy_nodes_and_elements(const MeshBase &other_mesh, const bool skip_find_neighbors=false, dof_id_type element_id_offset=0, dof_id_type node_id_offset=0, unique_id_type unique_id_offset=0, std::unordered_map< subdomain_id_type, subdomain_id_type > *id_remapping=nullptr, const bool skip_preparation=false)
Deep copy of nodes and elements from another mesh object (used by subclass copy constructors and by m...
UnstructuredMesh & operator=(const UnstructuredMesh &)=delete
Copy assignment is not allowed.
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) override
Other functions from MeshBase requiring re-definition.
virtual void move_nodes_and_elements(MeshBase &&other_mesh)=0
Move node and elements from other_mesh to this mesh.
This mapvector templated class is intended to provide the performance characteristics of a std::map w...
Definition mapvector.h:45
veclike_iterator begin()
Definition mapvector.h:193
void erase(index_t i)
Definition mapvector.h:183
veclike_iterator end()
Definition mapvector.h:203
void pull_parallel_vector_data(const Communicator &comm, const MapToVectors &queries, GatherFunctor &gather_data, const ActionFunctor &act_on_data, const datum *example)
void push_parallel_vector_data(const Communicator &comm, MapToVectors &&data, const ActionFunctor &act_on_data)
void libmesh_assert_valid_elem_ids(const MeshBase &mesh)
A function for verifying that ids and processor assignment of elements are correctly sorted (monotone...
Definition mesh_tools.h:672
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
A function for verifying that neighbor connectivity is correct (each element is a neighbor of or desc...
void libmesh_assert_valid_refinement_tree(const MeshBase &mesh)
A function for verifying that elements on this processor have valid descendants and consistent active...
Definition mesh_tools.h:685
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t unique_id_type
Definition id_types.h:86
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
libmesh_assert(ctx)
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
T command_line_value(const std::string &, T)
Definition libmesh.C:971
uint8_t dof_id_type
Definition id_types.h:67
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