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::vector< 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< BoundingBox > bboxes={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 mergeBBoxes (std::vector< BoundingBox > &bboxes, bool physical_intersection)
 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 (BoundingBox &bbox, const 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< 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
 Enumeration indicating boundary intersection status. More...
 

Private Member Functions

 FeatureData (const FeatureData &)=default
 We do not expect these objects to ever be copied. More...
 
FeatureDataoperator= (const FeatureData &)=default
 

Friends

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

Detailed Description

Definition at line 138 of file FeatureFloodCount.h.

Member Typedef Documentation

◆ container_type

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

Supported types are std::set<dof_id_type> or std::vector<dof_id_type>.

Note: Testing has shown that vector container may be slightly faster, but I believe much more data needs to be gathered to be sure. Perhaps more work could be performed to keep sorted sets to eliminate any extra work we do by occasionally performing a linear find or resorting the vector could help. For now, vector it is.

Definition at line 150 of file FeatureFloodCount.h.

Constructor & Destructor Documentation

◆ FeatureData() [1/5]

FeatureFloodCount::FeatureData::FeatureData ( )
inline

Definition at line 152 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 154 of file FeatureFloodCount.h.

158  : FeatureData(var_index, status)
159  {
160  _orig_ids = {std::make_pair(rank, local_index)};
161  }
MPI_Status status
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< BoundingBox >  bboxes = {BoundingBox()} 
)
inline

Definition at line 163 of file FeatureFloodCount.h.

166  {BoundingBox()})
167  : _var_index(var_index),
168  _id(id),
169  _bboxes(bboxes), // Assume at least one bounding box
170  _min_entity_id(DofObject::invalid_id),
171  _vol_count(0),
172  _status(status),
174  {
175  }
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
MPI_Status status
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
Enumeration 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

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 1953 of file FeatureFloodCount.C.

1954 {
1955  // See if any of the bounding boxes in either FeatureData object intersect
1956  for (const auto & bbox_lhs : _bboxes)
1957  for (const auto & bbox_rhs : rhs._bboxes)
1958  if (bbox_lhs.intersects(bbox_rhs, libMesh::TOLERANCE * libMesh::TOLERANCE))
1959  return true;
1960 
1961  return false;
1962 }
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
static constexpr Real TOLERANCE

◆ 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 1993 of file FeatureFloodCount.C.

1994 {
1995  for (const auto & orig_id_pair1 : _orig_ids)
1996  for (const auto & orig_id_pair2 : rhs._orig_ids)
1997  if (orig_id_pair1 == orig_id_pair2)
1998  return true;
1999 
2000  return false;
2001 }
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.

◆ clear()

void FeatureFloodCount::FeatureData::clear ( )

Definition at line 2117 of file FeatureFloodCount.C.

2118 {
2119  _local_ids.clear();
2120  _periodic_nodes.clear();
2121  _halo_ids.clear();
2122  _disjoint_halo_ids.clear();
2123  _ghosted_ids.clear();
2124  _bboxes.clear();
2125  _orig_ids.clear();
2126 }
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
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.
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 2098 of file FeatureFloodCount.C.

2099 {
2100  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
2101  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
2102 
2103  FeatureData::container_type set_union;
2104  FeatureFloodCount::reserve(_local_ids, _local_ids.size() + rhs._local_ids.size());
2105  std::set_union(_local_ids.begin(),
2106  _local_ids.end(),
2107  rhs._local_ids.begin(),
2108  rhs._local_ids.end(),
2109  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2110  _local_ids.swap(set_union);
2111 
2112  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
2113  "Flags in invalid state");
2114 }
std::vector< 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 313 of file FeatureFloodCount.h.

◆ ghostedIntersect()

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

Definition at line 1977 of file FeatureFloodCount.C.

1978 {
1979  return MooseUtils::setsIntersect(_ghosted_ids, rhs._ghosted_ids);
1980 }
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)

◆ 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 1965 of file FeatureFloodCount.C.

Referenced by GrainTracker::attemptGrainRenumber().

1966 {
1967  return MooseUtils::setsIntersect(_halo_ids, rhs._halo_ids);
1968 }
container_type _halo_ids
Holds the ids surrounding the feature.
bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)

◆ 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 2004 of file FeatureFloodCount.C.

