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...
 
bool _intersects_boundary
 Flag indicating whether this feature intersects a boundary. 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 123 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 134 of file FeatureFloodCount.h.

Constructor & Destructor Documentation

◆ FeatureData() [1/5]

FeatureFloodCount::FeatureData::FeatureData ( )
inline

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

142  : FeatureData(var_index, status)
143  {
144  _orig_ids = {std::make_pair(rank, local_index)};
145  }
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 147 of file FeatureFloodCount.h.

150  {MeshTools::BoundingBox()})
151  : _var_index(var_index),
152  _id(id),
153  _bboxes(bboxes), // Assume at least one bounding box
154  _min_entity_id(DofObject::invalid_id),
155  _vol_count(0),
156  _status(status),
157  _intersects_boundary(false)
158  {
159  }
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")
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
bool _intersects_boundary
Flag indicating whether this feature intersects a boundary.
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 1773 of file FeatureFloodCount.C.

1774 {
1775  // See if any of the bounding boxes in either FeatureData object intersect
1776  for (const auto & bbox_lhs : _bboxes)
1777  for (const auto & bbox_rhs : rhs._bboxes)
1778  if (bbox_lhs.intersects(bbox_rhs, libMesh::TOLERANCE * libMesh::TOLERANCE))
1779  return true;
1780 
1781  return false;
1782 }
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 1818 of file FeatureFloodCount.C.

1819 {
1820  for (const auto & orig_id_pair1 : _orig_ids)
1821  for (const auto & orig_id_pair2 : rhs._orig_ids)
1822  if (orig_id_pair1 == orig_id_pair2)
1823  return true;
1824 
1825  return false;
1826 }
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.

◆ clear()

void FeatureFloodCount::FeatureData::clear ( )

Definition at line 1942 of file FeatureFloodCount.C.

1943 {
1944  _local_ids.clear();
1945  _periodic_nodes.clear();
1946  _halo_ids.clear();
1947  _disjoint_halo_ids.clear();
1948  _ghosted_ids.clear();
1949  _bboxes.clear();
1950  _orig_ids.clear();
1951 }
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 1923 of file FeatureFloodCount.C.

1924 {
1925  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
1926  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
1927 
1928  FeatureData::container_type set_union;
1929  FeatureFloodCount::reserve(_local_ids, _local_ids.size() + rhs._local_ids.size());
1930  std::set_union(_local_ids.begin(),
1931  _local_ids.end(),
1932  rhs._local_ids.begin(),
1933  rhs._local_ids.end(),
1934  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1935  _local_ids.swap(set_union);
1936 
1937  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
1938  "Flags in invalid state");
1939 }
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 297 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 1954 of file FeatureFloodCount.C.

1955 {
1956  std::vector<bool> intersected_boxes(rhs._bboxes.size(), false);
1957 
1958  auto box_expanded = false;
1959  for (auto & bbox : _bboxes)
1960  for (auto j = beginIndex(rhs._bboxes); j < rhs._bboxes.size(); ++j)
1961  {
1962  if (bbox.intersects(rhs._bboxes[j], libMesh::TOLERANCE * libMesh::TOLERANCE))
1963  {
1964  updateBBoxExtremes(bbox, rhs._bboxes[j]);
1965  intersected_boxes[j] = true;
1966  box_expanded = true;
1967  }
1968  }
1969 
1970  // Error check
1971  if (!box_expanded)
1972  {
1973  std::ostringstream oss;
1974  oss << "LHS BBoxes:\n";
1975  for (auto i = beginIndex(_bboxes); i < _bboxes.size(); ++i)
1976  oss << "Max: " << _bboxes[i].max() << " Min: " << _bboxes[i].min() << '\n';
1977 
1978  oss << "RHS BBoxes:\n";
1979  for (auto i = beginIndex(rhs._bboxes); i < rhs._bboxes.size(); ++i)
1980  oss << "Max: " << rhs._bboxes[i].max() << " Min: " << rhs._bboxes[i].min() << '\n';
1981 
1982  ::mooseError("No Bounding Boxes Expanded - This is a catastrophic error!\n", oss.str());
1983  }
1984 
1985  // Any bounding box in the rhs vector that doesn't intersect
1986  // needs to be appended to the lhs vector
1987  for (auto j = beginIndex(intersected_boxes); j < intersected_boxes.size(); ++j)
1988  if (!intersected_boxes[j])
1989  _bboxes.push_back(rhs._bboxes[j]);
1990 }
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 1801 of file FeatureFloodCount.C.

