www.mooseframework.org
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
FeatureFloodCount::FeatureData Class Reference

#include <FeatureFloodCount.h>

Public Types

using container_type = std::set< dof_id_type >
 The primary underlying container type used to hold the data in each FeatureData. More...
 

Public Member Functions

 FeatureData ()
 
 FeatureData (std::size_t var_index, unsigned int local_index, processor_id_type rank, Status status)
 
 FeatureData (std::size_t var_index, Status status, unsigned int id=invalid_id, std::vector< MeshTools::BoundingBox > bboxes={MeshTools::BoundingBox()})
 
bool boundingBoxesIntersect (const FeatureData &rhs) const
 Determines if any of this FeatureData's bounding boxes overlap with the other FeatureData's bounding boxes. More...
 
bool mergeable (const FeatureData &rhs) const
 The routine called to see if two features are mergeable: More...
 
bool canConsolidate (const FeatureData &rhs) const
 This routine indicates whether two features can be consolidated, that is, one feature is reasonably expected to be part of another. More...
 
void expandBBox (const FeatureData &rhs)
 Located the overlapping bounding box between this Feature and the other Feature and expands that overlapping box accordingly. More...
 
void merge (FeatureData &&rhs)
 Merges another Feature Data into this one. More...
 
void consolidate (FeatureData &&rhs)
 Consolidates features, i.e. More...
 
void clear ()
 
bool operator< (const FeatureData &rhs) const
 Comparison operator for sorting individual FeatureDatas. More...
 
FeatureData duplicate () const
 
 FeatureData (FeatureData &&)=default
 
FeatureDataoperator= (FeatureData &&)=default
 
void updateBBoxExtremes (MeshBase &mesh)
 Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter. More...
 
void updateBBoxExtremes (MeshTools::BoundingBox &bbox, const MeshTools::BoundingBox &rhs_bbox)
 
bool halosIntersect (const FeatureData &rhs) const
 Determine if one of this FeaturesData's member sets intersects the other FeatureData's corresponding set. More...
 
bool periodicBoundariesIntersect (const FeatureData &rhs) const
 
bool ghostedIntersect (const FeatureData &rhs) const
 

Public Attributes