2005 {
2006  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
2007  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
2008 
2009  FeatureData::container_type set_union;
2010 
2011  FeatureFloodCount::reserve(set_union, _local_ids.size() + rhs._local_ids.size());
2012  std::set_union(_local_ids.begin(),
2013  _local_ids.end(),
2014  rhs._local_ids.begin(),
2015  rhs._local_ids.end(),
2016  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2017  _local_ids.swap(set_union);
2018 
2019  set_union.clear();
2020  FeatureFloodCount::reserve(set_union, _periodic_nodes.size() + rhs._periodic_nodes.size());
2021  std::set_union(_periodic_nodes.begin(),
2022  _periodic_nodes.end(),
2023  rhs._periodic_nodes.begin(),
2024  rhs._periodic_nodes.end(),
2025  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2026  _periodic_nodes.swap(set_union);
2027 
2028  set_union.clear();
2029  FeatureFloodCount::reserve(set_union, _ghosted_ids.size() + rhs._ghosted_ids.size());
2030  std::set_union(_ghosted_ids.begin(),
2031  _ghosted_ids.end(),
2032  rhs._ghosted_ids.begin(),
2033  rhs._ghosted_ids.end(),
2034  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2035 
2043  bool physical_intersection = (_ghosted_ids.size() + rhs._ghosted_ids.size() > set_union.size());
2044  _ghosted_ids.swap(set_union);
2045 
2050  _bboxes.reserve(_bboxes.size() + rhs._bboxes.size());
2051  std::copy(rhs._bboxes.begin(), rhs._bboxes.end(), std::back_inserter(_bboxes));
2052 
2053  mergeBBoxes(_bboxes, physical_intersection);
2054 
2055  set_union.clear();
2056  FeatureFloodCount::reserve(set_union, _disjoint_halo_ids.size() + rhs._disjoint_halo_ids.size());
2057  std::set_union(_disjoint_halo_ids.begin(),
2058  _disjoint_halo_ids.end(),
2059  rhs._disjoint_halo_ids.begin(),
2060  rhs._disjoint_halo_ids.end(),
2061  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2062  _disjoint_halo_ids.swap(set_union);
2063 
2064  set_union.clear();
2065  FeatureFloodCount::reserve(set_union, _halo_ids.size() + rhs._halo_ids.size());
2066  std::set_union(_halo_ids.begin(),
2067  _halo_ids.end(),
2068  rhs._halo_ids.begin(),
2069  rhs._halo_ids.end(),
2070  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
2071  _halo_ids.swap(set_union);
2072 
2073  // Keep track of the original ids so we can notify other processors of the local to global mapping
2074  _orig_ids.splice(_orig_ids.end(), std::move(rhs._orig_ids));
2075 
2076  // Update the min feature id
2077  _min_entity_id = std::min(_min_entity_id, rhs._min_entity_id);
2078 
2084  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
2085  "Flags in invalid state");
2086 
2087  // Logical AND here to combine flags (INACTIVE & INACTIVE == INACTIVE, all other combos are CLEAR)
2088  _status &= rhs._status;
2089 
2090  // Logical OR here to make sure we maintain boundary intersection attribute when joining
2091  _boundary_intersection |= rhs._boundary_intersection;
2092 
2093  _vol_count += rhs._vol_count;
2094  _centroid += rhs._centroid;
2095 }
Point _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
container_type _halo_ids
Holds the ids surrounding the feature.
std::vector< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
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.
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
Enumeration indicating boundary intersection status.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
void mergeBBoxes(std::vector< BoundingBox > &bboxes, bool physical_intersection)
Located the overlapping bounding box between this Feature and the other Feature and expands that over...
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 1983 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::areFeaturesMergeable().

1984 {
1985  return (_var_index == rhs._var_index && // the sets have matching variable indices and
1986  ((boundingBoxesIntersect(rhs) && // (if the feature's bboxes intersect and
1987  ghostedIntersect(rhs)) // the ghosted entities also intersect)
1988  || // or
1989  periodicBoundariesIntersect(rhs))); // periodic node sets intersect)
1990 }
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

◆ mergeBBoxes()

void FeatureFloodCount::FeatureData::mergeBBoxes ( std::vector< BoundingBox > &  bboxes,
bool  physical_intersection 
)

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

It's possible to iterate over these disjoint elements in a way such that bounding boxes in geometrically related region won't overlap on a single pass. Imagine having three elements across a periodic boundary that represent the halo that just bleeds over. If we attempt to merge the first and third bounding boxes, they won't intersect without having the second bounding box there to link them together. We'll have to continue to merge bounding boxes until convergence.

Now copy the list back into the original vector.

Definition at line 2129 of file FeatureFloodCount.C.

Referenced by updateBBoxExtremes().

2131 {
2140  std::list<BoundingBox> box_list(bboxes.begin(), bboxes.end());
2141 
2142  auto box_expanded = false;
2143  for (auto it1 = box_list.begin(); it1 != box_list.end(); /* No increment on it1 */)
2144  {
2145  auto merge_occured = false;
2146  for (auto it2 = box_list.begin(); it2 != box_list.end(); ++it2)
2147  {
2148  if (it1 != it2 && it1->intersects(*it2, TOLERANCE))
2149  {
2150  updateBBoxExtremes(*it2, *it1);
2151  box_list.emplace_back(std::move(*it2));
2152 
2153  box_list.erase(it2);
2154  it1 = box_list.erase(it1); // it1 is incremented here!
2155 
2156  box_expanded = true;
2157  merge_occured = true;
2158 
2159  break;
2160  }
2161  }
2162 
2163  if (!merge_occured)
2164  ++it1;
2165  }
2166 
2170  bboxes.resize(box_list.size());
2171  std::copy(box_list.begin(), box_list.end(), bboxes.begin());
2172 
2173  // Error check
2174  if (physical_intersection && !box_expanded)
2175  {
2176  std::ostringstream oss;
2177  oss << "LHS BBoxes:\n";
2178  for (const auto i : index_range(_bboxes))
2179  oss << "Max: " << _bboxes[i].max() << " Min: " << _bboxes[i].min() << '\n';
2180 
2181  ::mooseError("No Bounding Boxes Expanded - This is a catastrophic error!\n", oss.str());
2182  }
2183 }
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
void updateBBoxExtremes(MeshBase &mesh)
Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter...
auto max(const L &left, const R &right)
void mooseError(Args &&... args) const
auto index_range(const T &sizable)

◆ operator<()

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

Comparison operator for sorting individual FeatureDatas.

Definition at line 250 of file FeatureFloodCount.h.

251  {
252  if (_id != invalid_id)
253  {
254  mooseAssert(rhs._id != invalid_id, "Asymmetric setting of ids detected during sort");
255 
256  // Sort based on ids
257  return _id < rhs._id;
258  }
259  else
260  // Sort based on processor independent information (mesh and variable info)
261  return _var_index < rhs._var_index ||
262  (_var_index == rhs._var_index && _min_entity_id < rhs._min_entity_id);
263  }
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 1971 of file FeatureFloodCount.C.

1972 {
1973  return MooseUtils::setsIntersect(_periodic_nodes, rhs._periodic_nodes);
1974 }
bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.

◆ 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 region, now we need to iterate over the remaining "possible" disjoint elements and partition them into independent bboxes regions.

We no longer need to distinguish among the various halo ids in disjoint bounding boxes. We'll just merge them altogether for the remaining portions of the algorithm.

Definition at line 1872 of file FeatureFloodCount.C.

1873 {
1874  // First update the primary bounding box (all topologically connected)
1875  for (auto & halo_id : _halo_ids)
1876  updateBBoxExtremesHelper(_bboxes[0], mesh.elem_ref(halo_id));
1877  for (auto & ghost_id : _ghosted_ids)
1878  updateBBoxExtremesHelper(_bboxes[0], mesh.elem_ref(ghost_id));
1879 
1880  FeatureData::container_type all_primary_region_ids;
1881  FeatureFloodCount::reserve(all_primary_region_ids, _local_ids.size() + _halo_ids.size());
1882  std::set_union(_local_ids.begin(),
1883  _local_ids.end(),
1884  _halo_ids.begin(),
1885  _halo_ids.end(),
1886  std::insert_iterator<FeatureData::container_type>(all_primary_region_ids,
1887  all_primary_region_ids.begin()));
1888 
1889  // Remove all of the IDs that are in the primary region
1890  std::list<dof_id_type> disjoint_elem_id_list;
1891  std::set_difference(_disjoint_halo_ids.begin(),
1892  _disjoint_halo_ids.end(),
1893  all_primary_region_ids.begin(),
1894  all_primary_region_ids.end(),
1895  std::insert_iterator<std::list<dof_id_type>>(disjoint_elem_id_list,
1896  disjoint_elem_id_list.begin()));
1897 
1904  constexpr auto TOLERANCE = libMesh::TOLERANCE * libMesh::TOLERANCE;
1905  for (auto elem_id : disjoint_elem_id_list)
1906  {
1907  BoundingBox elem_bbox;
1908  updateBBoxExtremesHelper(elem_bbox, *mesh.elem_ptr(elem_id));
1909 
1910  bool found_match = false;
1911  for (auto & bbox : _bboxes)
1912  {
1913  if (bbox.intersects(elem_bbox, TOLERANCE))
1914  {
1915  updateBBoxExtremes(bbox, elem_bbox);
1916  found_match = true;
1917  break;
1918  }
1919  }
1920 
1921  if (!found_match)
1922  _bboxes.push_back(elem_bbox);
1923  }
1924 
1925  mergeBBoxes(_bboxes, false);
1926 
1931  FeatureData::container_type set_union;
1932  FeatureFloodCount::reserve(set_union, _halo_ids.size() + _disjoint_halo_ids.size());
1933  std::set_union(_halo_ids.begin(),
1934  _halo_ids.end(),
1935  _disjoint_halo_ids.begin(),
1936  _disjoint_halo_ids.end(),
1937  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1938  _halo_ids.swap(set_union);
1939  _disjoint_halo_ids.clear();
1940 }
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
container_type _halo_ids
Holds the ids surrounding the feature.
std::vector< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
static constexpr Real TOLERANCE
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
void updateBBoxExtremes(MeshBase &mesh)
Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter...
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
MeshBase & mesh
static void reserve(std::set< T > &, std::size_t)
container_type _local_ids
Holds the local ids in the interior of a feature.
void updateBBoxExtremesHelper(BoundingBox &bbox, const Point &node)
void mergeBBoxes(std::vector< BoundingBox > &bboxes, bool physical_intersection)
Located the overlapping bounding box between this Feature and the other Feature and expands that over...

◆ updateBBoxExtremes() [2/2]

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

Definition at line 1943 of file FeatureFloodCount.C.

1944 {
1945  for (const auto i : make_range(Moose::dim))
1946  {
1947  bbox.min()(i) = std::min(bbox.min()(i), rhs_bbox.min()(i));
1948  bbox.max()(i) = std::max(bbox.max()(i), rhs_bbox.max()(i));
1949  }
1950 }
static constexpr std::size_t dim
IntRange< T > make_range(T beg, T end)

Friends And Related Function Documentation

◆ operator<<

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

stream output operator

Definition at line 2186 of file FeatureFloodCount.C.

2187 {
2188  static const bool debug = true;
2189 
2190  out << "Grain ID: ";
2191  if (feature._id != FeatureFloodCount::invalid_id)
2192  out << feature._id;
2193  else
2194  out << "invalid";
2195 
2196  if (debug)
2197  {
2198  out << "\nGhosted Entities: ";
2199  for (auto ghosted_id : feature._ghosted_ids)
2200  out << ghosted_id << " ";
2201 
2202  out << "\nLocal Entities: ";
2203  for (auto local_id : feature._local_ids)
2204  out << local_id << " ";
2205 
2206  out << "\nHalo Entities: ";
2207  for (auto halo_id : feature._halo_ids)
2208  out << halo_id << " ";
2209 
2210  out << "\nPeriodic Node IDs: ";
2211  for (auto periodic_node : feature._periodic_nodes)
2212  out << periodic_node << " ";
2213  }
2214 
2215  out << "\nBBoxes:";
2216  for (const auto & bbox : feature._bboxes)
2217  {
2218  out << "\nMax: " << bbox.max() << " Min: " << bbox.min();
2219  }
2220 
2221  out << "\nStatus: ";
2222  if (feature._status == FeatureFloodCount::Status::CLEAR)
2223  out << "CLEAR";
2224  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::MARKED))
2225  out << " MARKED";
2226  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::DIRTY))
2227  out << " DIRTY";
2228  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::INACTIVE))
2229  out << " INACTIVE";
2230 
2231  if (debug)
2232  {
2233  out << "\nOrig IDs (rank, index): ";
2234  for (const auto & orig_pair : feature._orig_ids)
2235  out << '(' << orig_pair.first << ", " << orig_pair.second << ") ";
2236  out << "\nVar_index: " << feature._var_index;
2237  out << "\nMin Entity ID: " << feature._min_entity_id;
2238  }
2239  out << "\n" << std::endl;
2240 
2241  return out;
2242 }
static const unsigned int invalid_id
OStreamProxy out

Member Data Documentation

◆ _bboxes

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

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

Definition at line 292 of file FeatureFloodCount.h.

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

◆ _boundary_intersection

BoundaryIntersection FeatureFloodCount::FeatureData::_boundary_intersection

Enumeration indicating boundary intersection status.

Definition at line 311 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 305 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 279 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 269 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 273 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::appendPeriodicNeighborNodes(), FeatureFloodCount::flood(), operator<<(), GrainTracker::swapSolutionValues(), updateBBoxExtremes(), 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 298 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 295 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 282 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 308 of file FeatureFloodCount.h.

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

◆ _var_index

std::size_t FeatureFloodCount::FeatureData::_var_index

◆ _vol_count

std::size_t FeatureFloodCount::FeatureData::_vol_count

The count of entities contributing to the volume calculation.

Definition at line 301 of file FeatureFloodCount.h.

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


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