1802 {
1803  return setsIntersect(
1804  _ghosted_ids.begin(), _ghosted_ids.end(), rhs._ghosted_ids.begin(), rhs._ghosted_ids.end());
1805 }
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 1785 of file FeatureFloodCount.C.

1786 {
1787  return setsIntersect(
1788  _halo_ids.begin(), _halo_ids.end(), rhs._halo_ids.begin(), rhs._halo_ids.end());
1789 }
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 1829 of file FeatureFloodCount.C.

1830 {
1831  mooseAssert(_var_index == rhs._var_index, "Mismatched variable index in merge");
1832  mooseAssert(_id == rhs._id, "Mismatched auxiliary id in merge");
1833 
1834  FeatureData::container_type set_union;
1835 
1836  FeatureFloodCount::reserve(set_union, _local_ids.size() + rhs._local_ids.size());
1837  std::set_union(_local_ids.begin(),
1838  _local_ids.end(),
1839  rhs._local_ids.begin(),
1840  rhs._local_ids.end(),
1841  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1842  _local_ids.swap(set_union);
1843 
1844  set_union.clear();
1845  FeatureFloodCount::reserve(set_union, _periodic_nodes.size() + rhs._periodic_nodes.size());
1846  std::set_union(_periodic_nodes.begin(),
1847  _periodic_nodes.end(),
1848  rhs._periodic_nodes.begin(),
1849  rhs._periodic_nodes.end(),
1850  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1851  _periodic_nodes.swap(set_union);
1852 
1853  set_union.clear();
1854  FeatureFloodCount::reserve(set_union, _ghosted_ids.size() + rhs._ghosted_ids.size());
1855  std::set_union(_ghosted_ids.begin(),
1856  _ghosted_ids.end(),
1857  rhs._ghosted_ids.begin(),
1858  rhs._ghosted_ids.end(),
1859  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1860 
1868  bool physical_intersection = (_ghosted_ids.size() + rhs._ghosted_ids.size() > set_union.size());
1869  _ghosted_ids.swap(set_union);
1870 
1875  if (physical_intersection)
1876  expandBBox(rhs);
1877  else
1878  std::move(rhs._bboxes.begin(), rhs._bboxes.end(), std::back_inserter(_bboxes));
1879 
1880  set_union.clear();
1881  FeatureFloodCount::reserve(set_union, _disjoint_halo_ids.size() + rhs._disjoint_halo_ids.size());
1882  std::set_union(_disjoint_halo_ids.begin(),
1883  _disjoint_halo_ids.end(),
1884  rhs._disjoint_halo_ids.begin(),
1885  rhs._disjoint_halo_ids.end(),
1886  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1887  _disjoint_halo_ids.swap(set_union);
1888 
1889  set_union.clear();
1890  FeatureFloodCount::reserve(set_union, _halo_ids.size() + rhs._halo_ids.size());
1891  std::set_union(_halo_ids.begin(),
1892  _halo_ids.end(),
1893  rhs._halo_ids.begin(),
1894  rhs._halo_ids.end(),
1895  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1896  _halo_ids.swap(set_union);
1897 
1898  // Keep track of the original ids so we can notify other processors of the local to global mapping
1899  _orig_ids.splice(_orig_ids.end(), std::move(rhs._orig_ids));
1900 
1901  // Update the min feature id
1902  _min_entity_id = std::min(_min_entity_id, rhs._min_entity_id);
1903 
1909  mooseAssert((_status & Status::MARKED & Status::DIRTY) == Status::CLEAR,
1910  "Flags in invalid state");
1911 
1912  // Logical AND here to combine flags (INACTIVE & INACTIVE == INACTIVE, all other combos are CLEAR)
1913  _status &= rhs._status;
1914 
1915  // Logical OR here to make sure we maintain boundary intersection attribute when joining
1916  _intersects_boundary |= rhs._intersects_boundary;
1917 
1918  _vol_count += rhs._vol_count;
1919  _centroid += rhs._centroid;
1920 }
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.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
bool _intersects_boundary
Flag indicating whether this feature intersects a boundary.
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 1808 of file FeatureFloodCount.C.

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

1809 {
1810  return (_var_index == rhs._var_index && // the sets have matching variable indices and
1811  ((boundingBoxesIntersect(rhs) && // (if the feature's bboxes intersect and
1812  ghostedIntersect(rhs)) // the ghosted entities also intersect)
1813  || // or
1814  periodicBoundariesIntersect(rhs))); // periodic node sets intersect)
1815 }
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 234 of file FeatureFloodCount.h.

235  {
236  if (_id != invalid_id)
237  {
238  mooseAssert(rhs._id != invalid_id, "Asymmetric setting of ids detected during sort");
239 
240  // Sort based on ids
241  return _id < rhs._id;
242  }
243  else
244  // Sort based on processor independent information (mesh and variable info)
245  return _var_index < rhs._var_index ||
246  (_var_index == rhs._var_index && _min_entity_id < rhs._min_entity_id);
247  }
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 1792 of file FeatureFloodCount.C.

1793 {
1794  return setsIntersect(_periodic_nodes.begin(),
1795  _periodic_nodes.end(),
1796  rhs._periodic_nodes.begin(),
1797  rhs._periodic_nodes.end());
1798 }
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 1678 of file FeatureFloodCount.C.

1679 {
1680  // First update the primary bounding box (all topologically connected)
1681  for (auto & halo_id : _halo_ids)
1682  updateBBoxExtremesHelper(_bboxes[0], *mesh.elem(halo_id));
1683  for (auto & ghost_id : _ghosted_ids)
1684  updateBBoxExtremesHelper(_bboxes[0], *mesh.elem(ghost_id));
1685 
1686  // Remove all of the IDs that are in the primary region
1687  std::list<dof_id_type> disjoint_elem_id_list;
1688  std::set_difference(_disjoint_halo_ids.begin(),
1689  _disjoint_halo_ids.end(),
1690  _halo_ids.begin(),
1691  _halo_ids.end(),
1692  std::insert_iterator<std::list<dof_id_type>>(disjoint_elem_id_list,
1693  disjoint_elem_id_list.begin()));
1694 
1695  if (!disjoint_elem_id_list.empty())
1696  {
1705  std::list<std::list<dof_id_type>> disjoint_regions;
1706  for (auto elem_id : _disjoint_halo_ids)
1707  {
1708  disjoint_regions.emplace_back(std::list<dof_id_type>({elem_id}));
1709  }
1710 
1711  for (auto it1 = disjoint_regions.begin(); it1 != disjoint_regions.end(); /* No increment */)
1712  {
1713  bool merge_occured = false;
1714  for (auto it2 = disjoint_regions.begin(); it2 != disjoint_regions.end(); ++it2)
1715  {
1716  if (it1 != it2 && areElemListsMergeable(*it1, *it2, mesh))
1717  {
1718  it2->splice(it2->begin(), *it1);
1719 
1720  disjoint_regions.emplace_back(std::move(*it2));
1721  disjoint_regions.erase(it2);
1722  it1 = disjoint_regions.erase(it1);
1723 
1724  merge_occured = true;
1725 
1726  break;
1727  }
1728  }
1729 
1730  if (!merge_occured)
1731  ++it1;
1732  }
1733 
1734  // Finally create new bounding boxes for each disjoint region
1735  auto num_regions = disjoint_regions.size();
1736  // We have num_regions *new* bounding boxes plus the existing bounding box
1737  _bboxes.resize(num_regions + 1);
1738 
1739  decltype(num_regions) region = 1;
1740  for (const auto list_ref : disjoint_regions)
1741  {
1742  for (const auto elem_id : list_ref)
1743  updateBBoxExtremesHelper(_bboxes[region], *mesh.elem_ptr(elem_id));
1744 
1745  FeatureData::container_type set_union;
1746  FeatureFloodCount::reserve(set_union, _halo_ids.size() + _disjoint_halo_ids.size());
1747  std::set_union(
1748  _halo_ids.begin(),
1749  _halo_ids.end(),
1750  _disjoint_halo_ids.begin(),
1751  _disjoint_halo_ids.end(),
1752  std::insert_iterator<FeatureData::container_type>(set_union, set_union.begin()));
1753  _halo_ids.swap(set_union);
1754 
1755  _disjoint_halo_ids.clear();
1756  ++region;
1757  }
1758  }
1759 }
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 1762 of file FeatureFloodCount.C.

1764 {
1765  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
1766  {
1767  bbox.min()(i) = std::min(bbox.min()(i), rhs_bbox.min()(i));
1768  bbox.max()(i) = std::max(bbox.max()(i), rhs_bbox.max()(i));
1769  }
1770 }

Friends And Related Function Documentation

◆ operator<<

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

stream output operator

Definition at line 1993 of file FeatureFloodCount.C.

1994 {
1995  static const bool debug = true;
1996 
1997  out << "Grain ID: ";
1998  if (feature._id != FeatureFloodCount::invalid_id)
1999  out << feature._id;
2000  else
2001  out << "invalid";
2002 
2003  if (debug)
2004  {
2005  out << "\nGhosted Entities: ";
2006  for (auto ghosted_id : feature._ghosted_ids)
2007  out << ghosted_id << " ";
2008 
2009  out << "\nLocal Entities: ";
2010  for (auto local_id : feature._local_ids)
2011  out << local_id << " ";
2012 
2013  out << "\nHalo Entities: ";
2014  for (auto halo_id : feature._halo_ids)
2015  out << halo_id << " ";
2016 
2017  out << "\nPeriodic Node IDs: ";
2018  for (auto periodic_node : feature._periodic_nodes)
2019  out << periodic_node << " ";
2020  }
2021 
2022  out << "\nBBoxes:";
2023  Real volume = 0;
2024  for (const auto & bbox : feature._bboxes)
2025  {
2026  out << "\nMax: " << bbox.max() << " Min: " << bbox.min();
2027  volume += (bbox.max()(0) - bbox.min()(0)) * (bbox.max()(1) - bbox.min()(1)) *
2028  (MooseUtils::absoluteFuzzyEqual(bbox.max()(2), bbox.min()(2))
2029  ? 1
2030  : bbox.max()(2) - bbox.min()(2));
2031  }
2032 
2033  out << "\nStatus: ";
2034  if (feature._status == FeatureFloodCount::Status::CLEAR)
2035  out << "CLEAR";
2036  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::MARKED))
2037  out << " MARKED";
2038  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::DIRTY))
2039  out << " DIRTY";
2040  if (static_cast<bool>(feature._status & FeatureFloodCount::Status::INACTIVE))
2041  out << " INACTIVE";
2042 
2043  if (debug)
2044  {
2045  out << "\nOrig IDs (rank, index): ";
2046  for (const auto & orig_pair : feature._orig_ids)
2047  out << '(' << orig_pair.first << ", " << orig_pair.second << ") ";
2048  out << "\nVar_index: " << feature._var_index;
2049  out << "\nMin Entity ID: " << feature._min_entity_id;
2050  }
2051  out << "\n\n";
2052 
2053  return out;
2054 }
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 276 of file FeatureFloodCount.h.

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

◆ _centroid

Point FeatureFloodCount::FeatureData::_centroid

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

Definition at line 289 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 263 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 253 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

◆ _intersects_boundary

bool FeatureFloodCount::FeatureData::_intersects_boundary

Flag indicating whether this feature intersects a boundary.

Definition at line 295 of file FeatureFloodCount.h.

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

◆ _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 257 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::appendPeriodicNeighborNodes(), FeatureFloodCount::flood(), operator<<(), 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 282 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 279 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 266 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 292 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 269 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 285 of file FeatureFloodCount.h.

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


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