container_type _ghosted_ids
 Holds the ghosted ids for a feature (the ids which will be used for stitching. More...
 
container_type _local_ids
 Holds the local ids in the interior of a feature. More...
 
container_type _halo_ids
 Holds the ids surrounding the feature. More...
 
container_type _disjoint_halo_ids
 Holds halo ids that extend onto a non-topologically connected surface. More...
 
container_type _periodic_nodes
 Holds the nodes that belong to the feature on a periodic boundary. More...
 
std::size_t _var_index
 The Moose variable where this feature was found (often the "order parameter") More...
 
unsigned int _id
 An ID for this feature. More...
 
std::vector< MeshTools::BoundingBox > _bboxes
 The vector of bounding boxes completely enclosing this feature (multiple used with periodic constraints) More...
 
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
 Original processor/local ids. More...
 
dof_id_type _min_entity_id
 The minimum entity seen in the _local_ids, used for sorting features. More...
 
std::size_t _vol_count
 The count of entities contributing to the volume calculation. More...
 
Point _centroid
 The centroid of the feature (average of coordinates from entities participating in the volume calculation) More...
 
Status _status
 The status of a feature (used mostly in derived classes like the GrainTracker) More...
 
BoundaryIntersection _boundary_intersection
 Enumaration indicating boundary intersection status. More...
 

Private Member Functions

 FeatureData (const FeatureData &)=default
 2016-07-14 The INTEL compiler we are currently using (2013 with GCC 4.8) appears to have a bug introduced by the addition of the Point member in this structure. More...
 
FeatureDataoperator= (const FeatureData &)=default
 

Friends

std::ostream & operator<< (std::ostream &out, const FeatureData &feature)
 stream output operator More...
 

Detailed Description

Definition at line 135 of file FeatureFloodCount.h.

Member Typedef Documentation

◆ container_type

using FeatureFloodCount::FeatureData::container_type = std::set<dof_id_type>

The primary underlying container type used to hold the data in each FeatureData.

Supported types are std::set<dof_id_type> (with minor adjustmnets) or std::vector<dof_id_type>.

Note: Testing has shown that the vector container is nearly 10x faster. There's really no reason to use sets.

Definition at line 146 of file FeatureFloodCount.h.

Constructor & Destructor Documentation

◆ FeatureData() [1/5]

FeatureFloodCount::FeatureData::FeatureData ( )
inline

Definition at line 148 of file FeatureFloodCount.h.

Referenced by duplicate().

◆ FeatureData() [2/5]

FeatureFloodCount::FeatureData::FeatureData ( std::size_t  var_index,
unsigned int  local_index,
processor_id_type  rank,
Status  status 
)
inline

Definition at line 150 of file FeatureFloodCount.h.

154  : FeatureData(var_index, status)
155  {
156  _orig_ids = {std::make_pair(rank, local_index)};
157  }
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.

◆ FeatureData() [3/5]

FeatureFloodCount::FeatureData::FeatureData ( std::size_t  var_index,
Status  status,
unsigned int  id = invalid_id,
std::vector< MeshTools::BoundingBox >  bboxes = {MeshTools::BoundingBox()} 
)
inline

Definition at line 159 of file FeatureFloodCount.h.

162  {MeshTools::BoundingBox()})
163  : _var_index(var_index),
164  _id(id),
165  _bboxes(bboxes), // Assume at least one bounding box
166  _min_entity_id(DofObject::invalid_id),
167  _vol_count(0),
168  _status(status),
170  {
171  }
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
dof_id_type _min_entity_id
The minimum entity seen in the _local_ids, used for sorting features.
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
BoundaryIntersection _boundary_intersection
Enumaration indicating boundary intersection status.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
std::size_t _vol_count
The count of entities contributing to the volume calculation.
unsigned int _id
An ID for this feature.

◆ FeatureData() [4/5]

FeatureFloodCount::FeatureData::FeatureData ( FeatureData &&  )
default

◆ FeatureData() [5/5]

FeatureFloodCount::FeatureData::FeatureData ( const FeatureData )
privatedefault

2016-07-14 The INTEL compiler we are currently using (2013 with GCC 4.8) appears to have a bug introduced by the addition of the Point member in this structure.

Even though it supports move semantics on other non-POD types like libMesh::BoundingBox, it fails to compile this class with the "centroid" member. Specifically, it supports the move operation into the vector type but fails to work with the bracket operator on std::map and the std::sort algorithm used in this class. It does work with std::map::emplace() but that syntax is much less appealing and still doesn't work around the issue. For now, I'm allowing the copy constructor to be called where it shouldn't so that this class works under the Intel compiler but there may be a degradation in performance in that case.
We do not expect these objects to ever be copied. This is important since they are stored in standard containers directly. To enforce this, we are explicitly marking these methods private. They can be triggered through an explicit call to "duplicate".

Member Function Documentation

◆ boundingBoxesIntersect()

bool FeatureFloodCount::FeatureData::boundingBoxesIntersect ( const FeatureData rhs) const

Determines if any of this FeatureData's bounding boxes overlap with the other FeatureData's bounding boxes.

Definition at line 1874 of file FeatureFloodCount.C.

1875 {
1876  // See if any of the bounding boxes in either FeatureData object intersect
1877  for (const auto & bbox_lhs : _bboxes)
1878  for (const auto & bbox_rhs : rhs._bboxes)
1879  if (bbox_lhs.intersects(bbox_rhs, libMesh::TOLERANCE * libMesh::TOLERANCE))
1880  return true;
1881 
1882  return false;
1883 }
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...

◆ canConsolidate()

bool FeatureFloodCount::FeatureData::canConsolidate ( const FeatureData rhs) const

This routine indicates whether two features can be consolidated, that is, one feature is reasonably expected to be part of another.

