libMesh
mesh_base.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 // C++ includes
24 #include <algorithm> // for std::min
25 #include <map> // for std::multimap
26 #include <sstream> // for std::ostringstream
27 #include <unordered_map>
28 
29 // Local includes
30 #include "libmesh/boundary_info.h"
31 #include "libmesh/elem.h"
32 #include "libmesh/ghost_point_neighbors.h"
33 #include "libmesh/mesh_base.h"
34 #include "libmesh/mesh_communication.h"
35 #include "libmesh/mesh_tools.h"
36 #include "libmesh/parallel.h"
37 #include "libmesh/partitioner.h"
38 #include "libmesh/point_locator_base.h"
39 #include "libmesh/threads.h"
40 
41 
42 namespace libMesh
43 {
44 
45 
46 
47 // ------------------------------------------------------------
48 // MeshBase class member functions
50  unsigned char d) :
51  ParallelObject (comm_in),
52  boundary_info (new BoundaryInfo(*this)),
53  _n_parts (1),
54  _is_prepared (false),
55  _point_locator (),
56  _count_lower_dim_elems_in_point_locator(true),
57  _partitioner (),
58 #ifdef LIBMESH_ENABLE_UNIQUE_ID
59  _next_unique_id(DofObject::invalid_unique_id),
60 #endif
61  _skip_partitioning(libMesh::on_command_line("--skip-partitioning")),
62  _skip_renumber_nodes_and_elements(false),
63  _allow_remote_element_removal(true),
64  _spatial_dimension(d),
65  _default_ghosting(new GhostPointNeighbors(*this))
66 {
67  _elem_dims.insert(d);
69  libmesh_assert_less_equal (LIBMESH_DIM, 3);
70  libmesh_assert_greater_equal (LIBMESH_DIM, d);
72 }
73 
74 
75 #ifndef LIBMESH_DISABLE_COMMWORLD
76 #ifdef LIBMESH_ENABLE_DEPRECATED
77 MeshBase::MeshBase (unsigned char d) :
79  boundary_info (new BoundaryInfo(*this)),
80  _n_parts (1),
81  _is_prepared (false),
82  _point_locator (),
83  _partitioner (),
84 #ifdef LIBMESH_ENABLE_UNIQUE_ID
85  _next_unique_id(DofObject::invalid_unique_id),
86 #endif
87  _skip_partitioning(libMesh::on_command_line("--skip-partitioning")),
92 {
93  libmesh_deprecated();
94  _elem_dims.insert(d);
96  libmesh_assert_less_equal (LIBMESH_DIM, 3);
97  libmesh_assert_greater_equal (LIBMESH_DIM, d);
99 }
100 #endif
101 #endif // !LIBMESH_DISABLE_COMMWORLD
102 
103 
104 
105 MeshBase::MeshBase (const MeshBase & other_mesh) :
106  ParallelObject (other_mesh),
107  boundary_info (new BoundaryInfo(*this)),
108  _n_parts (other_mesh._n_parts),
109  _is_prepared (other_mesh._is_prepared),
110  _point_locator (),
111  _partitioner (),
112 #ifdef LIBMESH_ENABLE_UNIQUE_ID
113  _next_unique_id(other_mesh._next_unique_id),
114 #endif
115  _skip_partitioning(libMesh::on_command_line("--skip-partitioning")),
118  _elem_dims(other_mesh._elem_dims),
122 {
123  // Make sure we don't accidentally delete the other mesh's default
124  // ghosting functor; we'll use our own if that's needed.
125  if (other_mesh._ghosting_functors.count(other_mesh._default_ghosting.get()))
126  {
127  _ghosting_functors.erase(other_mesh._default_ghosting.get());
129  }
130 
131  if (other_mesh._partitioner.get())
132  {
133  _partitioner = other_mesh._partitioner->clone();
134  }
135 }
136 
137 
138 
140 {
141  this->clear();
142 
143  libmesh_exceptionless_assert (!libMesh::closed());
144 }
145 
146 
147 
148 unsigned int MeshBase::mesh_dimension() const
149 {
150  if (!_elem_dims.empty())
151  return cast_int<unsigned int>(*_elem_dims.rbegin());
152  return 0;
153 }
154 
155 
156 
157 unsigned int MeshBase::spatial_dimension () const
158 {
159  return cast_int<unsigned int>(_spatial_dimension);
160 }
161 
162 
163 
164 void MeshBase::set_spatial_dimension(unsigned char d)
165 {
166  // The user can set the _spatial_dimension however they wish,
167  // libMesh will only *increase* the spatial dimension, however,
168  // never decrease it.
169  _spatial_dimension = d;
170 }
171 
172 
173 
174 void MeshBase::prepare_for_use (const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
175 {
176  LOG_SCOPE("prepare_for_use()", "MeshBase");
177 
178  parallel_object_only();
179 
180  libmesh_assert(this->comm().verify(this->is_serial()));
181 
182  // A distributed mesh may have processors with no elements (or
183  // processors with no elements of higher dimension, if we ever
184  // support mixed-dimension meshes), but we want consistent
185  // mesh_dimension anyways.
186  //
187  // cache_elem_dims() should get the elem_dimensions() and
188  // mesh_dimension() correct later, and we don't need it earlier.
189 
190 
191  // Renumber the nodes and elements so that they in contiguous
192  // blocks. By default, _skip_renumber_nodes_and_elements is false.
193  //
194  // We may currently change that by passing
195  // skip_renumber_nodes_and_elements==true to this function, but we
196  // should use the allow_renumbering() accessor instead.
197  //
198  // Instances where you if prepare_for_use() should not renumber the nodes
199  // and elements include reading in e.g. an xda/r or gmv file. In
200  // this case, the ordering of the nodes may depend on an accompanying
201  // solution, and the node ordering cannot be changed.
202 
203  if (skip_renumber_nodes_and_elements)
204  {
205  libmesh_deprecated();
206  this->allow_renumbering(false);
207  }
208 
209  // Mesh modification operations might not leave us with consistent
210  // id counts, but our partitioner might need that consistency.
213  else
215 
216  // Let all the elements find their neighbors
217  if (!skip_find_neighbors)
218  this->find_neighbors();
219 
220  // The user may have set boundary conditions. We require that the
221  // boundary conditions were set consistently. Because we examine
222  // neighbors when evaluating non-raw boundary condition IDs, this
223  // assert is only valid when our neighbor links are in place.
224 #ifdef DEBUG
226 #endif
227 
228  // Search the mesh for all the dimensions of the elements
229  // and cache them.
230  this->cache_elem_dims();
231 
232  // Search the mesh for elements that have a neighboring element
233  // of dim+1 and set that element as the interior parent
234  this->detect_interior_parents();
235 
236  // Fix up node unique ids in case mesh generation code didn't take
237  // exceptional care to do so.
238  // MeshCommunication().make_node_unique_ids_parallel_consistent(*this);
239 
240  // We're going to still require that mesh generation code gets
241  // element unique ids consistent.
242 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
244 #endif
245 
246  // Reset our PointLocator. Any old locator is invalidated any time
247  // the elements in the underlying elements in the mesh have changed,
248  // so we clear it here.
249  this->clear_point_locator();
250 
251  // Allow our GhostingFunctor objects to reinit if necessary.
252  // Do this before partitioning and redistributing, and before
253  // deleting remote elements.
254  std::set<GhostingFunctor *>::iterator gf_it = this->ghosting_functors_begin();
255  const std::set<GhostingFunctor *>::iterator gf_end = this->ghosting_functors_end();
256  for (; gf_it != gf_end; ++gf_it)
257  {
258  GhostingFunctor * gf = *gf_it;
259  libmesh_assert(gf);
260  gf->mesh_reinit();
261  }
262 
263  // Partition the mesh.
264  this->partition();
265 
266  // If we're using DistributedMesh, we'll probably want it
267  // parallelized.
269  this->delete_remote_elements();
270 
273 
274  // The mesh is now prepared for use.
275  _is_prepared = true;
276 
277 #if defined(DEBUG) && defined(LIBMESH_ENABLE_UNIQUE_ID)
280 #endif
281 }
282 
283 
284 
286 {
287  // Reset the number of partitions
288  _n_parts = 1;
289 
290  // Reset the _is_prepared flag
291  _is_prepared = false;
292 
293  // Clear boundary information
294  this->get_boundary_info().clear();
295 
296  // Clear element dimensions
297  _elem_dims.clear();
298 
299  // Clear our point locator.
300  this->clear_point_locator();
301 }
302 
303 
304 
306 {
307  // We should only be trying to remove ghosting functors we actually
308  // have
309  libmesh_assert(_ghosting_functors.count(&ghosting_functor));
310  _ghosting_functors.erase(&ghosting_functor);
311 }
312 
313 
314 
315 void MeshBase::subdomain_ids (std::set<subdomain_id_type> & ids) const
316 {
317  // This requires an inspection on every processor
318  parallel_object_only();
319 
320  ids.clear();
321 
324 
325  for (; el!=end; ++el)
326  ids.insert((*el)->subdomain_id());
327 
328  // Some subdomains may only live on other processors
329  this->comm().set_union(ids);
330 }
331 
332 
333 
335 {
336  // This requires an inspection on every processor
337  parallel_object_only();
338 
339  std::set<subdomain_id_type> ids;
340 
341  this->subdomain_ids (ids);
342 
343  return cast_int<subdomain_id_type>(ids.size());
344 }
345 
346 
347 
348 
350 {
351  // We're either counting a processor's nodes or unpartitioned
352  // nodes
353  libmesh_assert (proc_id < this->n_processors() ||
355 
356  return static_cast<dof_id_type>(std::distance (this->pid_nodes_begin(proc_id),
357  this->pid_nodes_end (proc_id)));
358 }
359 
360 
361 
363 {
364  // We're either counting a processor's elements or unpartitioned
365  // elements
366  libmesh_assert (proc_id < this->n_processors() ||
368 
369  return static_cast<dof_id_type>(std::distance (this->pid_elements_begin(proc_id),
370  this->pid_elements_end (proc_id)));
371 }
372 
373 
374 
376 {
377  libmesh_assert_less (proc_id, this->n_processors());
378  return static_cast<dof_id_type>(std::distance (this->active_pid_elements_begin(proc_id),
379  this->active_pid_elements_end (proc_id)));
380 }
381 
382 
383 
385 {
386  dof_id_type ne=0;
387 
389  const const_element_iterator end = this->elements_end();
390 
391  for (; el!=end; ++el)
392  ne += (*el)->n_sub_elem();
393 
394  return ne;
395 }
396 
397 
398 
400 {
401  dof_id_type ne=0;
402 
405 
406  for (; el!=end; ++el)
407  ne += (*el)->n_sub_elem();
408 
409  return ne;
410 }
411 
412 
413 
414 std::string MeshBase::get_info() const
415 {
416  std::ostringstream oss;
417 
418  oss << " Mesh Information:" << '\n';
419 
420  if (!_elem_dims.empty())
421  {
422  oss << " elem_dimensions()={";
423  std::copy(_elem_dims.begin(),
424  --_elem_dims.end(), // --end() is valid if the set is non-empty
425  std::ostream_iterator<unsigned int>(oss, ", "));
426  oss << cast_int<unsigned int>(*_elem_dims.rbegin());
427  oss << "}\n";
428  }
429 
430  oss << " spatial_dimension()=" << this->spatial_dimension() << '\n'
431  << " n_nodes()=" << this->n_nodes() << '\n'
432  << " n_local_nodes()=" << this->n_local_nodes() << '\n'
433  << " n_elem()=" << this->n_elem() << '\n'
434  << " n_local_elem()=" << this->n_local_elem() << '\n'
435 #ifdef LIBMESH_ENABLE_AMR
436  << " n_active_elem()=" << this->n_active_elem() << '\n'
437 #endif
438  << " n_subdomains()=" << static_cast<std::size_t>(this->n_subdomains()) << '\n'
439  << " n_partitions()=" << static_cast<std::size_t>(this->n_partitions()) << '\n'
440  << " n_processors()=" << static_cast<std::size_t>(this->n_processors()) << '\n'
441  << " n_threads()=" << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
442  << " processor_id()=" << static_cast<std::size_t>(this->processor_id()) << '\n';
443 
444  return oss.str();
445 }
446 
447 
448 void MeshBase::print_info(std::ostream & os) const
449 {
450  os << this->get_info()
451  << std::endl;
452 }
453 
454 
455 std::ostream & operator << (std::ostream & os, const MeshBase & m)
456 {
457  m.print_info(os);
458  return os;
459 }
460 
461 
462 void MeshBase::partition (const unsigned int n_parts)
463 {
464  // If we get here and we have unpartitioned elements, we need that
465  // fixed.
466  if (this->n_unpartitioned_elem() > 0)
467  {
468  libmesh_assert (partitioner().get());
469  libmesh_assert (this->is_serial());
470  partitioner()->partition (*this, n_parts);
471  }
472  // NULL partitioner means don't repartition
473  // Non-serial meshes may not be ready for repartitioning here.
474  else if (!skip_partitioning() && partitioner().get())
475  {
476  partitioner()->partition (*this, n_parts);
477  }
478  else
479  {
480  // Adaptive coarsening may have "orphaned" nodes on processors
481  // whose elements no longer share them. We need to check for
482  // and possibly fix that.
484 
485  // Make sure locally cached partition count
486  this->recalculate_n_partitions();
487 
488  // Make sure any other locally cached data is correct
489  this->update_post_partitioning();
490  }
491 }
492 
494 {
495  // This requires an inspection on every processor
496  parallel_object_only();
497 
500 
501  unsigned int max_proc_id=0;
502 
503  for (; el!=end; ++el)
504  max_proc_id = std::max(max_proc_id, static_cast<unsigned int>((*el)->processor_id()));
505 
506  // The number of partitions is one more than the max processor ID.
507  _n_parts = max_proc_id+1;
508 
509  this->comm().max(_n_parts);
510 
511  return _n_parts;
512 }
513 
514 
515 
516 #ifdef LIBMESH_ENABLE_DEPRECATED
518 {
519  libmesh_deprecated();
520 
521  if (_point_locator.get() == libmesh_nullptr)
522  {
523  // PointLocator construction may not be safe within threads
525 
526  _point_locator.reset (PointLocatorBase::build(TREE_ELEMENTS, *this).release());
527  }
528 
529  return *_point_locator;
530 }
531 #endif
532 
533 
535 {
536  // If there's no master point locator, then we need one.
537  if (_point_locator.get() == libmesh_nullptr)
538  {
539  // PointLocator construction may not be safe within threads
541 
542  // And it may require parallel communication
543  parallel_object_only();
544 
545  _point_locator.reset (PointLocatorBase::build(TREE_ELEMENTS, *this).release());
546  }
547 
548  // Otherwise there was a master point locator, and we can grab a
549  // sub-locator easily.
551 }
552 
553 
554 
556 {
558 }
559 
560 
561 
563 {
564  _count_lower_dim_elems_in_point_locator = count_lower_dim_elems;
565 }
566 
567 
568 
570 {
572 }
573 
574 
575 
577 {
578  return _block_id_to_name[id];
579 }
580 
581 const std::string & MeshBase::subdomain_name(subdomain_id_type id) const
582 {
583  // An empty string to return when no matching subdomain name is found
584  static const std::string empty;
585 
586  std::map<subdomain_id_type, std::string>::const_iterator iter = _block_id_to_name.find(id);
587  if (iter == _block_id_to_name.end())
588  return empty;
589  else
590  return iter->second;
591 }
592 
593 
594 
595 
597 {
598  // Linear search over the map values.
599  std::map<subdomain_id_type, std::string>::const_iterator
600  iter = _block_id_to_name.begin(),
601  end_iter = _block_id_to_name.end();
602 
603  for ( ; iter != end_iter; ++iter)
604  if (iter->second == name)
605  return iter->first;
606 
607  // If we made it here without returning, we don't have a subdomain
608  // with the requested name, so return Elem::invalid_subdomain_id.
610 }
611 
613 {
614  // This requires an inspection on every processor
615  parallel_object_only();
616 
617  // Need to clear _elem_dims first in case all elements of a
618  // particular dimension have been deleted.
619  _elem_dims.clear();
620 
623 
624  for (; el!=end; ++el)
625  _elem_dims.insert((*el)->dim());
626 
627  // Some different dimension elements may only live on other processors
628  this->comm().set_union(_elem_dims);
629 
630  // If the largest element dimension found is larger than the current
631  // _spatial_dimension, increase _spatial_dimension.
632  unsigned int max_dim = this->mesh_dimension();
633  if (max_dim > _spatial_dimension)
634  _spatial_dimension = cast_int<unsigned char>(max_dim);
635 
636  // _spatial_dimension may need to increase from 1->2 or 2->3 if the
637  // mesh is full of 1D elements but they are not x-aligned, or the
638  // mesh is full of 2D elements but they are not in the x-y plane.
639  // If the mesh is x-aligned or x-y planar, we will end up checking
640  // every node's coordinates and not breaking out of the loop
641  // early...
642  if (_spatial_dimension < 3)
643  {
644  const_node_iterator node_it = this->nodes_begin();
645  const_node_iterator node_end = this->nodes_end();
646  for (; node_it != node_end; ++node_it)
647  {
648  Node & node = **node_it;
649 
650 #if LIBMESH_DIM > 1
651  // Note: the exact floating point comparison is intentional,
652  // we don't want to get tripped up by tolerances.
653  if (node(1) != 0.)
654  {
655  _spatial_dimension = 2;
656 #if LIBMESH_DIM == 2
657  // If libmesh is compiled in 2D mode, this is the
658  // largest spatial dimension possible so we can break
659  // out.
660  break;
661 #endif
662  }
663 #endif
664 
665 #if LIBMESH_DIM > 2
666  if (node(2) != 0.)
667  {
668  // Spatial dimension can't get any higher than this, so
669  // we can break out.
670  _spatial_dimension = 3;
671  break;
672  }
673 #endif
674  }
675  }
676 }
677 
679 {
680  // This requires an inspection on every processor
681  parallel_object_only();
682 
683  // Check if the mesh contains mixed dimensions. If so, then set interior parents, otherwise return.
684  if (this->elem_dimensions().size() == 1)
685  return;
686 
687  //This map will be used to set interior parents
688  std::unordered_map<dof_id_type, std::vector<dof_id_type>> node_to_elem;
689 
692 
693  for (; el!=end; ++el)
694  {
695  const Elem * elem = *el;
696 
697  // Populating the node_to_elem map, same as MeshTools::build_nodes_to_elem_map
698  for (unsigned int n=0; n<elem->n_vertices(); n++)
699  {
700  libmesh_assert_less (elem->id(), this->max_elem_id());
701 
702  node_to_elem[elem->node_id(n)].push_back(elem->id());
703  }
704  }
705 
706  // Automatically set interior parents
707  el = this->elements_begin();
708  for (; el!=end; ++el)
709  {
710  Elem * element = *el;
711 
712  // Ignore an 3D element or an element that already has an interior parent
713  if (element->dim()>=LIBMESH_DIM || element->interior_parent())
714  continue;
715 
716  // Start by generating a SET of elements that are dim+1 to the current
717  // element at each vertex of the current element, thus ignoring interior nodes.
718  // If one of the SET of elements is empty, then we will not have an interior parent
719  // since an interior parent must be connected to all vertices of the current element
720  std::vector<std::set<dof_id_type>> neighbors( element->n_vertices() );
721 
722  bool found_interior_parents = false;
723 
724  for (dof_id_type n=0; n < element->n_vertices(); n++)
725  {
726  std::vector<dof_id_type> & element_ids = node_to_elem[element->node_id(n)];
727  for (std::vector<dof_id_type>::iterator e_it = element_ids.begin();
728  e_it != element_ids.end(); e_it++)
729  {
730  dof_id_type eid = *e_it;
731  if (this->elem_ref(eid).dim() == element->dim()+1)
732  neighbors[n].insert(eid);
733  }
734  if (neighbors[n].size()>0)
735  {
736  found_interior_parents = true;
737  }
738  else
739  {
740  // We have found an empty set, no reason to continue
741  // Ensure we set this flag to false before the break since it could have
742  // been set to true for previous vertex
743  found_interior_parents = false;
744  break;
745  }
746  }
747 
748  // If we have successfully generated a set of elements for each vertex, we will compare
749  // the set for vertex 0 will the sets for the vertices until we find a id that exists in
750  // all sets. If found, this is our an interior parent id. The interior parent id found
751  // will be the lowest element id if there is potential for multiple interior parents.
752  if (found_interior_parents)
753  {
754  std::set<dof_id_type> & neighbors_0 = neighbors[0];
755  for (std::set<dof_id_type>::iterator e_it = neighbors_0.begin();
756  e_it != neighbors_0.end(); e_it++)
757  {
758  found_interior_parents=false;
759  dof_id_type interior_parent_id = *e_it;
760  for (dof_id_type n=1; n < element->n_vertices(); n++)
761  {
762  if (neighbors[n].find(interior_parent_id)!=neighbors[n].end())
763  {
764  found_interior_parents=true;
765  }
766  else
767  {
768  found_interior_parents=false;
769  break;
770  }
771  }
772  if (found_interior_parents)
773  {
774  element->set_interior_parent(this->elem_ptr(interior_parent_id));
775  break;
776  }
777  }
778  }
779  }
780 }
781 
782 } // namespace libMesh
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
virtual void mesh_reinit()
GhostingFunctor subclasses which cache data will need to initialize that cache.
dof_id_type n_nodes_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:349
dof_id_type n_active_sub_elem() const
Same as n_sub_elem(), but only counts active elements.
Definition: mesh_base.C:399
bool closed()
Checks that the library has been closed.
Definition: libmesh.C:281
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:117
bool _skip_renumber_nodes_and_elements
If this is true then renumbering will be kept to a minimum.
Definition: mesh_base.h:1389
UniquePtr< PointLocatorBase > _point_locator
A PointLocator class for this mesh.
Definition: mesh_base.h:1356
A Node is like a Point, but with more information.
Definition: node.h:52
Encapsulates the MPI_Comm object.
Definition: parallel.h:657
virtual dof_id_type n_active_elem() const =0
This abstract base class defines the interface by which library code and user code can report associa...
unsigned int n_threads()
Definition: libmesh_base.h:125
virtual bool is_serial() const
Definition: mesh_base.h:140
virtual node_iterator pid_nodes_end(processor_id_type proc_id)=0
UniquePtr< BoundaryInfo > boundary_info
This class holds the boundary information.
Definition: mesh_base.h:1321
bool _skip_partitioning
If this is true then no partitioning should be done.
Definition: mesh_base.h:1382
bool skip_partitioning() const
Definition: mesh_base.h:775
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:678
void max(T &r) const
Take a local variable and replace it with the maximum of it&#39;s values on all processors.
The definition of the const_element_iterator struct.
Definition: mesh_base.h:1494
dof_id_type n_local_nodes() const
Definition: mesh_base.h:272
static void set_node_processor_ids(MeshBase &mesh)
This function is called after partitioning to set the processor IDs for the nodes.
Definition: partitioner.C:416
unsigned int n_partitions() const
Definition: mesh_base.h:833
void set_spatial_dimension(unsigned char d)
Sets the "spatial dimension" of the Mesh.
Definition: mesh_base.C:164
dof_id_type n_unpartitioned_elem() const
Definition: mesh_base.h:378
processor_id_type n_processors() const
const Elem * interior_parent() const
Definition: elem.C:951
void remove_ghosting_functor(GhostingFunctor &ghosting_functor)
Removes a functor which was previously added to the set of ghosting functors.
Definition: mesh_base.C:305
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
uint8_t processor_id_type
Definition: id_types.h:99
const class libmesh_nullptr_t libmesh_nullptr
virtual const Elem * elem(const dof_id_type i) const
Definition: mesh_base.h:523
UniquePtr< Partitioner > _partitioner
A partitioner to use at each prepare_for_use().
Definition: mesh_base.h:1370
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end...
unsigned char _spatial_dimension
The "spatial dimension" of the Mesh.
Definition: mesh_base.h:1417
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:1397
The libMesh namespace provides an interface to certain functionality in the library.
std::string get_info() const
Definition: mesh_base.C:414
long double max(long double a, double b)
bool in_threads
A boolean which is true iff we are in a Threads:: function It may be useful to assert(!Threadsin_thre...
Definition: threads.C:31
Real distance(const Point &p)
void set_interior_parent(Elem *p)
Sets the pointer to the element&#39;s interior_parent.
Definition: elem.C:1003
This is the MeshBase class.
Definition: mesh_base.h:68
libmesh_assert(j)
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
End of range of ghosting functors.
Definition: mesh_base.h:804
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
const PointLocatorBase & point_locator() const
Definition: mesh_base.C:517
virtual node_iterator nodes_begin()=0
Iterate over all the nodes in the Mesh.
virtual element_iterator elements_begin()=0
Iterate over all the elements in the Mesh.
std::set< GhostingFunctor * > _ghosting_functors
The list of all GhostingFunctor objects to be used when distributing a DistributedMesh.
Definition: mesh_base.h:1433
unique_id_type _next_unique_id
The next available unique id for assigning ids to DOF objects.
Definition: mesh_base.h:1376
unsigned int _n_parts
The number of partitions the mesh has.
Definition: mesh_base.h:1342
virtual dof_id_type max_elem_id() const =0
static const subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition: elem.h:237
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true)=0
Locate element face (edge in 2D) neighbors.
dof_id_type n_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:362
void subdomain_ids(std::set< subdomain_id_type > &ids) const
Constructs a list of all subdomain identifiers in the global mesh.
Definition: mesh_base.C:315
static const 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:335
virtual element_iterator active_local_elements_begin()=0
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id)=0
virtual void update_parallel_id_counts()=0
Updates parallel caches so that methods like n_elem() accurately reflect changes on other processors...
virtual element_iterator elements_end()=0
void clear_point_locator()
Releases the current PointLocator object.
Definition: mesh_base.C:555
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:56
void libmesh_assert_valid_boundary_ids(const MeshBase &mesh)
A function for verifying that boundary condition ids match across processors.
Definition: mesh_tools.C:1194
std::set< unsigned char > _elem_dims
We cache the dimension of the elements present in the mesh.
Definition: mesh_base.h:1411
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Prepare a newly created (or read) mesh for use.
Definition: mesh_base.C:174
unsigned int spatial_dimension() const
Definition: mesh_base.C:157
std::string & subdomain_name(subdomain_id_type id)
Definition: mesh_base.C:576
This is the base class for point locators.
const std::set< unsigned char > & elem_dimensions() const
Definition: mesh_base.h:206
This class forms the base class for all other classes that are expected to be implemented in parallel...
subdomain_id_type get_id_by_name(const std::string &name) const
Definition: mesh_base.C:596
virtual void clear()
Deletes all the data that are currently stored.
Definition: mesh_base.C:285
void clear()
Clears the underlying data structures and restores the object to a pristine state with no data stored...
friend std::ostream & operator<<(std::ostream &os, const MeshBase &m)
Equivalent to calling print_info() above, but now you can write: Mesh mesh; libMesh::out << mesh << s...
Definition: mesh_base.C:455
static UniquePtr< PointLocatorBase > build(PointLocatorType t, const MeshBase &mesh, const PointLocatorBase *master=libmesh_nullptr)
Builds an PointLocator for the mesh mesh.
virtual element_iterator active_elements_begin()=0
Active, local, and negation forms of the element iterators described above.
UniquePtr< GhostingFunctor > _default_ghosting
The default geometric GhostingFunctor, used to implement standard libMesh element ghosting behavior...
Definition: mesh_base.h:1424
virtual element_iterator pid_elements_begin(processor_id_type proc_id)=0
Iterate over all elements with a specified processor id.
virtual element_iterator active_elements_end()=0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition: mesh_base.h:490
Parallel::FakeCommunicator CommWorld
The default libMesh communicator.
Definition: parallel.h:1433
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:493
dof_id_type n_local_elem() const
Definition: mesh_base.h:372
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Beginning of range of ghosting functors.
Definition: mesh_base.h:798
virtual node_iterator nodes_end()=0
virtual element_iterator active_pid_elements_end(processor_id_type proc_id)=0
bool verify(const T &r, const Communicator &comm=Communicator_World)
virtual UniquePtr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:112
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:569
bool on_command_line(const std::string &arg)
Definition: libmesh.C:921
const Parallel::Communicator & comm() const
unsigned int mesh_dimension() const
Definition: mesh_base.C:148
bool allow_renumbering() const
Definition: mesh_base.h:750
bool _is_prepared
Flag indicating if the mesh has been prepared for use.
Definition: mesh_base.h:1347
virtual unsigned int n_vertices() const =0
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:562
The definition of the const_node_iterator struct.
Definition: mesh_base.h:1548
MeshBase(const Parallel::Communicator &comm_in, unsigned char dim=1)
Constructor.
Definition: mesh_base.C:49
virtual unsigned int dim() const =0
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition: dof_object.h:51
virtual ~MeshBase()
Destructor.
Definition: mesh_base.C:139
virtual const Node & node(const dof_id_type i) const
Definition: mesh_base.h:440
bool initialized()
Checks that library initialization has been done.
Definition: libmesh.C:274
dof_id_type n_sub_elem() const
Definition: mesh_base.C:384
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
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:182
void cache_elem_dims()
Search the mesh and cache the different dimensions of the elements present in the mesh...
Definition: mesh_base.C:612
virtual void update_post_partitioning()
Recalculate any cached data after elements and nodes have been repartitioned.
Definition: mesh_base.h:741
dof_id_type id() const
Definition: dof_object.h:632
void libmesh_assert_valid_unique_ids(const MeshBase &mesh)
A function for verifying that unique ids match across processors.
Definition: mesh_tools.C:1397
subdomain_id_type n_subdomains() const
Definition: mesh_base.C:334
virtual dof_id_type n_nodes() const =0
virtual const Elem * elem_ptr(const dof_id_type i) const =0
virtual dof_id_type n_elem() const =0
virtual node_iterator pid_nodes_begin(processor_id_type proc_id)=0
Iterate over nodes with processor_id() == proc_id.
virtual element_iterator active_local_elements_end()=0
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:1362
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
Definition: mesh_base.C:448
UniquePtr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:534
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:1404
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...
This class implements the default geometry ghosting in libMesh: point neighbors and interior_parent e...
dof_id_type n_active_elem_on_proc(const processor_id_type proc) const
Definition: mesh_base.C:375
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:64
void set_union(T &data, const unsigned int root_id) const
Take a container of local variables on each processor, and collect their union over all processors...
virtual element_iterator pid_elements_end(processor_id_type proc_id)=0