unstructured_mesh.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 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 // C++ includes
21 #include <fstream>
22 #include <sstream>
23 #include <iomanip>
24 
25 // C includes
26 #include <sys/types.h> // for pid_t
27 #include <unistd.h> // for getpid(), unlink()
28 
29 // Local includes
30 #include "libmesh/boundary_info.h"
34 #include "libmesh/elem.h"
35 #include "libmesh/mesh_tools.h" // For n_levels
36 #include "libmesh/parallel.h"
37 #include "libmesh/remote_elem.h"
38 
39 // For most I/O
40 #include "libmesh/namebased_io.h"
41 
42 #include LIBMESH_INCLUDE_UNORDERED_MAP
43 
44 
45 namespace libMesh
46 {
47 
48 
49 // ------------------------------------------------------------
50 // UnstructuredMesh class member functions
52  unsigned char d) :
53  MeshBase (comm_in,d)
54 {
56 }
57 
58 
59 
60 #ifndef LIBMESH_DISABLE_COMMWORLD
62  MeshBase (d)
63 {
64  libmesh_deprecated();
66 }
67 #endif
68 
69 
70 
72  const bool skip_find_neighbors)
73 {
74  // We're assuming our subclass data needs no copy
75  libmesh_assert_equal_to (_n_parts, other_mesh._n_parts);
76  libmesh_assert_equal_to (_is_prepared, other_mesh._is_prepared);
77 
78  // We're assuming the other mesh has proper element number ordering,
79  // so that we add parents before their children.
80 #ifdef DEBUG
82 #endif
83 
84  //Copy in Nodes
85  {
86  //Preallocate Memory if necessary
87  this->reserve_nodes(other_mesh.n_nodes());
88 
89  const_node_iterator it = other_mesh.nodes_begin();
90  const_node_iterator end = other_mesh.nodes_end();
91 
92  for (; it != end; ++it)
93  {
94  const Node * oldn = *it;
95 
96  // Add new nodes in old node Point locations
97 #ifdef LIBMESH_ENABLE_UNIQUE_ID
98  Node *newn =
99 #endif
100  this->add_point(*oldn, oldn->id(), oldn->processor_id());
101 
102 #ifdef LIBMESH_ENABLE_UNIQUE_ID
103  newn->set_unique_id() = oldn->unique_id();
104 #endif
105  }
106  }
107 
108  //Copy in Elements
109  {
110  //Preallocate Memory if necessary
111  this->reserve_elem(other_mesh.n_elem());
112 
113  // Declare a map linking old and new elements, needed to copy the neighbor lists
114  std::map<const Elem *, Elem *> old_elems_to_new_elems;
115 
116  // Loop over the elements
119 
120  // FIXME: Where do we set element IDs??
121  for (; it != end; ++it)
122  {
123  //Look at the old element
124  const Elem * old = *it;
125  //Build a new element
126  Elem * newparent = old->parent() ?
127  this->elem_ptr(old->parent()->id()) : libmesh_nullptr;
128  UniquePtr<Elem> ap = Elem::build(old->type(), newparent);
129  Elem * el = ap.release();
130 
131  el->subdomain_id() = old->subdomain_id();
132 
133  for (unsigned int s=0; s != old->n_sides(); ++s)
134  if (old->neighbor_ptr(s) == remote_elem)
135  el->set_neighbor(s, const_cast<RemoteElem *>(remote_elem));
136 
137 #ifdef LIBMESH_ENABLE_AMR
138  if (old->has_children())
139  for (unsigned int c=0; c != old->n_children(); ++c)
140  if (old->child_ptr(c) == remote_elem)
141  el->add_child(const_cast<RemoteElem *>(remote_elem), c);
142 
143  //Create the parent's child pointers if necessary
144  if (newparent)
145  {
146  unsigned int oldc = old->parent()->which_child_am_i(old);
147  newparent->add_child(el, oldc);
148  }
149 
150  // Copy the refinement flags
151  el->set_refinement_flag(old->refinement_flag());
152 
153  // Use hack_p_level since we may not have sibling elements
154  // added yet
155  el->hack_p_level(old->p_level());
156 
157  el->set_p_refinement_flag(old->p_refinement_flag());
158 #endif // #ifdef LIBMESH_ENABLE_AMR
159 
160  //Assign all the nodes
161  for(unsigned int i=0;i<el->n_nodes();i++)
162  el->set_node(i) = this->node_ptr(old->node_id(i));
163 
164  // And start it off in the same subdomain
165  el->processor_id() = old->processor_id();
166 
167  // Give it the same ids
168  el->set_id(old->id());
169 
170 #ifdef LIBMESH_ENABLE_UNIQUE_ID
171  el->set_unique_id() = old->unique_id();
172 #endif
173 
174  //Hold onto it
175  if(!skip_find_neighbors)
176  {
177  this->add_elem(el);
178  }
179  else
180  {
181  Elem * new_el = this->add_elem(el);
182  old_elems_to_new_elems[old] = new_el;
183  }
184 
185  // Add the link between the original element and this copy to the map
186  if(skip_find_neighbors)
187  old_elems_to_new_elems[old] = el;
188  }
189 
190  // Loop (again) over the elements to fill in the neighbors
191  if(skip_find_neighbors)
192  {
193  it = other_mesh.elements_begin();
194  for (; it != end; ++it)
195  {
196  Elem * old_elem = *it;
197  Elem * new_elem = old_elems_to_new_elems[old_elem];
198  for (unsigned int s=0; s != old_elem->n_neighbors(); ++s)
199  {
200  const Elem * old_neighbor = old_elem->neighbor_ptr(s);
201  Elem * new_neighbor = old_elems_to_new_elems[old_neighbor];
202  new_elem->set_neighbor(s, new_neighbor);
203  }
204  }
205  }
206  }
207 
208  //Finally prepare the new Mesh for use. Keep the same numbering and
209  //partitioning but also the same renumbering and partitioning
210  //policies as our source mesh.
211  this->allow_renumbering(false);
212  this->skip_partitioning(true);
213  this->prepare_for_use(false, skip_find_neighbors);
214  this->allow_renumbering(other_mesh.allow_renumbering());
215  this->skip_partitioning(other_mesh.skip_partitioning());
216 }
217 
218 
219 
221 {
222  // this->clear (); // Nothing to clear at this level
223 
224  libmesh_exceptionless_assert (!libMesh::closed());
225 }
226 
227 
228 
229 
230 
231 void UnstructuredMesh::find_neighbors (const bool reset_remote_elements,
232  const bool reset_current_list)
233 {
234  // We might actually want to run this on an empty mesh
235  // (e.g. the boundary mesh for a nonexistant bcid!)
236  // libmesh_assert_not_equal_to (this->n_nodes(), 0);
237  // libmesh_assert_not_equal_to (this->n_elem(), 0);
238 
239  // This function must be run on all processors at once
240  parallel_object_only();
241 
242  LOG_SCOPE("find_neighbors()", "Mesh");
243 
244  const element_iterator el_end = this->elements_end();
245 
246  //TODO:[BSK] This should be removed later?!
247  if (reset_current_list)
248  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
249  {
250  Elem * e = *el;
251  for (unsigned int s=0; s<e->n_neighbors(); s++)
252  if (e->neighbor_ptr(s) != remote_elem ||
253  reset_remote_elements)
255  }
256 
257  // Find neighboring elements by first finding elements
258  // with identical side keys and then check to see if they
259  // are neighbors
260  {
261  // data structures -- Use the hash_multimap if available
262  typedef unsigned int key_type;
263  typedef std::pair<Elem *, unsigned char> val_type;
264  typedef std::pair<key_type, val_type> key_val_pair;
265 
266  typedef LIBMESH_BEST_UNORDERED_MULTIMAP<key_type, val_type> map_type;
267 
268  // A map from side keys to corresponding elements & side numbers
269  map_type side_to_elem_map;
270 
271 
272 
273  for (element_iterator el = this->elements_begin(); el != el_end; ++el)
274  {
275  Elem * element = *el;
276 
277  for (unsigned char ms=0; ms<element->n_neighbors(); ms++)
278  {
279  next_side:
280  // If we haven't yet found a neighbor on this side, try.
281  // Even if we think our neighbor is remote, that
282  // information may be out of date.
283  if (element->neighbor_ptr(ms) == libmesh_nullptr ||
284  element->neighbor_ptr(ms) == remote_elem)
285  {
286  // Get the key for the side of this element
287  const unsigned int key = element->key(ms);
288 
289  // Look for elements that have an identical side key
290  std::pair <map_type::iterator, map_type::iterator>
291  bounds = side_to_elem_map.equal_range(key);
292 
293  // May be multiple keys, check all the possible
294  // elements which _might_ be neighbors.
295  if (bounds.first != bounds.second)
296  {
297  // Get the side for this element
298  const UniquePtr<Elem> my_side(element->side_ptr(ms));
299 
300  // Look at all the entries with an equivalent key
301  while (bounds.first != bounds.second)
302  {
303  // Get the potential element
304  Elem * neighbor = bounds.first->second.first;
305 
306  // Get the side for the neighboring element
307  const unsigned int ns = bounds.first->second.second;
308  const UniquePtr<Elem> their_side(neighbor->side_ptr(ns));
309  //libmesh_assert(my_side.get());
310  //libmesh_assert(their_side.get());
311 
312  // If found a match with my side
313  //
314  // We need special tests here for 1D:
315  // since parents and children have an equal
316  // side (i.e. a node), we need to check
317  // ns != ms, and we also check level() to
318  // avoid setting our neighbor pointer to
319  // any of our neighbor's descendants
320  if( (*my_side == *their_side) &&
321  (element->level() == neighbor->level()) &&
322  ((element->dim() != 1) || (ns != ms)) )
323  {
324  // So share a side. Is this a mixed pair
325  // of subactive and active/ancestor
326  // elements?
327  // If not, then we're neighbors.
328  // If so, then the subactive's neighbor is
329 
330  if (element->subactive() ==
331  neighbor->subactive())
332  {
333  // an element is only subactive if it has
334  // been coarsened but not deleted
335  element->set_neighbor (ms,neighbor);
336  neighbor->set_neighbor(ns,element);
337  }
338  else if (element->subactive())
339  {
340  element->set_neighbor(ms,neighbor);
341  }
342  else if (neighbor->subactive())
343  {
344  neighbor->set_neighbor(ns,element);
345  }
346  side_to_elem_map.erase (bounds.first);
347 
348  // get out of this nested crap
349  goto next_side;
350  }
351 
352  ++bounds.first;
353  }
354  }
355 
356  // didn't find a match...
357  // Build the map entry for this element
358  key_val_pair kvp;
359 
360  kvp.first = key;
361  kvp.second.first = element;
362  kvp.second.second = ms;
363 
364  // use the lower bound as a hint for
365  // where to put it.
366 #if defined(LIBMESH_HAVE_UNORDERED_MAP) || defined(LIBMESH_HAVE_TR1_UNORDERED_MAP) || defined(LIBMESH_HAVE_HASH_MAP) || defined(LIBMESH_HAVE_EXT_HASH_MAP)
367  side_to_elem_map.insert (kvp);
368 #else
369  side_to_elem_map.insert (bounds.first,kvp);
370 #endif
371  }
372  }
373  }
374  }
375 
376 #ifdef LIBMESH_ENABLE_AMR
377 
405  const unsigned int n_levels = MeshTools::n_levels(*this);
406  for (unsigned int level = 1; level < n_levels; ++level)
407  {
408  element_iterator end = this->level_elements_end(level);
409  for (element_iterator el = this->level_elements_begin(level);
410  el != end; ++el)
411  {
412  Elem * current_elem = *el;
413  libmesh_assert(current_elem);
414  Elem * parent = current_elem->parent();
415  libmesh_assert(parent);
416  const unsigned int my_child_num = parent->which_child_am_i(current_elem);
417 
418  for (unsigned int s=0; s < current_elem->n_neighbors(); s++)
419  {
420  if (current_elem->neighbor_ptr(s) == libmesh_nullptr ||
421  (current_elem->neighbor_ptr(s) == remote_elem &&
422  parent->is_child_on_side(my_child_num, s)))
423  {
424  Elem * neigh = parent->neighbor_ptr(s);
425 
426  // If neigh was refined and had non-subactive children
427  // made remote earlier, then a non-subactive elem should
428  // actually have one of those remote children as a
429  // neighbor
430  if (neigh && (neigh->ancestor()) && (!current_elem->subactive()))
431  {
432 #ifdef DEBUG
433  // Let's make sure that "had children made remote"
434  // situation is actually the case
435  libmesh_assert(neigh->has_children());
436  bool neigh_has_remote_children = false;
437  for (unsigned int c = 0; c != neigh->n_children(); ++c)
438  {
439  if (neigh->child_ptr(c) == remote_elem)
440  neigh_has_remote_children = true;
441  }
442  libmesh_assert(neigh_has_remote_children);
443 
444  // And let's double-check that we don't have
445  // a remote_elem neighboring an active local element
446  if (current_elem->active())
447  libmesh_assert_not_equal_to (current_elem->processor_id(),
448  this->processor_id());
449 #endif // DEBUG
450  neigh = const_cast<RemoteElem *>(remote_elem);
451  }
452 
453  if (!current_elem->subactive())
454  current_elem->set_neighbor(s, neigh);
455 #ifdef DEBUG
456  if (neigh != libmesh_nullptr && neigh != remote_elem)
457  // We ignore subactive elements here because
458  // we don't care about neighbors of subactive element.
459  if ((!neigh->active()) && (!current_elem->subactive()))
460  {
461  libMesh::err << "On processor " << this->processor_id()
462  << std::endl;
463  libMesh::err << "Bad element ID = " << current_elem->id()
464  << ", Side " << s << ", Bad neighbor ID = " << neigh->id() << std::endl;
465  libMesh::err << "Bad element proc_ID = " << current_elem->processor_id()
466  << ", Bad neighbor proc_ID = " << neigh->processor_id() << std::endl;
467  libMesh::err << "Bad element size = " << current_elem->hmin()
468  << ", Bad neighbor size = " << neigh->hmin() << std::endl;
469  libMesh::err << "Bad element center = " << current_elem->centroid()
470  << ", Bad neighbor center = " << neigh->centroid() << std::endl;
471  libMesh::err << "ERROR: "
472  << (current_elem->active()?"Active":"Ancestor")
473  << " Element at level "
474  << current_elem->level() << std::endl;
475  libMesh::err << "with "
476  << (parent->active()?"active":
477  (parent->subactive()?"subactive":"ancestor"))
478  << " parent share "
479  << (neigh->subactive()?"subactive":"ancestor")
480  << " neighbor at level " << neigh->level()
481  << std::endl;
482  NameBasedIO(*this).write ("bad_mesh.gmv");
483  libmesh_error_msg("Problematic mesh written to bad_mesh.gmv.");
484  }
485 #endif // DEBUG
486  }
487  }
488 
489  // We can skip to the next element if we're full-dimension
490  // and therefore don't have any interior parents
491  if (current_elem->dim() >= LIBMESH_DIM)
492  continue;
493 
494  // We have no interior parents unless we can find one later
495  current_elem->set_interior_parent(libmesh_nullptr);
496 
497  Elem * pip = parent->interior_parent();
498 
499  if (!pip)
500  continue;
501 
502  // If there's no interior_parent children, whether due to a
503  // remote element or a non-conformity, then there's no
504  // children to search.
505  if (pip == remote_elem || pip->active())
506  {
507  current_elem->set_interior_parent(pip);
508  continue;
509  }
510 
511  // For node comparisons we'll need a sensible tolerance
512  Real node_tolerance = current_elem->hmin() * TOLERANCE;
513 
514  // Otherwise our interior_parent should be a child of our
515  // parent's interior_parent.
516  for (unsigned int c=0; c != pip->n_children(); ++c)
517  {
518  Elem * child = pip->child_ptr(c);
519 
520  // If we have a remote_elem, that might be our
521  // interior_parent. We'll set it provisionally now and
522  // keep trying to find something better.
523  if (child == remote_elem)
524  {
525  current_elem->set_interior_parent
526  (const_cast<RemoteElem *>(remote_elem));
527  continue;
528  }
529 
530  bool child_contains_our_nodes = true;
531  for (unsigned int n=0; n != current_elem->n_nodes();
532  ++n)
533  {
534  bool child_contains_this_node = false;
535  for (unsigned int cn=0; cn != child->n_nodes();
536  ++cn)
537  if (child->point(cn).absolute_fuzzy_equals
538  (current_elem->point(n), node_tolerance))
539  {
540  child_contains_this_node = true;
541  break;
542  }
543  if (!child_contains_this_node)
544  {
545  child_contains_our_nodes = false;
546  break;
547  }
548  }
549  if (child_contains_our_nodes)
550  {
551  current_elem->set_interior_parent(child);
552  break;
553  }
554  }
555 
556  // We should have found *some* interior_parent at this
557  // point, whether semilocal or remote.
558  libmesh_assert(current_elem->interior_parent());
559  }
560  }
561 
562 #endif // AMR
563 
564 
565 #ifdef DEBUG
567  !reset_remote_elements);
569 #endif
570 }
571 
572 
573 
574 void UnstructuredMesh::read (const std::string & name,
575  void *,
576  bool skip_renumber_nodes_and_elements,
577  bool skip_find_neighbors)
578 {
579  // Set the skip_renumber_nodes_and_elements flag on all processors
580  // if necessary.
581  // This ensures that renumber_nodes_and_elements is *not* called
582  // during prepare_for_use() for certain types of mesh files.
583  // This is required in cases where there is an associated solution
584  // file which expects a certain ordering of the nodes.
585  if (name.rfind(".gmv") + 4 == name.size())
586  this->allow_renumbering(false);
587 
588  NameBasedIO(*this).read(name);
589 
590  if (skip_renumber_nodes_and_elements)
591  {
592  // Use MeshBase::allow_renumbering() yourself instead.
593  libmesh_deprecated();
594  this->allow_renumbering(false);
595  }
596 
597  // Done reading the mesh. Now prepare it for use.
598  this->prepare_for_use(/*skip_renumber (deprecated)*/ false,
599  skip_find_neighbors);
600 }
601 
602 
603 
604 void UnstructuredMesh::write (const std::string & name)
605 {
606  LOG_SCOPE("write()", "Mesh");
607 
608  NameBasedIO(*this).write(name);
609 }
610 
611 
612 
613 void UnstructuredMesh::write (const std::string & name,
614  const std::vector<Number> & v,
615  const std::vector<std::string> & vn)
616 {
617  LOG_SCOPE("write()", "Mesh");
618 
619  NameBasedIO(*this).write_nodal_data(name, v, vn);
620 }
621 
622 
623 
624 
625 
627  const processor_id_type pid) const
628 {
629 
630  // Issue a warning if the number the number of processors
631  // currently available is less that that requested for
632  // partitioning. This is not necessarily an error since
633  // you may run on one processor and still partition the
634  // mesh into several partitions.
635 #ifdef DEBUG
636  if (this->n_processors() < pid)
637  {
638  libMesh::out << "WARNING: You are creating a "
639  << "mesh for a processor id (="
640  << pid
641  << ") greater than "
642  << "the number of processors available for "
643  << "the calculation. (="
644  << this->n_processors()
645  << ")."
646  << std::endl;
647  }
648 #endif
649 
650  // Create iterators to loop over the list of elements
651  // const_active_pid_elem_iterator it(this->elements_begin(), pid);
652  // const const_active_pid_elem_iterator it_end(this->elements_end(), pid);
653 
655  const const_element_iterator it_end = this->active_pid_elements_end(pid);
656 
657  this->create_submesh (pid_mesh, it, it_end);
658 }
659 
660 
661 
662 
663 
664 
665 
668  const const_element_iterator & it_end) const
669 {
670  // Just in case the subdomain_mesh already has some information
671  // in it, get rid of it.
672  new_mesh.clear();
673 
674  // If we're not serial, our submesh isn't either.
675  // There are no remote elements to delete on an empty mesh, but
676  // calling the method to do so marks the mesh as parallel.
677  if (!this->is_serial())
678  new_mesh.delete_remote_elements();
679 
680  // Fail if (*this == new_mesh), we cannot create a submesh inside ourself!
681  // This may happen if the user accidently passes the original mesh into
682  // this function! We will check this by making sure we did not just
683  // clear ourself.
684  libmesh_assert_not_equal_to (this->n_nodes(), 0);
685  libmesh_assert_not_equal_to (this->n_elem(), 0);
686 
687  // Container to catch boundary IDs handed back by BoundaryInfo
688  std::vector<boundary_id_type> bc_ids;
689 
690  for (; it != it_end; ++it)
691  {
692  const Elem * old_elem = *it;
693 
694  // Add an equivalent element type to the new_mesh.
695  // Copy ids for this element.
696  Elem * new_elem = Elem::build(old_elem->type()).release();
697  new_elem->set_id() = old_elem->id();
698 #ifdef LIBMESH_ENABLE_UNIQUE_ID
699  new_elem->set_unique_id() = old_elem->unique_id();
700 #endif
701  new_elem->subdomain_id() = old_elem->subdomain_id();
702  new_elem->processor_id() = old_elem->processor_id();
703 
704  new_mesh.add_elem (new_elem);
705 
706  libmesh_assert(new_elem);
707 
708  // Loop over the nodes on this element.
709  for (unsigned int n=0; n<old_elem->n_nodes(); n++)
710  {
711  const dof_id_type this_node_id = old_elem->node_id(n);
712 
713  // Add this node to the new mesh if it's not there already
714  if (!new_mesh.query_node_ptr(this_node_id))
715  {
716 #ifdef LIBMESH_ENABLE_UNIQUE_ID
717  Node *newn =
718 #endif
719  new_mesh.add_point (old_elem->point(n),
720  this_node_id,
721  old_elem->node_ptr(n)->processor_id());
722 
723 #ifdef LIBMESH_ENABLE_UNIQUE_ID
724  newn->set_unique_id() = old_elem->node_ptr(n)->unique_id();
725 #endif
726  }
727 
728  // Define this element's connectivity on the new mesh
729  new_elem->set_node(n) = new_mesh.node_ptr(this_node_id);
730  }
731 
732  // Maybe add boundary conditions for this element
733  for (unsigned short s=0; s<old_elem->n_sides(); s++)
734  {
735  this->get_boundary_info().boundary_ids(old_elem, s, bc_ids);
736  new_mesh.get_boundary_info().add_side (new_elem, s, bc_ids);
737  }
738  } // end loop over elements
739 
740  // Prepare the new_mesh for use
741  new_mesh.prepare_for_use(/*skip_renumber =*/false);
742 }
743 
744 
745 
746 #ifdef LIBMESH_ENABLE_AMR
748 {
749  LOG_SCOPE ("contract()", "Mesh");
750 
751  // Flag indicating if this call actually changes the mesh
752  bool mesh_changed = false;
753 
756 
757 #ifdef DEBUG
758  for ( ; in != end; ++in)
759  if (*in != libmesh_nullptr)
760  {
761  Elem * el = *in;
762  libmesh_assert(el->active() || el->subactive() || el->ancestor());
763  }
764  in = elements_begin();
765 #endif
766 
767  // Loop over the elements.
768  for ( ; in != end; ++in)
769  if (*in != libmesh_nullptr)
770  {
771  Elem * el = *in;
772 
773  // Delete all the subactive ones
774  if (el->subactive())
775  {
776  // No level-0 element should be subactive.
777  // Note that we CAN'T test elem->level(), as that
778  // touches elem->parent()->dim(), and elem->parent()
779  // might have already been deleted!
780  libmesh_assert(el->parent());
781 
782  // Delete the element
783  // This just sets a pointer to NULL, and doesn't
784  // invalidate any iterators
785  this->delete_elem(el);
786 
787  // the mesh has certainly changed
788  mesh_changed = true;
789  }
790  else
791  {
792  // Compress all the active ones
793  if (el->active())
794  el->contract();
795  else
796  libmesh_assert (el->ancestor());
797  }
798  }
799 
800  // Strip any newly-created NULL voids out of the element array
802 
803  // FIXME: Need to understand why deleting subactive children
804  // invalidates the point locator. For now we will clear it explicitly
805  this->clear_point_locator();
806 
807  // Allow our GhostingFunctor objects to reinit if necessary.
808  std::set<GhostingFunctor *>::iterator gf_it = this->ghosting_functors_begin();
809  const std::set<GhostingFunctor *>::iterator gf_end = this->ghosting_functors_end();
810  for (; gf_it != gf_end; ++gf_it)
811  {
812  GhostingFunctor *gf = *gf_it;
813  libmesh_assert(gf);
814  gf->mesh_reinit();
815  }
816 
817  return mesh_changed;
818 }
819 #endif // #ifdef LIBMESH_ENABLE_AMR
820 
821 } // namespace libMesh
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
bool ancestor() const
Definition: elem.C:1473
virtual void read(const std::string &mesh_file) libmesh_override
Definition: namebased_io.C:62
bool has_children() const
Definition: elem.h:2022
bool closed()
Definition: libmesh.C:279
const BoundaryInfo & get_boundary_info() const
Definition: mesh_base.h:111
unique_id_type & set_unique_id()
Definition: dof_object.h:654
virtual void reserve_nodes(const dof_id_type nn)=0
virtual void read(const std::string &name, void *mesh_data=libmesh_nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) libmesh_override
Used by ParallelMesh to represent an Elem owned by another processor.
Definition: remote_elem.h:44
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1723
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
void create_pid_mesh(UnstructuredMesh &pid_mesh, const processor_id_type pid) const
bool subactive() const
Definition: elem.h:2002
virtual bool is_serial() const
Definition: mesh_base.h:134
void libmesh_assert_valid_amr_interior_parents(const MeshBase &mesh)
Definition: mesh_tools.C:1141
bool active() const
Definition: elem.h:1984
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:234
virtual ElemType type() const =0
virtual element_iterator level_elements_begin(unsigned int level)=0
virtual void copy_nodes_and_elements(const UnstructuredMesh &other_mesh, const bool skip_find_neighbors=false)
void allow_renumbering(bool allow)
Definition: mesh_base.h:707
unsigned int p_level() const
Definition: elem.h:2149
bool skip_partitioning() const
Definition: mesh_base.h:732
void skip_partitioning(bool skip)
Definition: mesh_base.h:731
virtual unsigned int n_neighbors() const
Definition: elem.h:530
const Elem * parent() const
Definition: elem.h:2073
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) libmesh_override
Definition: namebased_io.C:425
processor_id_type n_processors() const
const Elem * interior_parent() const
Definition: elem.C:940
The base class for all geometric element types.
Definition: elem.h:86
virtual Real hmin() const
Definition: elem.C:449
uint8_t processor_id_type
Definition: id_types.h:99
void add_child(Elem *elem)
Definition: elem.C:1508
const class libmesh_nullptr_t libmesh_nullptr
virtual const Node * node_ptr(const dof_id_type i) const =0
static const Real TOLERANCE
IterBase * end
virtual void find_neighbors(const bool reset_remote_elements=false, const bool reset_current_list=true) libmesh_override
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const =0
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
void set_interior_parent(Elem *p)
Definition: elem.C:992
Base class for Mesh.
Definition: mesh_base.h:67
dof_id_type & set_id()
Definition: dof_object.h:633
libmesh_assert(j)
std::set< GhostingFunctor * >::const_iterator ghosting_functors_end() const
Definition: mesh_base.h:761
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual unsigned int n_nodes() const =0
const Elem * neighbor_ptr(unsigned int i) const
Definition: elem.h:1749
std::vector< boundary_id_type > boundary_ids(const Node *node) const
void create_submesh(UnstructuredMesh &new_mesh, const_element_iterator &it, const const_element_iterator &it_end) const
virtual node_iterator nodes_begin()=0
virtual element_iterator elements_begin()=0
virtual element_iterator level_elements_end(unsigned int level)=0
unsigned int _n_parts
Definition: mesh_base.h:1276
virtual void write(const std::string &mesh_file) libmesh_override
Definition: namebased_io.C:279
virtual void delete_elem(Elem *e)=0
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1658
virtual element_iterator active_pid_elements_begin(processor_id_type proc_id)=0
Base class for Replicated and Distributed meshes.
virtual Elem * add_elem(Elem *e)=0
virtual element_iterator elements_end()=0
unsigned int n_levels(const MeshBase &mesh)
Definition: mesh_tools.C:568
virtual bool contract() libmesh_override
virtual const Node * query_node_ptr(const dof_id_type i) const =0
virtual void write(const std::string &name) libmesh_override
void clear_point_locator()
Definition: mesh_base.C:552
const Elem * child_ptr(unsigned int i) const
Definition: elem.h:2163
void libmesh_assert_valid_amr_elem_ids(const MeshBase &mesh)
Definition: mesh_tools.C:1119
RefinementState p_refinement_flag() const
Definition: elem.h:2236
void prepare_for_use(const bool skip_renumber_nodes_and_elements=false, const bool skip_find_neighbors=false)
Definition: mesh_base.C:174
OStreamProxy err(std::cerr)
subdomain_id_type subdomain_id() const
Definition: elem.h:1733
virtual unsigned int n_sides() const =0
void set_neighbor(const unsigned int i, Elem *n)
Definition: elem.h:1780
virtual void clear()
Definition: mesh_base.C:283
virtual unsigned int n_children() const =0
UnstructuredMesh(const Parallel::Communicator &comm_in, unsigned char dim=1)
unsigned int which_child_am_i(const Elem *e) const
Definition: elem.h:2203
std::set< GhostingFunctor * >::const_iterator ghosting_functors_begin() const
Definition: mesh_base.h:755
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual node_iterator nodes_end()=0
virtual element_iterator active_pid_elements_end(processor_id_type proc_id)=0
const Point & point(const unsigned int i) const
Definition: elem.h:1595
bool absolute_fuzzy_equals(const TypeVector< T > &rhs, Real tol=TOLERANCE) const
Definition: type_vector.h:938
virtual dof_id_type key(const unsigned int s) const =0
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
bool allow_renumbering() const
Definition: mesh_base.h:708
virtual unsigned int dim() const =0
unsigned int level() const
Definition: elem.h:2115
RefinementState refinement_flag() const
Definition: elem.h:2220
bool initialized()
Definition: libmesh.C:272
virtual Point centroid() const
Definition: elem.C:437
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1617
void libmesh_assert_valid_neighbors(const MeshBase &mesh, bool assert_valid_remote_elems=true)
Definition: mesh_tools.C:1686
virtual void delete_remote_elements()
Definition: mesh_base.h:161
dof_id_type id() const
Definition: dof_object.h:624
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
unique_id_type unique_id() const
Definition: dof_object.h:641
OStreamProxy out(std::cout)
virtual void reserve_elem(const dof_id_type ne)=0
virtual UniquePtr< Elem > side_ptr(unsigned int i)=0
virtual void renumber_nodes_and_elements()=0
uint8_t dof_id_type
Definition: id_types.h:64
processor_id_type processor_id() const
processor_id_type processor_id() const
Definition: dof_object.h:686
const RemoteElem * remote_elem
Definition: remote_elem.C:57