This is different than mergable in that a portion of the feature is expected to be completely identical. This happens in the distributed work scenario when a feature that is partially owned by a processor is merged on a different processor (where local entities are not sent or available). However, later that feature ends back up on the original processor and just needs to be consolidated.

Definition at line 1919 of file FeatureFloodCount.C.

1920 {
1921  for (const auto & orig_id_pair1 : _orig_ids)
1922  for (const auto & orig_id_pair2 : rhs._orig_ids)
1923  if (orig_id_pair1 == orig_id_pair2)
1924  return true;
1925 
1926  return false;
1927 }
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.

◆ clear()

void FeatureFloodCount::FeatureData::clear ( )

Definition at line 2043 of file FeatureFloodCount.C.

2044 {
2045  _local_ids.clear();
2046  _periodic_nodes.clear();
2047  _halo_ids.clear();
2048  _disjoint_halo_ids.clear();
2049  _ghosted_ids.clear();
2050  _bboxes.clear();
2051  _orig_ids.clear();
2052 }
container_type _halo_ids
Holds the ids surrounding the feature.
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.
container_type _local_ids
Holds the local ids in the interior of a feature.
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.

◆ consolidate()

void FeatureFloodCount::FeatureData::consolidate ( FeatureData &&  rhs)

Consolidates features, i.e.

merges local entities but leaves everything else untouched.

Definition at line 2024 of file FeatureFloodCount.C.

2025 {
2026  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
2027  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
2028 
2029  FeatureData::container_type set_union;
2030  FeatureFloodCount::reserve(_local_ids, _local_ids.size() + rhs._local_ids.size());
2031  std::set_union(_local_ids.begin(),
2032  _local_ids.end(),
2033  rhs._local_ids.begin(),
2034  rhs._local_ids.end(),
2035  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2036  _local_ids.swap(set_union);
2037 
2038  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
2039  "Flags in invalid state");
2040 }
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
static void reserve(std::set< T > &, std::size_t)
container_type _local_ids
Holds the local ids in the interior of a feature.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
unsigned int _id
An ID for this feature.

◆ duplicate()

FeatureData FeatureFloodCount::FeatureData::duplicate ( ) const
inline

Definition at line 309 of file FeatureFloodCount.h.

◆ expandBBox()

void FeatureFloodCount::FeatureData::expandBBox ( const FeatureData rhs)

Located the overlapping bounding box between this Feature and the other Feature and expands that overlapping box accordingly.

Definition at line 2055 of file FeatureFloodCount.C.

2056 {
2057  std::vector<bool> intersected_boxes(rhs._bboxes.size(), false);
2058 
2059  auto box_expanded = false;
2060  for (auto & bbox : _bboxes)
2061  for (MooseIndex(rhs._bboxes) j = 0; j < rhs._bboxes.size(); ++j)
2062  {
2063  if (bbox.intersects(rhs._bboxes[j], libMesh::TOLERANCE * libMesh::TOLERANCE))
2064  {
2065  updateBBoxExtremes(bbox, rhs._bboxes[j]);
2066  intersected_boxes[j] = true;
2067  box_expanded = true;
2068  }
2069  }
2070 
2071  // Error check
2072  if (!box_expanded)
2073  {
2074  std::ostringstream oss;
2075  oss << "LHS BBoxes:\n";
2076  for (MooseIndex(_bboxes) i = 0; i < _bboxes.size(); ++i)
2077  oss << "Max: " << _bboxes[i].max() << " Min: " << _bboxes[i].min() << '\n';
2078 
2079  oss << "RHS BBoxes:\n";
2080  for (MooseIndex(rhs._bboxes) i = 0; i < rhs._bboxes.size(); ++i)
2081  oss << "Max: " << rhs._bboxes[i].max() << " Min: " << rhs._bboxes[i].min() << '\n';
2082 
2083  ::mooseError("No Bounding Boxes Expanded - This is a catastrophic error!\n", oss.str());
2084  }
2085 
2086  // Any bounding box in the rhs vector that doesn't intersect
2087  // needs to be appended to the lhs vector
2088  for (MooseIndex(intersected_boxes) j = 0; j < intersected_boxes.size(); ++j)
2089  if (!intersected_boxes[j])
2090  _bboxes.push_back(rhs._bboxes[j]);
2091 }
void updateBBoxExtremes(MeshBase &mesh)
Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter...
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...

