https://mooseframework.inl.gov
CacheChangedListsThread.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 
12 #include "libmesh/elem.h"
13 
16 {
17 }
18 
19 // Splitting Constructor
22 {
23 }
24 
26 
27 void
29 {
30  if (_mesh.doingPRefinement())
31  {
32  // When we p-refine an active child element this can lead to p-refinement of the parent as well.
33  // We don't care about inactive parents
34  if (elem->active())
35  {
36  if (elem->p_refinement_flag() == Elem::JUST_REFINED)
37  _refined_elements.push_back(elem);
38  else if (elem->p_refinement_flag() == Elem::JUST_COARSENED)
39  _coarsened_elements.push_back(elem);
40  }
41  }
42  else
43  {
44  // Cache any parents of local elements that have just been refined
45  // away.
46  //
47  // The parent itself might *not* be local, because only some of its
48  // new children are. Make sure to cache every such case exactly once.
49  if (elem->refinement_flag() == Elem::JUST_REFINED)
50  {
51  const Elem * const parent = elem->parent();
52  const unsigned int child_num = parent->which_child_am_i(elem);
53 
54  bool im_the_lowest_local_child = true;
55  for (const auto c : make_range(child_num))
56  if (parent->child_ptr(c) && parent->child_ptr(c) != remote_elem &&
57  parent->child_ptr(c)->processor_id() == elem->processor_id())
58  im_the_lowest_local_child = false;
59 
60  if (im_the_lowest_local_child)
61  _refined_elements.push_back(parent);
62  }
63 
64  else if (elem->refinement_flag() == Elem::JUST_COARSENED)
65  {
66  if (elem->has_children())
67  {
68  _coarsened_elements.push_back(elem);
69 
70  std::vector<const Elem *> & children = _coarsened_element_children[elem];
71 
72  for (unsigned int child = 0; child < elem->n_children(); child++)
73  children.push_back(elem->child_ptr(child));
74  }
75  }
76  }
77 }
78 
79 void
81 {
82  _refined_elements.insert(
83  _refined_elements.end(), y._refined_elements.begin(), y._refined_elements.end());
84  _coarsened_elements.insert(
88 }
CacheChangedListsThread(MooseMesh &mesh)
MeshBase & mesh
void join(const CacheChangedListsThread &y)
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
virtual void onElement(const Elem *elem) override
Assembly of the element (not including surface assembly)
tbb::split split
std::map< const Elem *, std::vector< const Elem * > > _coarsened_element_children
Map of Parent elements to children elements for elements that were just coarsened.
std::vector< const Elem * > _refined_elements
The elements that were just refined.
IntRange< T > make_range(T beg, T end)
Base class for assembly-like calculations.
void doingPRefinement(bool doing_p_refinement)
Indicate whether the kind of adaptivity we&#39;re doing is p-refinement.
Definition: MooseMesh.h:1347
std::vector< const Elem * > _coarsened_elements
The elements that were just coarsened.
const RemoteElem * remote_elem