◆ ghostedIntersect()

bool FeatureFloodCount::FeatureData::ghostedIntersect ( const FeatureData rhs) const

Definition at line 1902 of file FeatureFloodCount.C.

1903 {
1904  return setsIntersect(
1905  _ghosted_ids.begin(), _ghosted_ids.end(), rhs._ghosted_ids.begin(), rhs._ghosted_ids.end());
1906 }
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
static bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
This method detects whether two sets intersect without building a result set.

◆ halosIntersect()

bool FeatureFloodCount::FeatureData::halosIntersect ( const FeatureData rhs) const

Determine if one of this FeaturesData's member sets intersects the other FeatureData's corresponding set.

Definition at line 1886 of file FeatureFloodCount.C.

1887 {
1888  return setsIntersect(
1889  _halo_ids.begin(), _halo_ids.end(), rhs._halo_ids.begin(), rhs._halo_ids.end());
1890 }
container_type _halo_ids
Holds the ids surrounding the feature.
static bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
This method detects whether two sets intersect without building a result set.

◆ merge()

void FeatureFloodCount::FeatureData::merge ( FeatureData &&  rhs)

Merges another Feature Data into this one.

This method leaves rhs in an inconsistent state.

Even though we've determined that these two partial regions need to be merged, we don't necessarily know if the _ghost_ids intersect. We could be in this branch because the periodic boundaries intersect but that doesn't tell us anything about whether or not the ghost_region also intersects. If the _ghost_ids intersect, that means that we are merging along a periodic boundary, not across one. In this case the bounding box(s) need to be expanded.

If we had a physical intersection, we need to expand boxes. If we had a virtual (periodic) intersection we need to preserve all of the boxes from each of the regions' sets.

Combine the status flags: Currently we only expect to combine CLEAR and INACTIVE. Any other combination is currently a logic error. In this case of CLEAR and INACTIVE though, we want to make sure that CLEAR wins.

Definition at line 1930 of file FeatureFloodCount.C.

1931 {
1932  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
1933  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
1934 
1935  FeatureData::container_type set_union;
1936 
1937  FeatureFloodCount::reserve(set_union, _local_ids.size() + rhs._local_ids.size());
1938  std::set_union(_local_ids.begin(),
1939  _local_ids.end(),
1940  rhs._local_ids.begin(),
1941  rhs._local_ids.end(),
1942  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1943  _local_ids.swap(set_union);
1944 
1945  set_union.clear();
1946  FeatureFloodCount::reserve(set_union, _periodic_nodes.size() + rhs._periodic_nodes.size());
1947  std::set_union(_periodic_nodes.begin(),
1948  _periodic_nodes.end(),
1949  rhs._periodic_nodes.begin(),
1950  rhs._periodic_nodes.end(),
1951  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1952  _periodic_nodes.swap(set_union);
1953 
1954  set_union.clear();
1955  FeatureFloodCount::reserve(set_union, _ghosted_ids.size() + rhs._ghosted_ids.size());
1956  std::set_union(_ghosted_ids.begin(),
1957  _ghosted_ids.end(),
1958  rhs._ghosted_ids.begin(),
1959  rhs._ghosted_ids.end(),
1960  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1961 
1969  bool physical_intersection = (_ghosted_ids.size() + rhs._ghosted_ids.size() > set_union.size());
1970  _ghosted_ids.swap(set_union);
1971 
1976  if (physical_intersection)
1977  expandBBox(rhs);
1978  else
1979  std::move(rhs._bboxes.begin(), rhs._bboxes.end(), std::back_inserter(_bboxes));
1980 
1981  set_union.clear();
1982  FeatureFloodCount::reserve(set_union, _disjoint_halo_ids.size() + rhs._disjoint_halo_ids.size());
1983  std::set_union(_disjoint_halo_ids.begin(),
1984  _disjoint_halo_ids.end(),
1985  rhs._disjoint_halo_ids.begin(),
1986  rhs._disjoint_halo_ids.end(),
1987  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1988  _disjoint_halo_ids.swap(set_union);
1989 
1990  set_union.clear();
1991  FeatureFloodCount::reserve(set_union, _halo_ids.size() + rhs._halo_ids.size());
1992  std::set_union(_halo_ids.begin(),
1993  _halo_ids.end(),
1994  rhs._halo_ids.begin(),
1995  rhs._halo_ids.end(),
1996  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1997  _halo_ids.swap(set_union);
1998 
1999  // Keep track of the original ids so we can notify other processors of the local to global mapping
2000  _orig_ids.splice(_orig_ids.end(), std::move(rhs._orig_ids));
2001 
2002  // Update the min feature id
2003  _min_entity_id = std::min(_min_entity_id, rhs._min_entity_id);
2004 
2010  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
2011  "Flags in invalid state");
2012 
2013  // Logical AND here to combine flags (INACTIVE & INACTIVE == INACTIVE, all other combos are CLEAR)
2014  _status &= rhs._status;
2015 
2016  // Logical OR here to make sure we maintain boundary intersection attribute when joining
2017  _boundary_intersection |= rhs._boundary_intersection;
2018 
2019  _vol_count += rhs._vol_count;
2020  _centroid += rhs._centroid;
2021 }
Point _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
container_type _halo_ids
Holds the ids surrounding the feature.
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
void expandBBox(const FeatureData &rhs)
Located the overlapping bounding box between this Feature and the other Feature and expands that over...
dof_id_type _min_entity_id
The minimum entity seen in the _local_ids, used for sorting features.
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.
static void reserve(std::set< T > &, std::size_t)
container_type _local_ids
Holds the local ids in the interior of a feature.
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.
BoundaryIntersection _boundary_intersection
Enumaration indicating boundary intersection status.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
std::size_t _vol_count
The count of entities contributing to the volume calculation.
unsigned int _id
An ID for this feature.

◆ mergeable()

bool FeatureFloodCount::FeatureData::mergeable ( const FeatureData rhs) const

The routine called to see if two features are mergeable:

  • Features must be represented by the same variable (_var_index)
  • Features must either intersect on halos or
  • Features must intersect on a periodic BC

Optimization: We may use the bounding boxes as a coarse-level check before checking halo intersection.

Definition at line 1909 of file FeatureFloodCount.C.

Referenced by PolycrystalUserObjectBase::areFeaturesMergeable(), and FeatureFloodCount::areFeaturesMergeable().

1910 {
1911  return (_var_index == rhs._var_index && // the sets have matching variable indices and
1912  ((boundingBoxesIntersect(rhs) && // (if the feature's bboxes intersect and
1913  ghostedIntersect(rhs)) // the ghosted entities also intersect)
1914  || // or
1915  periodicBoundariesIntersect(rhs))); // periodic node sets intersect)
1916 }
bool boundingBoxesIntersect(const FeatureData &rhs) const
Determines if any of this FeatureData&#39;s bounding boxes overlap with the other FeatureData&#39;s bounding ...
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
bool ghostedIntersect(const FeatureData &rhs) const
bool periodicBoundariesIntersect(const FeatureData &rhs) const

◆ operator<()

bool FeatureFloodCount::FeatureData::operator< ( const FeatureData rhs) const
inline

Comparison operator for sorting individual FeatureDatas.

Definition at line 246 of file FeatureFloodCount.h.

247  {
248  if (_id != invalid_id)
249  {
250  mooseAssert(rhs._id != invalid_id, "Asymmetric setting of ids detected during sort");
251 
252  // Sort based on ids
253  return _id < rhs._id;
254  }
255  else
256  // Sort based on processor independent information (mesh and variable info)
257  return _var_index < rhs._var_index ||
258  (_var_index == rhs._var_index && _min_entity_id < rhs._min_entity_id);
259  }
dof_id_type _min_entity_id
The minimum entity seen in the _local_ids, used for sorting features.
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
static const unsigned int invalid_id
unsigned int _id
An ID for this feature.

◆ operator=() [1/2]

FeatureData& FeatureFloodCount::FeatureData::operator= ( FeatureData &&  )
default

◆ operator=() [2/2]

FeatureData& FeatureFloodCount::FeatureData::operator= ( const FeatureData )
privatedefault

◆ periodicBoundariesIntersect()

bool FeatureFloodCount::FeatureData::periodicBoundariesIntersect ( const FeatureData rhs) const

Definition at line 1893 of file FeatureFloodCount.C.

1894 {
1895  return setsIntersect(_periodic_nodes.begin(),
1896  _periodic_nodes.end(),
1897  rhs._periodic_nodes.begin(),
1898  rhs._periodic_nodes.end());
1899 }
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.
static bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
This method detects whether two sets intersect without building a result set.

◆ updateBBoxExtremes() [1/2]

void FeatureFloodCount::FeatureData::updateBBoxExtremes ( MeshBase &  mesh)

Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter.

Now we need to find how many distinct topologically disconnected sets of elements we have. We've already removed elements that are part of the primary halo, we'll start by assuming that element left is part of the same disjoint set. For each element, we'll see if it is a neighbor of any other element in the current set. If it's not, then it must be part of yet another set. The process repeats until every element is processed and put in the right bucket.

Definition at line 1779 of file FeatureFloodCount.C.

1780 {
1781  // First update the primary bounding box (all topologically connected)
1782  for (auto & halo_id : _halo_ids)
1783  updateBBoxExtremesHelper(_bboxes[0], *mesh.elem(halo_id));
1784  for (auto & ghost_id : _ghosted_ids)
1785  updateBBoxExtremesHelper(_bboxes[0], *mesh.elem(ghost_id));
1786 
1787  // Remove all of the IDs that are in the primary region
1788  std::list<dof_id_type> disjoint_elem_id_list;
1789  std::set_difference(_disjoint_halo_ids.begin(),
1790  _disjoint_halo_ids.end(),
1791  _halo_ids.begin(),
1792  _halo_ids.end(),
1793  std::insert_iterator<std::list<dof_id_type>>(disjoint_elem_id_list,
1794  disjoint_elem_id_list.begin()));
1795 
1796  if (!disjoint_elem_id_list.empty())
1797  {
1806  std::list<std::list<dof_id_type>> disjoint_regions;
1807  for (auto elem_id : _disjoint_halo_ids)
1808  {
1809  disjoint_regions.emplace_back(std::list<dof_id_type>({elem_id}));
1810  }
1811 
1812  for (auto it1 = disjoint_regions.begin(); it1 != disjoint_regions.end(); /* No increment */)
1813  {
1814  bool merge_occured = false;
1815  for (auto it2 = disjoint_regions.begin(); it2 != disjoint_regions.end(); ++it2)
1816  {
1817  if (it1 != it2 && areElemListsMergeable(*it1, *it2, mesh))
1818  {
1819  it2->splice(it2->begin(), *it1);
1820 
1821  disjoint_regions.emplace_back(std::move(*it2));
1822  disjoint_regions.erase(it2);
1823  it1 = disjoint_regions.erase(it1);
1824 
1825  merge_occured = true;
1826 
1827  break;
1828  }
1829  }
1830 
1831  if (!merge_occured)
1832  ++it1;
1833  }
1834 
1835  // Finally create new bounding boxes for each disjoint region
1836  auto num_regions = disjoint_regions.size();
1837  // We have num_regions *new* bounding boxes plus the existing bounding box
1838  _bboxes.resize(num_regions + 1);
1839 
1840  decltype(num_regions) region = 1;
1841  for (const auto list_ref : disjoint_regions)
1842  {
1843  for (const auto elem_id : list_ref)
1844  updateBBoxExtremesHelper(_bboxes[region], *mesh.elem_ptr(elem_id));
1845 
1846  FeatureData::container_type set_union;
1847  FeatureFloodCount::reserve(set_union, _halo_ids.size() + _disjoint_halo_ids.size());
1848  std::set_union(
1849  _halo_ids.begin(),
1850  _halo_ids.end(),
1851  _disjoint_halo_ids.begin(),
1852  _disjoint_halo_ids.end(),
1853  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1854  _halo_ids.swap(set_union);
1855 
1856  _disjoint_halo_ids.clear();
1857  ++region;
1858  }
1859  }
1860 }
container_type _halo_ids
Holds the ids surrounding the feature.
bool areElemListsMergeable(const std::list< dof_id_type > &elem_list1, const std::list< dof_id_type > &elem_list2, MeshBase &mesh)
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
std::vector< MeshTools::BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
void updateBBoxExtremesHelper(MeshTools::BoundingBox &bbox, const Point &node)
static void reserve(std::set< T > &, std::size_t)

◆ updateBBoxExtremes() [2/2]

void FeatureFloodCount::FeatureData::updateBBoxExtremes ( MeshTools::BoundingBox &  bbox,
const MeshTools::BoundingBox &  rhs_bbox 
)

Definition at line 1863 of file FeatureFloodCount.C.

1865 {
1866  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
1867  {
1868  bbox.min()(i) = std::min(bbox.min()(i), rhs_bbox.min()(i));
1869  bbox.max()(i) = std::max(bbox.max()(i), rhs_bbox.max()(i));
1870  }
1871 }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const FeatureData feature 
)
friend

stream output operator

Definition at line 2094 of file FeatureFloodCount.C.

2095 {
2096  static const bool debug = true;
2097 
2098  out << "Grain ID: ";
2099  if (feature._id != FeatureFloodCount::invalid_id)
2100  out << feature._id;
2101  else
2102  out << "invalid";
2103 
2104  if (debug)
2105  {
2106  out << "\nGhosted Entities: ";
2107  for (auto ghosted_id : feature._ghosted_ids)
2108  out << ghosted_id << " ";
2109 
2110  out << "\nLocal Entities: ";
2111  for (auto local_id : feature._local_ids)
2112  out << local_id << " ";
2113 
2114  out << "\nHalo Entities: ";
2115  for (auto halo_id : feature._halo_ids)
2116  out << halo_id << " ";
2117 
2118  out << "\nPeriodic Node IDs: ";
2119  for (auto periodic_node : feature._periodic_nodes)
2120  out << periodic_node << " ";
2121  }
2122 
2123  out << "\nBBoxes:";
2124  Real volume = 0;
2125  for (const auto & bbox : feature._bboxes)
2126  {
2127  out << "\nMax: " << bbox.max() << " Min: " << bbox.min();
2128  volume += (bbox.max()(0) - bbox.min()(0)) * (bbox.max()(1) - bbox.min()(1)) *
2129  (MooseUtils::absoluteFuzzyEqual(bbox.max()(2), bbox.min()(2))
2130  ? 1
2131  : bbox.max()(2) - bbox.min()(2));
2132  }
2133 
2134  out << "\nStatus: ";
2135  if (feature._status == FeatureFloodCount::Status::CLEAR)
2136  out << "CLEAR";
2137  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::MARKED))
2138  out << " MARKED";
2139  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::DIRTY))
2140  out << " DIRTY";
2141  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::INACTIVE))
2142  out << " INACTIVE";
2143 
2144  if (debug)
2145  {
2146  out << "\nOrig IDs (rank, index): ";
2147  for (const auto & orig_pair : feature._orig_ids)
2148  out << '(' << orig_pair.first << ", " << orig_pair.second << ") ";
2149  out << "\nVar_index: " << feature._var_index;
2150  out << "\nMin Entity ID: " << feature._min_entity_id;
2151  }
2152  out << "\n\n";
2153 
2154  return out;
2155 }
static const unsigned int invalid_id

Member Data Documentation

◆ _bboxes

std::vector<MeshTools::BoundingBox> FeatureFloodCount::FeatureData::_bboxes

The vector of bounding boxes completely enclosing this feature (multiple used with periodic constraints)

Definition at line 288 of file FeatureFloodCount.h.

Referenced by boundingBoxesIntersect(), dataLoad(), dataStore(), expandBBox(), operator<<(), updateBBoxExtremes(), and FeatureFloodCount::visitElementalNeighbors().

◆ _boundary_intersection

BoundaryIntersection FeatureFloodCount::FeatureData::_boundary_intersection

Enumaration indicating boundary intersection status.

Definition at line 307 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), and FeatureFloodCount::updateBoundaryIntersections().

◆ _centroid

Point FeatureFloodCount::FeatureData::_centroid

The centroid of the feature (average of coordinates from entities participating in the volume calculation)

Definition at line 301 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), and FeatureFloodCount::flood().

◆ _disjoint_halo_ids

container_type FeatureFloodCount::FeatureData::_disjoint_halo_ids

Holds halo ids that extend onto a non-topologically connected surface.

Definition at line 275 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), updateBBoxExtremes(), and FeatureFloodCount::visitNeighborsHelper().

◆ _ghosted_ids

container_type FeatureFloodCount::FeatureData::_ghosted_ids

Holds the ghosted ids for a feature (the ids which will be used for stitching.

Definition at line 265 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), ghostedIntersect(), operator<<(), updateBBoxExtremes(), and FeatureFloodCount::visitNeighborsHelper().

◆ _halo_ids

container_type FeatureFloodCount::FeatureData::_halo_ids

◆ _id

unsigned int FeatureFloodCount::FeatureData::_id

◆ _local_ids

container_type FeatureFloodCount::FeatureData::_local_ids

Holds the local ids in the interior of a feature.

This data structure is only maintained on the local processor

Definition at line 269 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::appendPeriodicNeighborNodes(), FeatureFloodCount::flood(), operator<<(), FeatureFloodCount::updateBoundaryIntersections(), and FeatureFloodCount::visitNeighborsHelper().

◆ _min_entity_id

dof_id_type FeatureFloodCount::FeatureData::_min_entity_id

The minimum entity seen in the _local_ids, used for sorting features.

Definition at line 294 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), operator<(), and operator<<().

◆ _orig_ids

std::list<std::pair<processor_id_type, unsigned int> > FeatureFloodCount::FeatureData::_orig_ids

Original processor/local ids.

Definition at line 291 of file FeatureFloodCount.h.

Referenced by canConsolidate(), dataLoad(), dataStore(), FeatureData(), and operator<<().

◆ _periodic_nodes

container_type FeatureFloodCount::FeatureData::_periodic_nodes

Holds the nodes that belong to the feature on a periodic boundary.

Definition at line 278 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::appendPeriodicNeighborNodes(), dataLoad(), dataStore(), operator<<(), and periodicBoundariesIntersect().

◆ _status

Status FeatureFloodCount::FeatureData::_status

The status of a feature (used mostly in derived classes like the GrainTracker)

Definition at line 304 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), FeatureFloodCount::isNewFeatureOrConnectedRegion(), and operator<<().

◆ _var_index

std::size_t FeatureFloodCount::FeatureData::_var_index

The Moose variable where this feature was found (often the "order parameter")

Definition at line 281 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), mergeable(), operator<(), and operator<<().

◆ _vol_count

std::size_t FeatureFloodCount::FeatureData::_vol_count

The count of entities contributing to the volume calculation.

Definition at line 297 of file FeatureFloodCount.h.

Referenced by dataLoad(), dataStore(), and FeatureFloodCount::flood().


The documentation for this class was generated from the following files: