www.mooseframework.org
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | List of all members
FauxGrainTracker Class Reference

This class is a fake grain tracker object, it will not actually track grains nor remap them but will provide the same interface as the grain tracker and can be used as a lightweight replacement when neither of those methods are needed. More...

#include <FauxGrainTracker.h>

Inheritance diagram for FauxGrainTracker:
[legend]

Public Types

enum  FieldType {
  FieldType::UNIQUE_REGION, FieldType::VARIABLE_COLORING, FieldType::GHOSTED_ENTITIES, FieldType::HALOS,
  FieldType::CENTROID, FieldType::ACTIVE_BOUNDS
}
 
enum  Status : unsigned char { Status::CLEAR = 0x0, Status::MARKED = 0x1, Status::DIRTY = 0x2, Status::INACTIVE = 0x4 }
 This enumeration is used to indicate status of the grains in the _unique_grains data structure. More...
 
enum  BoundaryIntersection : unsigned char { BoundaryIntersection::NONE = 0x0, BoundaryIntersection::ANY_BOUNDARY = 0x1, BoundaryIntersection::PRIMARY_PERCOLATION_BOUNDARY = 0x2, BoundaryIntersection::SECONDARY_PERCOLATION_BOUNDARY = 0x4 }
 This enumeration is used to inidacate status of boundary intersections. More...
 

Public Member Functions

 FauxGrainTracker (const InputParameters &parameters)
 
virtual ~FauxGrainTracker ()
 
virtual void initialize () override
 
virtual void finalize () override
 
virtual Real getValue () override
 
virtual void execute () override
 
virtual Real getEntityValue (dof_id_type entity_id, FeatureFloodCount::FieldType field_type, std::size_t var_idx) const override
 
virtual const std::vector< unsigned int > & getVarToFeatureVector (dof_id_type elem_id) const override
 Returns a list of active unique feature ids for a particular element. More...
 
virtual unsigned int getFeatureVar (unsigned int feature_id) const override
 Returns the variable representing the passed in feature. More...
 
virtual std::size_t getNumberActiveGrains () const override
 Returns the number of active grains current stored in the GrainTracker. More...
 
virtual std::size_t getTotalFeatureCount () const override
 Returns the total feature count (active and inactive ids, useful for sizing vectors) More...
 
virtual Point getGrainCentroid (unsigned int grain_id) const override
 Returns the centroid for the given grain number. More...
 
virtual bool doesFeatureIntersectBoundary (unsigned int feature_id) const override
 Returns a Boolean indicating whether this feature intersects any boundary. More...
 
virtual void initialSetup () override
 
virtual void meshChanged () override
 
std::size_t getNumberActiveFeatures () const
 Return the number of active features. More...
 
virtual bool isFeaturePercolated (unsigned int feature_id) const
 Returns a Boolean indicating whether this feature is percolated (e.g. More...
 
virtual Point featureCentroid (unsigned int feature_id) const
 Returns the centroid of the designated feature (only supported without periodic boundaries) More...
 
std::size_t numCoupledVars () const
 Returns the number of coupled varaibles. More...
 
const std::vector< MooseVariable * > & getCoupledVars () const
 Returns a const vector to the coupled variable pointers. More...
 
const std::vector< MooseVariableFEBase * > & getFECoupledVars () const
 Returns a const vector to the coupled MooseVariableFEBase pointers. More...
 
bool isElemental () const
 
const std::vector< FeatureData > & getFeatures () const
 Return a constant reference to the vector of all discovered features. More...
 
virtual std::vector< unsigned int > getNewGrainIDs () const
 This method returns all of the new ids generated in an invocation of the GrainTracker. More...
 

Static Public Attributes

static const std::size_t invalid_size_t = std::numeric_limits<std::size_t>::max()
 
static const unsigned int invalid_id = std::numeric_limits<unsigned int>::max()
 

Protected Member Functions

template<typename T >
bool isBoundaryEntity (const T *entity) const
 Returns a Boolean indicating whether the entity is on one of the desired boundaries. More...
 
virtual void updateFieldInfo ()
 This method is used to populate any of the data structures used for storing field data (nodal or elemental). More...
 
bool flood (const DofObject *dof_object, std::size_t current_index)
 This method will check if the current entity is above the supplied threshold and "mark" it. More...
 
virtual Real getThreshold (std::size_t current_index) const
 Return the starting comparison threshold to use when inspecting an entity during the flood stage. More...
 
virtual Real getConnectingThreshold (std::size_t current_index) const
 Return the "connecting" comparison threshold to use when inspecting an entity during the flood stage. More...
 
bool compareValueWithThreshold (Real entity_value, Real threshold) const
 This method is used to determine whether the current entity value is part of a feature or not. More...
 
virtual bool isNewFeatureOrConnectedRegion (const DofObject *dof_object, std::size_t &current_index, FeatureData *&feature, Status &status, unsigned int &new_id)
 Method called during the recursive flood routine that should return whether or not the current entity is part of the current feature (if one is being explored), or if it's the start of a new feature. More...
 
void expandPointHalos ()
 This method takes all of the partial features and expands the local, ghosted, and halo sets around those regions to account for the diffuse interface. More...
 
void expandEdgeHalos (unsigned int num_layers_to_expand)
 This method expands the existing halo set by some width determined by the passed in value. More...
 
template<typename T >
void visitNeighborsHelper (const T *curr_entity, std::vector< const T *> neighbor_entities, FeatureData *feature, bool expand_halos_only, bool topological_neighbor, bool disjoint_only)
 The actual logic for visiting neighbors is abstracted out here. More...
 
void prepareDataForTransfer ()
 This routine uses the local flooded data to build up the local feature data structures (_feature_sets). More...
 
void serialize (std::string &serialized_buffer, unsigned int var_num=invalid_id)
 This routines packs the _partial_feature_sets data into a structure suitable for parallel communication operations. More...
 
void deserialize (std::vector< std::string > &serialized_buffers, unsigned int var_num=invalid_id)
 This routine takes the vector of byte buffers (one for each processor), deserializes them into a series of FeatureSet objects, and appends them to the _feature_sets data structure. More...
 
virtual void mergeSets ()
 This routine is called on the master rank only and stitches together the partial feature pieces seen on any processor. More...
 
virtual bool areFeaturesMergeable (const FeatureData &f1, const FeatureData &f2) const
 Method for determining whether two features are mergeable. More...
 
void communicateAndMerge ()
 This routine handles all of the serialization, communication and deserialization of the data structures containing FeatureData objects. More...
 
void sortAndLabel ()
 Sort and assign ids to features based on their position in the container after sorting. More...
 
void scatterAndUpdateRanks ()
 Calls buildLocalToGlobalIndices to build the individual local to global indicies for each rank and scatters that information to all ranks. More...
 
virtual void buildLocalToGlobalIndices (std::vector< std::size_t > &local_to_global_all, std::vector< int > &counts) const
 This routine populates a stacked vector of local to global indices per rank and the associated count vector for scattering the vector to the ranks. More...
 
void buildFeatureIdToLocalIndices (unsigned int max_id)
 This method builds a lookup map for retrieving the right local feature (by index) given a global index or id. More...
 
virtual void clearDataStructures ()
 Helper routine for clearing up data structures during initialize and prior to parallel communication. More...
 
void updateBoundaryIntersections (FeatureData &feature) const
 Update the feature's attributes to indicate boundary intersections. More...
 
void appendPeriodicNeighborNodes (FeatureData &feature) const
 This routine adds the periodic node information to our data structure prior to packing the data this makes those periodic neighbors appear much like ghosted nodes in a multiprocessor setting. More...
 
void updateRegionOffsets ()
 This routine updates the _region_offsets variable which is useful for quickly determining the proper global number for a feature when using multimap mode. More...
 
void visitNodalNeighbors (const Node *node, FeatureData *feature, bool expand_halos_only)
 These two routines are utility routines used by the flood routine and by derived classes for visiting neighbors. More...
 
void visitElementalNeighbors (const Elem *elem, FeatureData *feature, bool expand_halos_only, bool disjoint_only)
 

Static Protected Member Functions

template<class InputIterator >
static bool setsIntersect (InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
 This method detects whether two sets intersect without building a result set. More...
 

Protected Attributes

std::vector< MooseVariableFEBase * > _fe_vars
 The vector of coupled in variables. More...
 
std::vector< MooseVariable * > _vars
 The vector of coupled in variables cast to MooseVariable. More...
 
const DofMap & _dof_map
 Reference to the dof_map containing the coupled variables. More...
 
const Real _threshold
 The threshold above (or below) where an entity may begin a new region (feature) More...
 
Real _step_threshold
 
const Real _connecting_threshold
 The threshold above (or below) which neighboring entities are flooded (where regions can be extended but not started) More...
 
Real _step_connecting_threshold
 
MooseMesh & _mesh
 A reference to the mesh. More...
 
unsigned long _var_number
 This variable is used to build the periodic node map. More...
 
const bool _single_map_mode
 This variable is used to indicate whether or not multiple maps are used during flooding. More...
 
const bool _condense_map_info
 
const bool _global_numbering
 This variable is used to indicate whether or not we identify features with unique numbers on multiple maps. More...
 
const bool _var_index_mode
 This variable is used to indicate whether the maps will contain unique region information or just the variable numbers owning those regions. More...
 
const bool _compute_halo_maps
 Indicates whether or not to communicate halo map information with all ranks. More...
 
const bool _compute_var_to_feature_map
 Indicates whether or not the var to feature map is populated. More...
 
const bool _use_less_than_threshold_comparison
 Use less-than when comparing values against the threshold value. More...
 
const std::size_t _maps_size
 Convenience variable holding the size of all the datastructures size by the number of maps. More...
 
const processor_id_type _n_procs
 Convenience variable holding the number of processors in this simulation. More...
 
std::vector< std::set< dof_id_type > > _entities_visited
 This variable keeps track of which nodes have been visited during execution. More...
 
std::vector< std::map< dof_id_type, int > > _var_index_maps
 This map keeps track of which variables own which nodes. More...
 
std::vector< std::vector< const Elem * > > _nodes_to_elem_map
 The data structure used to find neighboring elements give a node ID. More...
 
std::vector< unsigned int > _feature_counts_per_map
 The number of features seen by this object per map. More...
 
unsigned int _feature_count
 The number of features seen by this object (same as summing _feature_counts_per_map) More...
 
std::vector< std::list< FeatureData > > _partial_feature_sets
 The data structure used to hold partial and communicated feature data, during the discovery and merging phases. More...
 
std::vector< FeatureData > & _feature_sets
 The data structure used to hold the globally unique features. More...
 
std::vector< FeatureData_volatile_feature_sets
 Derived objects (e.g. More...
 
std::vector< std::map< dof_id_type, int > > _feature_maps
 The feature maps contain the raw flooded node information and eventually the unique grain numbers. More...
 
std::vector< std::size_t > _local_to_global_feature_map
 The vector recording the local to global feature indices. More...
 
std::vector< std::size_t > _feature_id_to_local_index
 The vector recording the grain_id to local index (several indices will contain invalid_size_t) More...
 
PeriodicBoundaries * _pbs
 A pointer to the periodic boundary constraints object. More...
 
std::unique_ptr< PointLocatorBase > _point_locator
 
const PostprocessorValue & _element_average_value
 Average value of the domain which can optionally be used to find features in a field. More...
 
std::map< dof_id_type, int > _ghosted_entity_ids
 The map for holding reconstructed ghosted element information. More...
 
std::vector< std::map< dof_id_type, int > > _halo_ids
 The data structure for looking up halos around features. More...
 
std::multimap< dof_id_type, dof_id_type > _periodic_node_map
 The data structure which is a list of nodes that are constrained to other nodes based on the imposed periodic boundary conditions. More...
 
std::unordered_set< dof_id_type > _all_boundary_entity_ids
 The set of entities on the boundary of the domain used for determining if features intersect any boundary. More...
 
std::vector< BoundaryID > _primary_perc_bnds
 
std::vector< BoundaryID > _secondary_perc_bnds
 
const bool _is_elemental
 Determines if the flood counter is elements or not (nodes) More...
 
bool _is_boundary_restricted
 Indicates that this object should only run on one or more boundaries. More...
 
ConstBndElemRange * _bnd_elem_range
 Boundary element range pointer. More...
 
const bool _is_master
 Convenience variable for testing master rank. More...
 

Private Attributes

std::map< dof_id_type, unsigned int > _entity_id_to_var_num
 The mapping of entities to grains, in this case always the order parameter. More...
 
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
 
std::vector< unsigned int > _empty_var_to_features
 
std::set< unsigned int > _variables_used
 Used as the lightweight grain counter. More...
 
std::size_t _grain_count
 Total Grain Count. More...
 
const std::size_t _n_vars
 
const int _tracking_step
 Used to emulate the tracking step of the real grain tracker object. More...
 
std::vector< unsigned int > _op_to_grains
 Order parameter to grain indices (just a reflexive vector) More...
 
std::map< unsigned int, Real > _volume
 The volume of the feature. More...
 
std::map< unsigned int, unsigned int > _vol_count
 The count of entities contributing to the volume calculation. More...
 
std::map< unsigned int, Point > _centroid
 The centroid of the feature (average of coordinates from entities participating in the volume calculation) More...
 

Detailed Description

This class is a fake grain tracker object, it will not actually track grains nor remap them but will provide the same interface as the grain tracker and can be used as a lightweight replacement when neither of those methods are needed.

You may safely use this object anytime you have at least as many order parameters as you do grains.

Definition at line 27 of file FauxGrainTracker.h.

Member Enumeration Documentation

◆ BoundaryIntersection

enum FeatureFloodCount::BoundaryIntersection : unsigned char
stronginherited

This enumeration is used to inidacate status of boundary intersections.

Enumerator
NONE 
ANY_BOUNDARY 
PRIMARY_PERCOLATION_BOUNDARY 
SECONDARY_PERCOLATION_BOUNDARY 

Definition at line 127 of file FeatureFloodCount.h.

127  : unsigned char
128  {
129  NONE = 0x0,
130  ANY_BOUNDARY = 0x1,
131  PRIMARY_PERCOLATION_BOUNDARY = 0x2,
132  SECONDARY_PERCOLATION_BOUNDARY = 0x4
133  };

◆ FieldType

enum FeatureFloodCount::FieldType
stronginherited
Enumerator
UNIQUE_REGION 
VARIABLE_COLORING 
GHOSTED_ENTITIES 
HALOS 
CENTROID 
ACTIVE_BOUNDS 

Definition at line 101 of file FeatureFloodCount.h.

102  {
103  UNIQUE_REGION,
104  VARIABLE_COLORING,
105  GHOSTED_ENTITIES,
106  HALOS,
107  CENTROID,
108  ACTIVE_BOUNDS,
109  };

◆ Status

enum FeatureFloodCount::Status : unsigned char
stronginherited

This enumeration is used to indicate status of the grains in the _unique_grains data structure.

Enumerator
CLEAR 
MARKED 
DIRTY 
INACTIVE 

Definition at line 118 of file FeatureFloodCount.h.

118  : unsigned char
119  {
120  CLEAR = 0x0,
121  MARKED = 0x1,
122  DIRTY = 0x2,
123  INACTIVE = 0x4
124  };

Constructor & Destructor Documentation

◆ FauxGrainTracker()

FauxGrainTracker::FauxGrainTracker ( const InputParameters &  parameters)

Definition at line 29 of file FauxGrainTracker.C.

30  : FeatureFloodCount(parameters),
32  _grain_count(0),
33  _n_vars(_vars.size()),
34  _tracking_step(getParam<int>("tracking_step"))
35 {
36  // initialize faux data with identity map
37  _op_to_grains.resize(_n_vars);
38  for (MooseIndex(_op_to_grains) i = 0; i < _op_to_grains.size(); ++i)
39  _op_to_grains[i] = i;
40 
42 }
FeatureFloodCount(const InputParameters &parameters)
std::vector< unsigned int > _empty_var_to_features
This class defines the interface for the GrainTracking objects.
std::vector< unsigned int > _op_to_grains
Order parameter to grain indices (just a reflexive vector)
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
const int _tracking_step
Used to emulate the tracking step of the real grain tracker object.
static const unsigned int invalid_id
std::size_t _grain_count
Total Grain Count.
const std::size_t _n_vars

◆ ~FauxGrainTracker()

FauxGrainTracker::~FauxGrainTracker ( )
virtual

Definition at line 44 of file FauxGrainTracker.C.

44 {}

Member Function Documentation

◆ appendPeriodicNeighborNodes()

void FeatureFloodCount::appendPeriodicNeighborNodes ( FeatureData feature) const
protectedinherited

This routine adds the periodic node information to our data structure prior to packing the data this makes those periodic neighbors appear much like ghosted nodes in a multiprocessor setting.

Definition at line 1726 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::prepareDataForTransfer().

1727 {
1728  if (_is_elemental)
1729  {
1730  for (auto entity : feature._local_ids)
1731  {
1732  Elem * elem = _mesh.elemPtr(entity);
1733 
1734  for (MooseIndex(elem->n_nodes()) node_n = 0; node_n < elem->n_nodes(); ++node_n)
1735  {
1736  auto iters = _periodic_node_map.equal_range(elem->node_id(node_n));
1737 
1738  for (auto it = iters.first; it != iters.second; ++it)
1739  {
1740  feature._periodic_nodes.insert(feature._periodic_nodes.end(), it->first);
1741  feature._periodic_nodes.insert(feature._periodic_nodes.end(), it->second);
1742  }
1743  }
1744  }
1745  }
1746  else
1747  {
1748  for (auto entity : feature._local_ids)
1749  {
1750  auto iters = _periodic_node_map.equal_range(entity);
1751 
1752  for (auto it = iters.first; it != iters.second; ++it)
1753  {
1754  feature._periodic_nodes.insert(feature._periodic_nodes.end(), it->first);
1755  feature._periodic_nodes.insert(feature._periodic_nodes.end(), it->second);
1756  }
1757  }
1758  }
1759 
1760  // TODO: Remove duplicates
1761 }
std::multimap< dof_id_type, dof_id_type > _periodic_node_map
The data structure which is a list of nodes that are constrained to other nodes based on the imposed ...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
MooseMesh & _mesh
A reference to the mesh.

◆ areFeaturesMergeable()

bool FeatureFloodCount::areFeaturesMergeable ( const FeatureData f1,
const FeatureData f2 
) const
protectedvirtualinherited

Method for determining whether two features are mergeable.

This routine exists because derived classes may need to override this function rather than use the mergeable method in the FeatureData object.

Reimplemented in PolycrystalUserObjectBase.

Definition at line 1208 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::mergeSets().

1209 {
1210  return f1.mergeable(f2);
1211 }

◆ buildFeatureIdToLocalIndices()

void FeatureFloodCount::buildFeatureIdToLocalIndices ( unsigned int  max_id)
protectedinherited

This method builds a lookup map for retrieving the right local feature (by index) given a global index or id.

max_id is passed to size the vector properly and may or may not be a globally consistent number. The assumption is that any id that is later queried from this object that is higher simply doesn't exist on the local processor.

Definition at line 655 of file FeatureFloodCount.C.

Referenced by GrainTracker::assignGrains(), FeatureFloodCount::scatterAndUpdateRanks(), and GrainTracker::trackGrains().

656 {
657  _feature_id_to_local_index.assign(max_id + 1, invalid_size_t);
658  for (MooseIndex(_feature_sets) feature_index = 0; feature_index < _feature_sets.size();
659  ++feature_index)
660  {
661  if (_feature_sets[feature_index]._status != Status::INACTIVE)
662  {
663  mooseAssert(_feature_sets[feature_index]._id <= max_id,
664  "Feature ID out of range(" << _feature_sets[feature_index]._id << ')');
665  _feature_id_to_local_index[_feature_sets[feature_index]._id] = feature_index;
666  }
667  }
668 }
static const std::size_t invalid_size_t
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
std::vector< std::size_t > _feature_id_to_local_index
The vector recording the grain_id to local index (several indices will contain invalid_size_t) ...

◆ buildLocalToGlobalIndices()

void FeatureFloodCount::buildLocalToGlobalIndices ( std::vector< std::size_t > &  local_to_global_all,
std::vector< int > &  counts 
) const
protectedvirtualinherited

This routine populates a stacked vector of local to global indices per rank and the associated count vector for scattering the vector to the ranks.

The individual vectors can be different sizes. The ith vector will be distributed to the ith processor including the master rank. e.g. [ ... n_0 ] [ ... n_1 ] ... [ ... n_m ]

It is intended to be overridden in derived classes.

Definition at line 609 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::scatterAndUpdateRanks().

611 {
612  mooseAssert(_is_master, "This method must only be called on the root processor");
613 
614  counts.assign(_n_procs, 0);
615  // Now size the individual counts vectors based on the largest index seen per processor
616  for (const auto & feature : _feature_sets)
617  for (const auto & local_index_pair : feature._orig_ids)
618  {
619  // local_index_pair.first = ranks, local_index_pair.second = local_index
620  mooseAssert(local_index_pair.first < _n_procs, "Processor ID is out of range");
621  if (local_index_pair.second >= static_cast<std::size_t>(counts[local_index_pair.first]))
622  counts[local_index_pair.first] = local_index_pair.second + 1;
623  }
624 
625  // Build the offsets vector
626  unsigned int globalsize = 0;
627  std::vector<int> offsets(_n_procs); // Type is signed for use with the MPI API
628  for (MooseIndex(offsets) i = 0; i < offsets.size(); ++i)
629  {
630  offsets[i] = globalsize;
631  globalsize += counts[i];
632  }
633 
634  // Finally populate the master vector
635  local_to_global_all.resize(globalsize, FeatureFloodCount::invalid_size_t);
636  for (const auto & feature : _feature_sets)
637  {
638  // Get the local indices from the feature and build a map
639  for (const auto & local_index_pair : feature._orig_ids)
640  {
641  auto rank = local_index_pair.first;
642  mooseAssert(rank < _n_procs, rank << ", " << _n_procs);
643 
644  auto local_index = local_index_pair.second;
645  auto stacked_local_index = offsets[rank] + local_index;
646 
647  mooseAssert(stacked_local_index < globalsize,
648  "Global index: " << stacked_local_index << " is out of range");
649  local_to_global_all[stacked_local_index] = feature._id;
650  }
651  }
652 }
static const std::size_t invalid_size_t
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
const bool _is_master
Convenience variable for testing master rank.
const processor_id_type _n_procs
Convenience variable holding the number of processors in this simulation.

◆ clearDataStructures()

void FeatureFloodCount::clearDataStructures ( )
protectedvirtualinherited

Helper routine for clearing up data structures during initialize and prior to parallel communication.

Definition at line 321 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::communicateAndMerge().

322 {
323 }

◆ communicateAndMerge()

void FeatureFloodCount::communicateAndMerge ( )
protectedinherited

This routine handles all of the serialization, communication and deserialization of the data structures containing FeatureData objects.

The libMesh packed range routines handle the communication of the individual string buffers. Here we need to create a container to hold our type to serialize. It'll always be size one because we are sending a single byte stream of all the data to other processors. The stream need not be the same size on all processors.

Additionally we need to create a different container to hold the received byte buffers. The container type need not match the send container type. However, We do know the number of incoming buffers (num processors) so we'll go ahead and use a vector.

When we distribute merge work, we are reducing computational work by adding more communication. Each of the first _n_vars processors will receive one variable worth of information to merge. After each of those processors has merged that information, it'll be sent to the master processor where final consolidation will occur.

Send the data from all processors to the first _n_vars processors to create a complete global feature maps for each variable.

A call to gather_packed_range seems to populate the receiving buffer on all processors, not just the receiving buffer on the actual receiving processor. If we plan to call this function repeatedly, we must clear the buffers each time on all non-receiving processors. On the actual receiving processor, we'll save off the buffer for use later.

The FeatureFloodCount and derived algorithms rely on having the data structures intact on all non-zero ranks. This is because local-only information (local entities) is never communicated and thus must remain intact. However, the distributed merging will destroy that information. The easiest thing to do is to swap out the data structure while we perform the distributed merge work.

Send the data from the merging processors to the root to create a complete global feature map.

Send the data from all processors to the root to create a complete global feature map.

Definition at line 402 of file FeatureFloodCount.C.

Referenced by GrainTracker::finalize(), and FeatureFloodCount::finalize().

403 {
404  TIME_SECTION(_comm_and_merge);
405 
406  // First we need to transform the raw data into a usable data structure
408 
416  std::vector<std::string> send_buffers(1);
417 
424  std::vector<std::string> recv_buffers, deserialize_buffers;
425 
433  {
434  auto rank = processor_id();
435  bool is_merging_processor = rank < _n_vars;
436 
437  if (is_merging_processor)
438  recv_buffers.reserve(_app.n_processors());
439 
440  for (MooseIndex(_n_vars) i = 0; i < _n_vars; ++i)
441  {
442  serialize(send_buffers[0], i);
443 
448  _communicator.gather_packed_range(i,
449  (void *)(nullptr),
450  send_buffers.begin(),
451  send_buffers.end(),
452  std::back_inserter(recv_buffers));
453 
460  if (rank == i)
461  recv_buffers.swap(deserialize_buffers);
462  else
463  recv_buffers.clear();
464  }
465 
466  // Setup a new communicator for doing merging communication operations
467  Parallel::Communicator merge_comm;
468 
469  // TODO: Update to MPI_UNDEFINED when libMesh bug is fixed.
470  _communicator.split(is_merging_processor ? 0 : 1, rank, merge_comm);
471 
472  if (is_merging_processor)
473  {
481  std::vector<std::list<FeatureData>> tmp_data(_partial_feature_sets.size());
482  tmp_data.swap(_partial_feature_sets);
483 
484  deserialize(deserialize_buffers, processor_id());
485 
486  send_buffers[0].clear();
487  recv_buffers.clear();
488  deserialize_buffers.clear();
489 
490  // Merge one variable's worth of data
491  mergeSets();
492 
493  // Now we need to serialize again to send to the master (only the processors who did work)
494  serialize(send_buffers[0]);
495 
496  // Free up as much memory as possible here before we do global communication
498 
503  merge_comm.gather_packed_range(0,
504  (void *)(nullptr),
505  send_buffers.begin(),
506  send_buffers.end(),
507  std::back_inserter(recv_buffers));
508 
509  if (_is_master)
510  {
511  // The root process now needs to deserialize all of the data
512  deserialize(recv_buffers);
513 
514  send_buffers[0].clear();
515  recv_buffers.clear();
516 
517  consolidateMergedFeatures(&tmp_data);
518  }
519  else
520  // Restore our original data on non-zero ranks
521  tmp_data.swap(_partial_feature_sets);
522  }
523  }
524 
525  // Serialized merging (master does all the work)
526  else
527  {
528  if (_is_master)
529  recv_buffers.reserve(_app.n_processors());
530 
531  serialize(send_buffers[0]);
532 
533  // Free up as much memory as possible here before we do global communication
535 
540  _communicator.gather_packed_range(0,
541  (void *)(nullptr),
542  send_buffers.begin(),
543  send_buffers.end(),
544  std::back_inserter(recv_buffers));
545 
546  if (_is_master)
547  {
548  // The root process now needs to deserialize all of the data
549  deserialize(recv_buffers);
550  recv_buffers.clear();
551 
552  mergeSets();
553 
555  }
556  }
557 
558  // Make sure that feature count is communicated to all ranks
559  _communicator.broadcast(_feature_count);
560 }
const std::size_t _n_vars
void serialize(std::string &serialized_buffer, unsigned int var_num=invalid_id)
This routines packs the _partial_feature_sets data into a structure suitable for parallel communicati...
const PerfID _comm_and_merge
const bool _is_master
Convenience variable for testing master rank.
void consolidateMergedFeatures(std::vector< std::list< FeatureData >> *saved_data=nullptr)
This method consolidates all of the merged information from _partial_feature_sets into the _feature_s...
virtual void clearDataStructures()
Helper routine for clearing up data structures during initialize and prior to parallel communication...
unsigned int _feature_count
The number of features seen by this object (same as summing _feature_counts_per_map) ...
virtual void mergeSets()
This routine is called on the master rank only and stitches together the partial feature pieces seen ...
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
const bool _distribute_merge_work
Keeps track of whether we are distributing the merge work.
void deserialize(std::vector< std::string > &serialized_buffers, unsigned int var_num=invalid_id)
This routine takes the vector of byte buffers (one for each processor), deserializes them into a seri...
void prepareDataForTransfer()
This routine uses the local flooded data to build up the local feature data structures (_feature_sets...

◆ compareValueWithThreshold()

bool FeatureFloodCount::compareValueWithThreshold ( Real  entity_value,
Real  threshold 
) const
protectedinherited

This method is used to determine whether the current entity value is part of a feature or not.

Comparisons can either be greater than or less than the threshold which is controlled via input parameter.

Definition at line 1383 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::isNewFeatureOrConnectedRegion().

1384 {
1385  return ((_use_less_than_threshold_comparison && (entity_value >= threshold)) ||
1386  (!_use_less_than_threshold_comparison && (entity_value <= threshold)));
1387 }
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.

◆ deserialize()

void FeatureFloodCount::deserialize ( std::vector< std::string > &  serialized_buffers,
unsigned int  var_num = invalid_id 
)
protectedinherited

This routine takes the vector of byte buffers (one for each processor), deserializes them into a series of FeatureSet objects, and appends them to the _feature_sets data structure.

Note: It is assumed that local processor information may already be stored in the _feature_sets data structure so it is not cleared before insertion.

Usually we have the local processor data already in the _partial_feature_sets data structure. However, if we are doing distributed merge work, we also need to preserve all of the original data for use in later stages of the algorithm so it'll have been swapped out with clean buffers. This leaves us a choice, either we just duplicate the Features from the original data structure after we've swapped out the buffer, or we go ahead and unpack data that we would normally already have. So during distributed merging, that's exactly what we'll do. Later however when the master is doing the final consolidating, we'll opt to just skip the local unpacking. To tell the difference, between these two modes, we just need to see if a var_num was passed in.

Definition at line 1051 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::communicateAndMerge().

1052 {
1053  // The input string stream used for deserialization
1054  std::istringstream iss;
1055 
1056  auto rank = processor_id();
1057 
1058  for (MooseIndex(serialized_buffers) proc_id = 0; proc_id < serialized_buffers.size(); ++proc_id)
1059  {
1071  if (var_num == invalid_id && proc_id == rank)
1072  continue;
1073 
1074  iss.str(serialized_buffers[proc_id]); // populate the stream with a new buffer
1075  iss.clear(); // reset the string stream state
1076 
1077  // Load the gathered data into the data structure.
1078  if (var_num == invalid_id)
1079  dataLoad(iss, _partial_feature_sets, this);
1080  else
1081  dataLoad(iss, _partial_feature_sets[var_num], this);
1082  }
1083 }
void dataLoad(std::istream &stream, FeatureFloodCount::FeatureData &feature, void *context)
static const unsigned int invalid_id
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...

◆ doesFeatureIntersectBoundary()

bool FauxGrainTracker::doesFeatureIntersectBoundary ( unsigned int  feature_id) const
overridevirtual

Returns a Boolean indicating whether this feature intersects any boundary.

Reimplemented from FeatureFloodCount.

Definition at line 271 of file FauxGrainTracker.C.

272 {
273  mooseDoOnce(mooseWarning("FauxGrainTracker::doesFeatureIntersectboundary() is unimplemented"));
274 
275  return false;
276 }

◆ execute()

void FauxGrainTracker::execute ( )
overridevirtual

Reimplemented from FeatureFloodCount.

Definition at line 155 of file FauxGrainTracker.C.

156 {
157  Moose::perf_log.push("execute()", "FauxGrainTracker");
158 
159  for (const auto & current_elem : _mesh.getMesh().active_local_element_ptr_range())
160  {
161  // Loop over elements or nodes and populate the data structure with the first variable with a
162  // value above a threshold
163  if (_is_elemental)
164  {
165  std::vector<Point> centroid(1, current_elem->centroid());
166  _fe_problem.reinitElemPhys(current_elem, centroid, 0);
167 
168  auto entity = current_elem->id();
169  auto insert_pair =
170  moose_try_emplace(_entity_var_to_features,
171  entity,
172  std::vector<unsigned int>(_n_vars, FeatureFloodCount::invalid_id));
173  auto & vec_ref = insert_pair.first->second;
174 
175  for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
176  {
177  auto entity_value = _vars[var_num]->sln()[0];
178 
179  if ((_use_less_than_threshold_comparison && (entity_value >= _threshold)) ||
180  (!_use_less_than_threshold_comparison && (entity_value <= _threshold)))
181  {
182  _entity_id_to_var_num[current_elem->id()] = var_num;
183  _variables_used.insert(var_num);
184  _volume[var_num] += current_elem->volume();
185  _vol_count[var_num]++;
186  // Sum the centroid values for now, we'll average them later
187  _centroid[var_num] += current_elem->centroid();
188  vec_ref[var_num] = var_num;
189  break;
190  }
191  }
192  }
193  else
194  {
195  unsigned int n_nodes = current_elem->n_vertices();
196  for (unsigned int i = 0; i < n_nodes; ++i)
197  {
198  const Node * current_node = current_elem->node_ptr(i);
199 
200  for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
201  {
202  auto entity_value = _vars[var_num]->getNodalValue(*current_node);
203  if ((_use_less_than_threshold_comparison && (entity_value >= _threshold)) ||
204  (!_use_less_than_threshold_comparison && (entity_value <= _threshold)))
205  {
206  _entity_id_to_var_num[current_node->id()] = var_num;
207  _variables_used.insert(var_num);
208  break;
209  }
210  }
211  }
212  }
213  }
214 
215  _grain_count = std::max(_grain_count, _variables_used.size());
216 
217  Moose::perf_log.pop("execute()", "FauxGrainTracker");
218 }
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
std::map< unsigned int, unsigned int > _vol_count
The count of entities contributing to the volume calculation.
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.
static const unsigned int invalid_id
std::map< dof_id_type, unsigned int > _entity_id_to_var_num
The mapping of entities to grains, in this case always the order parameter.
const Real _threshold
The threshold above (or below) where an entity may begin a new region (feature)
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::size_t _grain_count
Total Grain Count.
std::map< unsigned int, Point > _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
std::map< unsigned int, Real > _volume
The volume of the feature.
MooseMesh & _mesh
A reference to the mesh.
const std::size_t _n_vars

◆ expandEdgeHalos()

void FeatureFloodCount::expandEdgeHalos ( unsigned int  num_layers_to_expand)
protectedinherited

This method expands the existing halo set by some width determined by the passed in value.

This method does NOT mask off any local IDs.

Create a copy of the halo set so that as we insert new ids into the set we don't continue to iterate on those new ids.

We have to handle disjoint halo IDs slightly differently. Once you are disjoint, you can't go back so make sure that we keep placing these IDs in the disjoint set.

Definition at line 1492 of file FeatureFloodCount.C.

Referenced by GrainTracker::finalize(), and PolycrystalUserObjectBase::finalize().

1493 {
1494  if (num_layers_to_expand == 0)
1495  return;
1496 
1497  TIME_SECTION(_expand_halos);
1498 
1499  for (auto & list_ref : _partial_feature_sets)
1500  {
1501  for (auto & feature : list_ref)
1502  {
1503  for (MooseIndex(num_layers_to_expand) halo_level = 0; halo_level < num_layers_to_expand;
1504  ++halo_level)
1505  {
1510  FeatureData::container_type orig_halo_ids(feature._halo_ids);
1511  for (auto entity : orig_halo_ids)
1512  {
1513  if (_is_elemental)
1514  visitElementalNeighbors(_mesh.elemPtr(entity),
1515  &feature,
1516  /*expand_halos_only =*/true,
1517  /*disjoint_only =*/false);
1518  else
1519  visitNodalNeighbors(_mesh.nodePtr(entity),
1520  &feature,
1521  /*expand_halos_only =*/true);
1522  }
1523 
1528  FeatureData::container_type disjoint_orig_halo_ids(feature._disjoint_halo_ids);
1529  for (auto entity : disjoint_orig_halo_ids)
1530  {
1531  if (_is_elemental)
1532  visitElementalNeighbors(_mesh.elemPtr(entity),
1533 
1534  &feature,
1535  /*expand_halos_only =*/true,
1536  /*disjoint_only =*/true);
1537  else
1538  visitNodalNeighbors(_mesh.nodePtr(entity),
1539 
1540  &feature,
1541  /*expand_halos_only =*/true);
1542  }
1543  }
1544  }
1545  }
1546 }
void visitNodalNeighbors(const Node *node, FeatureData *feature, bool expand_halos_only)
These two routines are utility routines used by the flood routine and by derived classes for visiting...
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
void visitElementalNeighbors(const Elem *elem, FeatureData *feature, bool expand_halos_only, bool disjoint_only)
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
const PerfID _expand_halos
MooseMesh & _mesh
A reference to the mesh.

◆ expandPointHalos()

void FeatureFloodCount::expandPointHalos ( )
protectedinherited

This method takes all of the partial features and expands the local, ghosted, and halo sets around those regions to account for the diffuse interface.

Rather than using any kind of recursion here, we simply expand the region by all "point" neighbors from the actual grain cells since all point neighbors will contain contributions to the region.

To expand the feature element region to the actual flooded region (nodal basis) we need to add in all point neighbors of the current local region for each feature. This is because the elemental variable influence spreads from the elemental data out exactly one element from every mesh point.

Definition at line 1430 of file FeatureFloodCount.C.

1431 {
1432  const auto & node_to_elem_map = _mesh.nodeToActiveSemilocalElemMap();
1433  FeatureData::container_type expanded_local_ids;
1434  auto my_processor_id = processor_id();
1435 
1442  for (auto & list_ref : _partial_feature_sets)
1443  {
1444  for (auto & feature : list_ref)
1445  {
1446  expanded_local_ids.clear();
1447 
1448  for (auto entity : feature._local_ids)
1449  {
1450  const Elem * elem = _mesh.elemPtr(entity);
1451  mooseAssert(elem, "elem pointer is NULL");
1452 
1453  // Get the nodes on a current element so that we can add in point neighbors
1454  auto n_nodes = elem->n_vertices();
1455  for (MooseIndex(n_nodes) i = 0; i < n_nodes; ++i)
1456  {
1457  const Node * current_node = elem->node_ptr(i);
1458 
1459  auto elem_vector_it = node_to_elem_map.find(current_node->id());
1460  if (elem_vector_it == node_to_elem_map.end())
1461  mooseError("Error in node to elem map");
1462 
1463  const auto & elem_vector = elem_vector_it->second;
1464 
1465  std::copy(elem_vector.begin(),
1466  elem_vector.end(),
1467  std::insert_iterator<FeatureData::container_type>(expanded_local_ids,
1468  expanded_local_ids.end()));
1469 
1470  // Now see which elements need to go into the ghosted set
1471  for (auto entity : elem_vector)
1472  {
1473  const Elem * neighbor = _mesh.elemPtr(entity);
1474  mooseAssert(neighbor, "neighbor pointer is NULL");
1475 
1476  if (neighbor->processor_id() != my_processor_id)
1477  feature._ghosted_ids.insert(feature._ghosted_ids.end(), elem->id());
1478  }
1479  }
1480  }
1481 
1482  // Replace the existing local ids with the expanded local ids
1483  feature._local_ids.swap(expanded_local_ids);
1484 
1485  // Copy the expanded local_ids into the halo_ids container
1486  feature._halo_ids = feature._local_ids;
1487  }
1488  }
1489 }
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
MooseMesh & _mesh
A reference to the mesh.

◆ featureCentroid()

Point FeatureFloodCount::featureCentroid ( unsigned int  feature_id) const
virtualinherited

Returns the centroid of the designated feature (only supported without periodic boundaries)

Definition at line 865 of file FeatureFloodCount.C.

Referenced by FeatureVolumeVectorPostprocessor::execute().

866 {
867  if (feature_id >= _feature_id_to_local_index.size())
868  return invalid_id;
869 
870  auto local_index = _feature_id_to_local_index[feature_id];
871 
872  Real invalid_coord = std::numeric_limits<Real>::max();
873  Point p(invalid_coord, invalid_coord, invalid_coord);
874  if (local_index != invalid_size_t)
875  {
876  mooseAssert(local_index < _feature_sets.size(), "local_index out of bounds");
877  p = _feature_sets[local_index]._centroid;
878  }
879  return p;
880 }
static const std::size_t invalid_size_t
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
static const unsigned int invalid_id
std::vector< std::size_t > _feature_id_to_local_index
The vector recording the grain_id to local index (several indices will contain invalid_size_t) ...

◆ finalize()

void FauxGrainTracker::finalize ( )
overridevirtual

Convert elements of the maps into simple values or vector of Real. libMesh's _communicator.sum() does not work on std::maps

Reimplemented from FeatureFloodCount.

Definition at line 221 of file FauxGrainTracker.C.

222 {
223  Moose::perf_log.push("finalize()", "FauxGrainTracker");
224 
225  _communicator.set_union(_variables_used);
226  _communicator.set_union(_entity_id_to_var_num);
227 
228  if (_is_elemental)
229  for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
230  {
235  unsigned int vol_count;
236  std::vector<Real> grain_data(4);
237 
238  const auto count = _vol_count.find(var_num);
239  if (count != _vol_count.end())
240  vol_count = count->second;
241 
242  const auto vol = _volume.find(var_num);
243  if (vol != _volume.end())
244  grain_data[0] = vol->second;
245 
246  const auto centroid = _centroid.find(var_num);
247  if (centroid != _centroid.end())
248  {
249  grain_data[1] = centroid->second(0);
250  grain_data[2] = centroid->second(1);
251  grain_data[3] = centroid->second(2);
252  }
253  // combine centers & volumes from all MPI ranks
254  gatherSum(vol_count);
255  gatherSum(grain_data);
256  _volume[var_num] = grain_data[0];
257  _centroid[var_num] = {grain_data[1], grain_data[2], grain_data[3]};
258  _centroid[var_num] /= vol_count;
259  }
260 
261  Moose::perf_log.pop("finalize()", "FauxGrainTracker");
262 }
std::map< unsigned int, unsigned int > _vol_count
The count of entities contributing to the volume calculation.
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
std::map< dof_id_type, unsigned int > _entity_id_to_var_num
The mapping of entities to grains, in this case always the order parameter.
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::map< unsigned int, Point > _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
std::map< unsigned int, Real > _volume
The volume of the feature.
const std::size_t _n_vars

◆ flood()

bool FeatureFloodCount::flood ( const DofObject *  dof_object,
std::size_t  current_index 
)
protectedinherited

This method will check if the current entity is above the supplied threshold and "mark" it.

It will then inspect neighboring entities that are above the connecting threshold and add them to the current feature.

Returns
Boolean indicating whether a new feature was found while exploring the current entity.

If we reach this point (i.e. we haven't continued to the next queue entry), we've found a new mesh entity that's part of a feature. We need to mark the entity as visited at this point (and not before!) to avoid infinite recursion. If you mark the node too early you risk not coloring in a whole feature any time a "connecting threshold" is used since we may have already visited this entity earlier but it was in-between two thresholds.

See if this particular entity cell contributes to the centroid calculation. We only deal with elemental floods and only count it if it's owned by the current processor to avoid skewing the result.

Definition at line 1259 of file FeatureFloodCount.C.

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

1261 {
1262  // if (dof_object == nullptr || dof_object == libMesh::remote_elem)
1263  // return false;
1264  mooseAssert(dof_object, "DOF object is nullptr");
1265  mooseAssert(_entity_queue.empty(), "Entity queue is not empty when starting a feature");
1266 
1267  // Kick off the exploration of a new feature
1268  _entity_queue.push_front(dof_object);
1269 
1270  bool return_value = false;
1271  FeatureData * feature = nullptr;
1272  while (!_entity_queue.empty())
1273  {
1274  const DofObject * curr_dof_object = _entity_queue.back();
1275  const Elem * elem = _is_elemental ? static_cast<const Elem *>(curr_dof_object) : nullptr;
1276  _entity_queue.pop_back();
1277 
1278  // Retrieve the id of the current entity
1279  auto entity_id = curr_dof_object->id();
1280 
1281  // Has this entity already been marked? - if so move along
1282  if (current_index != invalid_size_t &&
1283  _entities_visited[current_index].find(entity_id) != _entities_visited[current_index].end())
1284  continue;
1285 
1286  // Are we outside of the range we should be working in?
1287  if (_is_elemental && !_dof_map.is_evaluable(*elem))
1288  continue;
1289 
1290  // See if the current entity either starts a new feature or continues an existing feature
1291  auto new_id = invalid_id; // Writable reference to hold an optional id;
1292  Status status =
1293  Status::INACTIVE; // Status is inactive until we find an entity above the starting threshold
1294 
1295  // Make sure that the Assembly object has the right element and subdomain information set
1296  // since we are moving through the mesh in a manual fashion.
1297  if (_is_elemental)
1298  _fe_problem.setCurrentSubdomainID(elem, 0);
1299 
1300  if (!isNewFeatureOrConnectedRegion(curr_dof_object, current_index, feature, status, new_id))
1301  {
1302  // If we have an active feature, we just found a halo entity
1303  if (feature)
1304  feature->_halo_ids.insert(feature->_halo_ids.end(), entity_id);
1305  continue;
1306  }
1307 
1308  mooseAssert(current_index != invalid_size_t, "current_index is invalid");
1309 
1318  return_value = true;
1319  _entities_visited[current_index].insert(entity_id);
1320 
1321  auto map_num = _single_map_mode ? decltype(current_index)(0) : current_index;
1322 
1323  // New Feature (we need to create it and add it to our data structure)
1324  if (!feature)
1325  {
1326  _partial_feature_sets[map_num].emplace_back(
1327  current_index, _feature_count++, processor_id(), status);
1328 
1329  // Get a handle to the feature we will update (always the last feature in the data structure)
1330  feature = &_partial_feature_sets[map_num].back();
1331 
1332  // If new_id is valid, we'll set it in the feature here.
1333  if (new_id != invalid_id)
1334  feature->_id = new_id;
1335  }
1336 
1337  // Insert the current entity into the local ids data structure
1338  feature->_local_ids.insert(feature->_local_ids.end(), entity_id);
1339 
1345  if (_is_elemental && processor_id() == curr_dof_object->processor_id())
1346  {
1347  // Keep track of how many elements participate in the centroid averaging
1348  feature->_vol_count++;
1349 
1350  // Sum the centroid values for now, we'll average them later
1351  feature->_centroid += elem->centroid();
1352 
1353  // // Does the volume intersect the boundary?
1354  // if (_all_boundary_entity_ids.find(elem->id()) != _all_boundary_entity_ids.end())
1355  // feature->_intersects_boundary = true;
1356  }
1357 
1358  if (_is_elemental)
1360  feature,
1361  /*expand_halos_only =*/false,
1362  /*disjoint_only =*/false);
1363  else
1364  visitNodalNeighbors(static_cast<const Node *>(curr_dof_object),
1365  feature,
1366  /*expand_halos_only =*/false);
1367  }
1368 
1369  return return_value;
1370 }
void visitNodalNeighbors(const Node *node, FeatureData *feature, bool expand_halos_only)
These two routines are utility routines used by the flood routine and by derived classes for visiting...
static const std::size_t invalid_size_t
Status
This enumeration is used to indicate status of the grains in the _unique_grains data structure...
std::vector< std::set< dof_id_type > > _entities_visited
This variable keeps track of which nodes have been visited during execution.
void visitElementalNeighbors(const Elem *elem, FeatureData *feature, bool expand_halos_only, bool disjoint_only)
const DofMap & _dof_map
Reference to the dof_map containing the coupled variables.
static const unsigned int invalid_id
const bool _single_map_mode
This variable is used to indicate whether or not multiple maps are used during flooding.
unsigned int _feature_count
The number of features seen by this object (same as summing _feature_counts_per_map) ...
virtual bool isNewFeatureOrConnectedRegion(const DofObject *dof_object, std::size_t &current_index, FeatureData *&feature, Status &status, unsigned int &new_id)
Method called during the recursive flood routine that should return whether or not the current entity...
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::deque< const DofObject * > _entity_queue
The data structure for maintaining entities to flood during discovery.

◆ getConnectingThreshold()

Real FeatureFloodCount::getConnectingThreshold ( std::size_t  current_index) const
protectedvirtualinherited

Return the "connecting" comparison threshold to use when inspecting an entity during the flood stage.

Definition at line 1377 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::isNewFeatureOrConnectedRegion().

1378 {
1380 }

◆ getCoupledVars()

const std::vector<MooseVariable *>& FeatureFloodCount::getCoupledVars ( ) const
inlineinherited

Returns a const vector to the coupled variable pointers.

Definition at line 96 of file FeatureFloodCount.h.

Referenced by AverageGrainVolume::AverageGrainVolume(), and FeatureVolumeVectorPostprocessor::FeatureVolumeVectorPostprocessor().

96 { return _vars; }
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.

◆ getEntityValue()

Real FauxGrainTracker::getEntityValue ( dof_id_type  entity_id,
FeatureFloodCount::FieldType  field_type,
std::size_t  var_idx 
) const
overridevirtual

Reimplemented from FeatureFloodCount.

Definition at line 47 of file FauxGrainTracker.C.

50 {
51  if (var_idx == FeatureFloodCount::invalid_size_t)
52  var_idx = 0;
53 
54  mooseAssert(var_idx < _n_vars, "Index out of range");
55 
56  switch (field_type)
57  {
60  {
61  auto entity_it = _entity_id_to_var_num.find(entity_id);
62 
63  if (entity_it != _entity_id_to_var_num.end())
64  return entity_it->second;
65  else
66  return -1;
67  break;
68  }
69 
71  {
72  if (_periodic_node_map.size())
73  mooseDoOnce(mooseWarning(
74  "Centroids are not correct when using periodic boundaries, contact the MOOSE team"));
75 
76  // If this element contains the centroid of one of features, return it's index
77  const auto * elem_ptr = _mesh.elemPtr(entity_id);
78  for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
79  {
80  const auto centroid = _centroid.find(var_num);
81  if (centroid != _centroid.end())
82  if (elem_ptr->contains_point(centroid->second))
83  return 1;
84  }
85 
86  return 0;
87  }
88 
89  // We don't want to error here because this should be a drop in replacement for the real grain
90  // tracker.
91  // Instead we'll just return zero and continue
92  default:
93  return 0;
94  }
95 
96  return 0;
97 }
std::multimap< dof_id_type, dof_id_type > _periodic_node_map
The data structure which is a list of nodes that are constrained to other nodes based on the imposed ...
static const std::size_t invalid_size_t
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
std::map< dof_id_type, unsigned int > _entity_id_to_var_num
The mapping of entities to grains, in this case always the order parameter.
std::map< unsigned int, Point > _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
MooseMesh & _mesh
A reference to the mesh.
const std::size_t _n_vars

◆ getFeatures()

const std::vector<FeatureData>& FeatureFloodCount::getFeatures ( ) const
inlineinherited

Return a constant reference to the vector of all discovered features.

Definition at line 337 of file FeatureFloodCount.h.

Referenced by GrainTracker::prepopulateState().

337 { return _feature_sets; }
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.

◆ getFeatureVar()

unsigned int FauxGrainTracker::getFeatureVar ( unsigned int  feature_id) const
overridevirtual

Returns the variable representing the passed in feature.

Reimplemented from FeatureFloodCount.

Definition at line 113 of file FauxGrainTracker.C.

114 {
115  return feature_id;
116 }

◆ getFECoupledVars()

const std::vector<MooseVariableFEBase *>& FeatureFloodCount::getFECoupledVars ( ) const
inlineinherited

Returns a const vector to the coupled MooseVariableFEBase pointers.

Definition at line 99 of file FeatureFloodCount.h.

Referenced by AverageGrainVolume::AverageGrainVolume().

99 { return _fe_vars; }
std::vector< MooseVariableFEBase * > _fe_vars
The vector of coupled in variables.

◆ getGrainCentroid()

Point FauxGrainTracker::getGrainCentroid ( unsigned int  grain_id) const
overridevirtual

Returns the centroid for the given grain number.

Implements GrainTrackerInterface.

Definition at line 131 of file FauxGrainTracker.C.

132 {
133  const auto grain_center = _centroid.find(grain_index);
134  mooseAssert(grain_center != _centroid.end(),
135  "Grain " << grain_index << " does not exist in data structure");
136 
137  return grain_center->second;
138 }
std::map< unsigned int, Point > _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...

◆ getNewGrainIDs()

std::vector< unsigned int > GrainTrackerInterface::getNewGrainIDs ( ) const
virtualinherited

This method returns all of the new ids generated in an invocation of the GrainTracker.

Reimplemented in GrainTracker.

Definition at line 80 of file GrainTrackerInterface.C.

81 {
82  return std::vector<unsigned int>();
83 }

◆ getNumberActiveFeatures()

std::size_t FeatureFloodCount::getNumberActiveFeatures ( ) const
inherited

Return the number of active features.

Definition at line 780 of file FeatureFloodCount.C.

Referenced by AverageGrainVolume::getValue().

781 {
782  // Note: This value is parallel consistent, see FeatureFloodCount::communicateAndMerge()
783  return _feature_count;
784 }
unsigned int _feature_count
The number of features seen by this object (same as summing _feature_counts_per_map) ...

◆ getNumberActiveGrains()

std::size_t FauxGrainTracker::getNumberActiveGrains ( ) const
overridevirtual

Returns the number of active grains current stored in the GrainTracker.

This value is the same value reported when the GrainTracker (FeatureFloodObject) is used as a Postprocessor.

Note: This value will count each piece of a split grain (often encountered in EBSD data sets).

Implements GrainTrackerInterface.

Definition at line 119 of file FauxGrainTracker.C.

120 {
121  return _variables_used.size();
122 }
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.

◆ getThreshold()

Real FeatureFloodCount::getThreshold ( std::size_t  current_index) const
protectedvirtualinherited

Return the starting comparison threshold to use when inspecting an entity during the flood stage.

Reimplemented in GrainTracker.

Definition at line 1372 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::isNewFeatureOrConnectedRegion().

1373 {
1374  return _step_threshold;
1375 }

◆ getTotalFeatureCount()

std::size_t FauxGrainTracker::getTotalFeatureCount ( ) const
overridevirtual

Returns the total feature count (active and inactive ids, useful for sizing vectors)

Since the FeatureFloodCount object doesn't maintain any information about features between invocations. The maximum id in use is simply the number of features.

Reimplemented from FeatureFloodCount.

Definition at line 125 of file FauxGrainTracker.C.

126 {
127  return _grain_count;
128 }
std::size_t _grain_count
Total Grain Count.

◆ getValue()

Real FauxGrainTracker::getValue ( )
overridevirtual

Reimplemented from FeatureFloodCount.

Definition at line 265 of file FauxGrainTracker.C.

266 {
267  return static_cast<Real>(_variables_used.size());
268 }
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.

◆ getVarToFeatureVector()

const std::vector< unsigned int > & FauxGrainTracker::getVarToFeatureVector ( dof_id_type  elem_id) const
overridevirtual

Returns a list of active unique feature ids for a particular element.

The vector is indexed by variable number with each entry containing either an invalid size_t type (no feature active at that location) or a feature id if the variable is non-zero at that location.

Reimplemented from FeatureFloodCount.

Definition at line 100 of file FauxGrainTracker.C.

101 {
102  const auto pos = _entity_var_to_features.find(elem_id);
103  if (pos != _entity_var_to_features.end())
104  {
105  mooseAssert(pos->second.size() == _n_vars, "Variable to feature vector not sized properly");
106  return pos->second;
107  }
108  else
109  return _empty_var_to_features;
110 }
std::vector< unsigned int > _empty_var_to_features
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
const std::size_t _n_vars

◆ initialize()

void FauxGrainTracker::initialize ( )
overridevirtual

Reimplemented from FeatureFloodCount.

Definition at line 141 of file FauxGrainTracker.C.

142 {
143  _entity_id_to_var_num.clear();
144  _entity_var_to_features.clear();
145  _variables_used.clear();
146  if (_is_elemental)
147  {
148  _volume.clear();
149  _vol_count.clear();
150  _centroid.clear();
151  }
152 }
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
std::map< unsigned int, unsigned int > _vol_count
The count of entities contributing to the volume calculation.
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.
std::map< dof_id_type, unsigned int > _entity_id_to_var_num
The mapping of entities to grains, in this case always the order parameter.
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::map< unsigned int, Point > _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
std::map< unsigned int, Real > _volume
The volume of the feature.

◆ initialSetup()

void FeatureFloodCount::initialSetup ( )
overridevirtualinherited

Size the empty var to features vector to the number of coupled variables. This empty vector (but properly sized) vector is returned for elements that are queried but are not in the structure (which also shouldn't happen). The user is warned in this case but this helps avoid extra bounds checking in user code and avoids segfaults.

Reimplemented in PolycrystalUserObjectBase.

Definition at line 268 of file FeatureFloodCount.C.

Referenced by PolycrystalUserObjectBase::initialSetup().

269 {
270  // We need one map per coupled variable for normal runs to support overlapping features
271  _entities_visited.resize(_vars.size());
272 
273  // Get a pointer to the PeriodicBoundaries buried in libMesh
274  _pbs = _fe_problem.getNonlinearSystemBase().dofMap().get_periodic_boundaries();
275 
276  meshChanged();
277 
286 }
const std::size_t _n_vars
std::vector< std::set< dof_id_type > > _entities_visited
This variable keeps track of which nodes have been visited during execution.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
static const unsigned int invalid_id
PeriodicBoundaries * _pbs
A pointer to the periodic boundary constraints object.
std::vector< unsigned int > _empty_var_to_features
virtual void meshChanged() override

◆ isBoundaryEntity()

template<typename T >
bool FeatureFloodCount::isBoundaryEntity ( const T *  entity) const
protectedinherited

Returns a Boolean indicating whether the entity is on one of the desired boundaries.

Definition at line 1765 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::visitNeighborsHelper().

1766 {
1767  mooseAssert(_bnd_elem_range, "Boundary Element Range is nullptr");
1768 
1769  if (entity)
1770  for (const auto & belem : *_bnd_elem_range)
1771  // Only works for Elements
1772  if (belem->_elem->id() == entity->id() && hasBoundary(belem->_bnd_id))
1773  return true;
1774 
1775  return false;
1776 }
ConstBndElemRange * _bnd_elem_range
Boundary element range pointer.

◆ isElemental()

bool FeatureFloodCount::isElemental ( ) const
inlineinherited

Definition at line 115 of file FeatureFloodCount.h.

Referenced by FeatureFloodCountAux::FeatureFloodCountAux().

115 { return _is_elemental; }
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)

◆ isFeaturePercolated()

bool FeatureFloodCount::isFeaturePercolated ( unsigned int  feature_id) const
virtualinherited

Returns a Boolean indicating whether this feature is percolated (e.g.

intersects at least two different boundaries from sets supplied by the user)

Reimplemented in GrainTracker.

Definition at line 839 of file FeatureFloodCount.C.

Referenced by FeatureVolumeVectorPostprocessor::execute().

840 {
841  // TODO: This information is not parallel consistent when using FeatureFloodCounter
842 
843  // Some processors don't contain the largest feature id, in that case we just return invalid_id
844  if (feature_id >= _feature_id_to_local_index.size())
845  return false;
846 
847  auto local_index = _feature_id_to_local_index[feature_id];
848 
849  if (local_index != invalid_size_t)
850  {
851  mooseAssert(local_index < _feature_sets.size(), "local_index out of bounds");
852  bool primary = ((_feature_sets[local_index]._boundary_intersection &
855  bool secondary = ((_feature_sets[local_index]._boundary_intersection &
858  return _feature_sets[local_index]._status != Status::INACTIVE ? (primary && secondary) : false;
859  }
860 
861  return false;
862 }
static const std::size_t invalid_size_t
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
std::vector< std::size_t > _feature_id_to_local_index
The vector recording the grain_id to local index (several indices will contain invalid_size_t) ...

◆ isNewFeatureOrConnectedRegion()

bool FeatureFloodCount::isNewFeatureOrConnectedRegion ( const DofObject *  dof_object,
std::size_t &  current_index,
FeatureData *&  feature,
Status status,
unsigned int &  new_id 
)
protectedvirtualinherited

Method called during the recursive flood routine that should return whether or not the current entity is part of the current feature (if one is being explored), or if it's the start of a new feature.

If the value is only above the connecting threshold, it's still part of a feature but possibly part of one that we'll discard if there is never any starting threshold encountered.

Reimplemented in PolycrystalUserObjectBase.

Definition at line 1390 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::flood().

1395 {
1396  // Get the value of the current variable for the current entity
1397  Real entity_value;
1398  if (_is_elemental)
1399  {
1400  const Elem * elem = static_cast<const Elem *>(dof_object);
1401  std::vector<Point> centroid(1, elem->centroid());
1402  _subproblem.reinitElemPhys(elem, centroid, 0, /* suppress_displaced_init = */ true);
1403  entity_value = _vars[current_index]->sln()[0];
1404  }
1405  else
1406  entity_value = _vars[current_index]->getNodalValue(*static_cast<const Node *>(dof_object));
1407 
1408  // If the value compares against our starting threshold, this is definitely part of a feature
1409  // we'll keep
1410  if (compareValueWithThreshold(entity_value, getThreshold(current_index)))
1411  {
1412  Status * status_ptr = &status;
1413 
1414  if (feature)
1415  status_ptr = &feature->_status;
1416 
1417  // Update an existing feature's status or clear the flag on the passed in status
1418  *status_ptr &= ~Status::INACTIVE;
1419  return true;
1420  }
1421 
1426  return compareValueWithThreshold(entity_value, getConnectingThreshold(current_index));
1427 }
Status
This enumeration is used to indicate status of the grains in the _unique_grains data structure...
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
virtual Real getConnectingThreshold(std::size_t current_index) const
Return the "connecting" comparison threshold to use when inspecting an entity during the flood stage...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
bool compareValueWithThreshold(Real entity_value, Real threshold) const
This method is used to determine whether the current entity value is part of a feature or not...
virtual Real getThreshold(std::size_t current_index) const
Return the starting comparison threshold to use when inspecting an entity during the flood stage...

◆ mergeSets()

void FeatureFloodCount::mergeSets ( )
protectedvirtualinherited

This routine is called on the master rank only and stitches together the partial feature pieces seen on any processor.

Insert the new entity at the end of the list so that it may be checked against all other partial features again.

Now remove both halves the merged features: it2 contains the "moved" feature cell just inserted at the back of the list, it1 contains the mostly empty other half. We have to be careful about the order in which these two elements are deleted. We delete it2 first since we don't care where its iterator points after the deletion. We are going to break out of this loop anyway. If we delete it1 first, it may end up pointing at the same location as it2 which after the second deletion would cause both of the iterators to be invalidated.

Reimplemented in PolycrystalUserObjectBase.

Definition at line 1086 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::communicateAndMerge().

1087 {
1088  TIME_SECTION(_merge_timer);
1089 
1090  // When working with _distribute_merge_work all of the maps will be empty except for one
1091  for (MooseIndex(_maps_size) map_num = 0; map_num < _maps_size; ++map_num)
1092  {
1093  for (auto it1 = _partial_feature_sets[map_num].begin();
1094  it1 != _partial_feature_sets[map_num].end();
1095  /* No increment on it1 */)
1096  {
1097  bool merge_occured = false;
1098  for (auto it2 = _partial_feature_sets[map_num].begin();
1099  it2 != _partial_feature_sets[map_num].end();
1100  ++it2)
1101  {
1102  if (it1 != it2 && areFeaturesMergeable(*it1, *it2))
1103  {
1104  it2->merge(std::move(*it1));
1105 
1110  _partial_feature_sets[map_num].emplace_back(std::move(*it2));
1111 
1121  _partial_feature_sets[map_num].erase(it2);
1122  it1 = _partial_feature_sets[map_num].erase(it1); // it1 is incremented here!
1123 
1124  // A merge occurred, this is used to determine whether or not we increment the outer
1125  // iterator
1126  merge_occured = true;
1127 
1128  // We need to start the list comparison over for the new it1 so break here
1129  break;
1130  }
1131  } // it2 loop
1132 
1133  if (!merge_occured) // No merges so we need to manually increment the outer iterator
1134  ++it1;
1135 
1136  } // it1 loop
1137  } // map loop
1138 }
const PerfID _merge_timer
virtual bool areFeaturesMergeable(const FeatureData &f1, const FeatureData &f2) const
Method for determining whether two features are mergeable.
const std::size_t _maps_size
Convenience variable holding the size of all the datastructures size by the number of maps...
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...

◆ meshChanged()

void FeatureFloodCount::meshChanged ( )
overridevirtualinherited

We need to build a set containing all of the boundary entities to compare against. This will be elements for elemental flooding. Volumes for nodal flooding is not supported

Reimplemented in GrainTracker.

Definition at line 326 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::initialSetup(), and GrainTracker::meshChanged().

327 {
328  _point_locator = _mesh.getMesh().sub_point_locator();
329 
330  _mesh.buildPeriodicNodeMap(_periodic_node_map, _var_number, _pbs);
331 
332  // Build a new node to element map
333  _nodes_to_elem_map.clear();
334  MeshTools::build_nodes_to_elem_map(_mesh.getMesh(), _nodes_to_elem_map);
335 
341  _all_boundary_entity_ids.clear();
342  if (_is_elemental)
343  for (auto elem_it = _mesh.bndElemsBegin(), elem_end = _mesh.bndElemsEnd(); elem_it != elem_end;
344  ++elem_it)
345  _all_boundary_entity_ids.insert((*elem_it)->_elem->id());
346 }
std::multimap< dof_id_type, dof_id_type > _periodic_node_map
The data structure which is a list of nodes that are constrained to other nodes based on the imposed ...
unsigned long _var_number
This variable is used to build the periodic node map.
std::vector< std::vector< const Elem * > > _nodes_to_elem_map
The data structure used to find neighboring elements give a node ID.
std::unique_ptr< PointLocatorBase > _point_locator
PeriodicBoundaries * _pbs
A pointer to the periodic boundary constraints object.
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
MooseMesh & _mesh
A reference to the mesh.
std::unordered_set< dof_id_type > _all_boundary_entity_ids
The set of entities on the boundary of the domain used for determining if features intersect any boun...

◆ numCoupledVars()

std::size_t FeatureFloodCount::numCoupledVars ( ) const
inlineinherited

Returns the number of coupled varaibles.

Definition at line 87 of file FeatureFloodCount.h.

87 { return _n_vars; }
const std::size_t _n_vars

◆ prepareDataForTransfer()

void FeatureFloodCount::prepareDataForTransfer ( )
protectedinherited

This routine uses the local flooded data to build up the local feature data structures (_feature_sets).

This routine does not perform any communication so the _feature_sets data structure will only contain information from the local processor after calling this routine. Any existing data in the _feature_sets structure is destroyed by calling this routine.

_feature_sets layout: The outer vector is sized to one when _single_map_mode == true, otherwise it is sized for the number of coupled variables. The inner list represents the flooded regions (local only after this call but fully populated after parallel communication and stitching).

If using a vector container, we need to sort all of the data structures for later operations such as checking for intersection and merging. The following "sort" function does nothing when invoked on a std::set.

Save off the min entity id present in the feature to uniquely identify the feature regardless of n_procs

Definition at line 982 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::communicateAndMerge().

983 {
984  TIME_SECTION(_prepare_for_transfer);
985 
986  MeshBase & mesh = _mesh.getMesh();
987 
988  FeatureData::container_type local_ids_no_ghost, set_difference;
989 
990  for (auto & list_ref : _partial_feature_sets)
991  {
992  for (auto & feature : list_ref)
993  {
994  // See if the feature intersects a boundary or perhaps one of the percolation boundaries.
996 
997  // Periodic node ids
999 
1005  FeatureFloodCount::sort(feature._ghosted_ids);
1006  FeatureFloodCount::sort(feature._local_ids);
1007  FeatureFloodCount::sort(feature._halo_ids);
1008  FeatureFloodCount::sort(feature._disjoint_halo_ids);
1009  FeatureFloodCount::sort(feature._periodic_nodes);
1010 
1011  // Now extend the bounding box by the halo region
1012  if (_is_elemental)
1013  feature.updateBBoxExtremes(mesh);
1014  else
1015  {
1016  for (auto & halo_id : feature._halo_ids)
1017  updateBBoxExtremesHelper(feature._bboxes[0], mesh.node(halo_id));
1018  }
1019 
1020  mooseAssert(!feature._local_ids.empty(), "local entity ids cannot be empty");
1021 
1026  feature._min_entity_id = *feature._local_ids.begin();
1027  }
1028  }
1029 }
void appendPeriodicNeighborNodes(FeatureData &feature) const
This routine adds the periodic node information to our data structure prior to packing the data this ...
static void sort(std::set< T > &)
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)
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
void updateBoundaryIntersections(FeatureData &feature) const
Update the feature&#39;s attributes to indicate boundary intersections.
const PerfID _prepare_for_transfer
MooseMesh & _mesh
A reference to the mesh.

◆ scatterAndUpdateRanks()

void FeatureFloodCount::scatterAndUpdateRanks ( )
protectedinherited

Calls buildLocalToGlobalIndices to build the individual local to global indicies for each rank and scatters that information to all ranks.

Finally, the non-master ranks update their own data structures to reflect the global mappings.

On non-root processors we can't maintain the full _feature_sets data structure since we don't have all of the global information. We'll move the items from the partial feature sets into a flat structure maintaining order and update the internal IDs with the proper global ID.

Important: Make sure we clear the local status if we received a valid global index for this feature. It's possible that we have a status of INVALID on the local processor because there was never any starting threshold found. However, the root processor wouldn't have sent an index if it didn't find a starting threshold connected to our local piece.

Definition at line 706 of file FeatureFloodCount.C.

Referenced by GrainTracker::assignGrains(), FeatureFloodCount::finalize(), and GrainTracker::trackGrains().

707 {
708  // local to global map (one per processor)
709  std::vector<int> counts;
710  std::vector<std::size_t> local_to_global_all;
711  if (_is_master)
712  buildLocalToGlobalIndices(local_to_global_all, counts);
713 
714  // Scatter local_to_global indices to all processors and store in class member variable
715  _communicator.scatter(local_to_global_all, counts, _local_to_global_feature_map);
716 
717  std::size_t largest_global_index = std::numeric_limits<std::size_t>::lowest();
718  if (!_is_master)
719  {
721 
728  for (auto & list_ref : _partial_feature_sets)
729  {
730  for (auto & feature : list_ref)
731  {
732  mooseAssert(feature._orig_ids.size() == 1, "feature._orig_ids length doesn't make sense");
733 
734  auto global_index = FeatureFloodCount::invalid_size_t;
735  auto local_index = feature._orig_ids.begin()->second;
736 
737  if (local_index < _local_to_global_feature_map.size())
738  global_index = _local_to_global_feature_map[local_index];
739 
740  if (global_index != FeatureFloodCount::invalid_size_t)
741  {
742  if (global_index > largest_global_index)
743  largest_global_index = global_index;
744 
745  // Set the correct global index
746  feature._id = global_index;
747 
755  feature._status &= ~Status::INACTIVE;
756 
757  // Move the feature into the correct place
758  _feature_sets[local_index] = std::move(feature);
759  }
760  }
761  }
762  }
763  else
764  {
765  for (auto global_index : local_to_global_all)
766  if (global_index != FeatureFloodCount::invalid_size_t && global_index > largest_global_index)
767  largest_global_index = global_index;
768  }
769 
770  buildFeatureIdToLocalIndices(largest_global_index);
771 }
static const std::size_t invalid_size_t
Status
This enumeration is used to indicate status of the grains in the _unique_grains data structure...
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
const bool _is_master
Convenience variable for testing master rank.
virtual void buildLocalToGlobalIndices(std::vector< std::size_t > &local_to_global_all, std::vector< int > &counts) const
This routine populates a stacked vector of local to global indices per rank and the associated count ...
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...
void buildFeatureIdToLocalIndices(unsigned int max_id)
This method builds a lookup map for retrieving the right local feature (by index) given a global inde...
std::vector< std::size_t > _local_to_global_feature_map
The vector recording the local to global feature indices.

◆ serialize()

void FeatureFloodCount::serialize ( std::string &  serialized_buffer,
unsigned int  var_num = invalid_id 
)
protectedinherited

This routines packs the _partial_feature_sets data into a structure suitable for parallel communication operations.

Definition at line 1032 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::communicateAndMerge().

1033 {
1034  // stream for serializing the _partial_feature_sets data structure to a byte stream
1035  std::ostringstream oss;
1036 
1037  mooseAssert(var_num == invalid_id || var_num < _partial_feature_sets.size(),
1038  "var_num out of range");
1039 
1040  // Serialize everything
1041  if (var_num == invalid_id)
1042  dataStore(oss, _partial_feature_sets, this);
1043  else
1044  dataStore(oss, _partial_feature_sets[var_num], this);
1045 
1046  // Populate the passed in string pointer with the string stream's buffer contents
1047  serialized_buffer.assign(oss.str());
1048 }
void dataStore(std::ostream &stream, FeatureFloodCount::FeatureData &feature, void *context)
static const unsigned int invalid_id
std::vector< std::list< FeatureData > > _partial_feature_sets
The data structure used to hold partial and communicated feature data, during the discovery and mergi...

◆ setsIntersect()

template<class InputIterator >
static bool FeatureFloodCount::setsIntersect ( InputIterator  first1,
InputIterator  last1,
InputIterator  first2,
InputIterator  last2 
)
inlinestaticprotectedinherited

This method detects whether two sets intersect without building a result set.

It exits as soon as any intersection is detected.

Definition at line 540 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::FeatureData::ghostedIntersect(), FeatureFloodCount::FeatureData::halosIntersect(), and FeatureFloodCount::FeatureData::periodicBoundariesIntersect().

544  {
545  while (first1 != last1 && first2 != last2)
546  {
547  if (*first1 == *first2)
548  return true;
549 
550  if (*first1 < *first2)
551  ++first1;
552  else if (*first1 > *first2)
553  ++first2;
554  }
555  return false;
556  }

◆ sortAndLabel()

void FeatureFloodCount::sortAndLabel ( )
protectedinherited

Sort and assign ids to features based on their position in the container after sorting.

Perform a sort to give a parallel unique sorting to the identified features. We use the "min_entity_id" inside each feature to assign it's position in the sorted vector.

Sanity check. Now that we've sorted the flattened vector of features we need to make sure that the counts vector still lines up appropriately with each feature's _var_index.

Definition at line 563 of file FeatureFloodCount.C.

Referenced by GrainTracker::assignGrains(), and FeatureFloodCount::finalize().

564 {
565  mooseAssert(_is_master, "sortAndLabel can only be called on the master");
566 
572  std::sort(_feature_sets.begin(), _feature_sets.end());
573 
574 #ifndef NDEBUG
575 
580  unsigned int feature_offset = 0;
581  for (MooseIndex(_maps_size) map_num = 0; map_num < _maps_size; ++map_num)
582  {
583  // Skip empty map checks
584  if (_feature_counts_per_map[map_num] == 0)
585  continue;
586 
587  // Check the begin and end of the current range
588  auto range_front = feature_offset;
589  auto range_back = feature_offset + _feature_counts_per_map[map_num] - 1;
590 
591  mooseAssert(range_front <= range_back && range_back < _feature_count,
592  "Indexing error in feature sets");
593 
594  if (!_single_map_mode && (_feature_sets[range_front]._var_index != map_num ||
595  _feature_sets[range_back]._var_index != map_num))
596  mooseError("Error in _feature_sets sorting, map index: ", map_num);
597 
598  feature_offset += _feature_counts_per_map[map_num];
599  }
600 #endif
601 
602  // Label the features with an ID based on the sorting (processor number independent value)
603  for (MooseIndex(_feature_sets) i = 0; i < _feature_sets.size(); ++i)
604  if (_feature_sets[i]._id == invalid_id)
605  _feature_sets[i]._id = i;
606 }
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
const bool _is_master
Convenience variable for testing master rank.
const std::size_t _maps_size
Convenience variable holding the size of all the datastructures size by the number of maps...
static const unsigned int invalid_id
const bool _single_map_mode
This variable is used to indicate whether or not multiple maps are used during flooding.
unsigned int _feature_count
The number of features seen by this object (same as summing _feature_counts_per_map) ...
std::vector< unsigned int > _feature_counts_per_map
The number of features seen by this object per map.

◆ updateBoundaryIntersections()

void FeatureFloodCount::updateBoundaryIntersections ( FeatureData feature) const
protectedinherited

Update the feature's attributes to indicate boundary intersections.

Definition at line 1689 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::prepareDataForTransfer().

1690 {
1691  if (_is_elemental)
1692  {
1693  for (auto entity : feature._local_ids)
1694  {
1695  // See if this feature is on a boundary if we haven't already figured that out
1696  if ((feature._boundary_intersection & BoundaryIntersection::ANY_BOUNDARY) ==
1698  {
1699  Elem * elem = _mesh.elemPtr(entity);
1700  if (elem && elem->on_boundary())
1701  feature._boundary_intersection |= BoundaryIntersection::ANY_BOUNDARY;
1702  }
1703 
1704  // Now see if the feature touches the primary and/or secondary boundary IDs if we haven't
1705  // figured that out already
1706  if ((feature._boundary_intersection & BoundaryIntersection::PRIMARY_PERCOLATION_BOUNDARY) ==
1708  {
1709  for (auto primary_id : _primary_perc_bnds)
1710  if (_mesh.isBoundaryElem(entity, primary_id))
1711  feature._boundary_intersection |= BoundaryIntersection::PRIMARY_PERCOLATION_BOUNDARY;
1712  }
1713 
1714  if ((feature._boundary_intersection & BoundaryIntersection::SECONDARY_PERCOLATION_BOUNDARY) ==
1716  {
1717  for (auto secondary_id : _secondary_perc_bnds)
1718  if (_mesh.isBoundaryElem(entity, secondary_id))
1719  feature._boundary_intersection |= BoundaryIntersection::SECONDARY_PERCOLATION_BOUNDARY;
1720  }
1721  }
1722  }
1723 }
std::vector< BoundaryID > _primary_perc_bnds
std::vector< BoundaryID > _secondary_perc_bnds
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
MooseMesh & _mesh
A reference to the mesh.

◆ updateFieldInfo()

void FeatureFloodCount::updateFieldInfo ( )
protectedvirtualinherited

This method is used to populate any of the data structures used for storing field data (nodal or elemental).

It is called at the end of finalize and can make use of any of the data structures created during the execution of this postprocessor.

Reimplemented in GrainTracker.

Definition at line 1214 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::finalize().

1215 {
1216  for (MooseIndex(_feature_sets) i = 0; i < _feature_sets.size(); ++i)
1217  {
1218  auto & feature = _feature_sets[i];
1219 
1220  // If the developer has requested _condense_map_info we'll make sure we only update the zeroth
1221  // map
1222  auto map_index = (_single_map_mode || _condense_map_info) ? decltype(feature._var_index)(0)
1223  : feature._var_index;
1224 
1225  // Loop over the entity ids of this feature and update our local map
1226  for (auto entity : feature._local_ids)
1227  {
1228  _feature_maps[map_index][entity] = static_cast<int>(feature._id);
1229 
1230  if (_var_index_mode)
1231  _var_index_maps[map_index][entity] = feature._var_index;
1232 
1233  // Fill in the data structure that keeps track of all features per elem
1235  {
1236  auto insert_pair = moose_try_emplace(
1237  _entity_var_to_features, entity, std::vector<unsigned int>(_n_vars, invalid_id));
1238  auto & vec_ref = insert_pair.first->second;
1239  vec_ref[feature._var_index] = feature._id;
1240  }
1241  }
1242 
1243  if (_compute_halo_maps)
1244  // Loop over the halo ids to update cells with halo information
1245  for (auto entity : feature._halo_ids)
1246  _halo_ids[map_index][entity] = static_cast<int>(feature._id);
1247 
1248  // Loop over the ghosted ids to update cells with ghost information
1249  for (auto entity : feature._ghosted_ids)
1250  _ghosted_entity_ids[entity] = 1;
1251 
1252  // TODO: Fixme
1253  if (!_global_numbering)
1254  mooseError("Local numbering currently disabled");
1255  }
1256 }
const std::size_t _n_vars
const bool _condense_map_info
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
std::map< dof_id_type, int > _ghosted_entity_ids
The map for holding reconstructed ghosted element information.
std::vector< std::map< dof_id_type, int > > _halo_ids
The data structure for looking up halos around features.
const bool _global_numbering
This variable is used to indicate whether or not we identify features with unique numbers on multiple...
static const unsigned int invalid_id
std::vector< std::map< dof_id_type, int > > _feature_maps
The feature maps contain the raw flooded node information and eventually the unique grain numbers...
const bool _single_map_mode
This variable is used to indicate whether or not multiple maps are used during flooding.
const bool _compute_halo_maps
Indicates whether or not to communicate halo map information with all ranks.
const bool _compute_var_to_feature_map
Indicates whether or not the var to feature map is populated.
const bool _var_index_mode
This variable is used to indicate whether the maps will contain unique region information or just the...
std::vector< std::map< dof_id_type, int > > _var_index_maps
This map keeps track of which variables own which nodes.

◆ updateRegionOffsets()

void FeatureFloodCount::updateRegionOffsets ( )
protectedinherited

This routine updates the _region_offsets variable which is useful for quickly determining the proper global number for a feature when using multimap mode.

◆ visitElementalNeighbors()

void FeatureFloodCount::visitElementalNeighbors ( const Elem *  elem,
FeatureData feature,
bool  expand_halos_only,
bool  disjoint_only 
)
protectedinherited

Retrieve only the active neighbors for each side of this element, append them to the list of active neighbors

If the current element (passed into this method) doesn't have a connected neighbor but does have a topological neighbor, this might be a new disjoint region that we'll need to represent with a separate bounding box. To find out for sure, we'll need see if the new neighbors are present in any of the halo or disjoint halo sets. If they are not present, this is a new region.

This neighbor is NULL which means we need to expand the bounding box here in case this grain is up against multiple domain edges so we don't end up with a degenerate bounding box.

Definition at line 1549 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::expandEdgeHalos(), and FeatureFloodCount::flood().

1553 {
1554  mooseAssert(elem, "Elem is NULL");
1555 
1556  std::vector<const Elem *> all_active_neighbors;
1557  MeshBase & mesh = _mesh.getMesh();
1558 
1559  // Loop over all neighbors (at the the same level as the current element)
1560  for (MooseIndex(elem->n_neighbors()) i = 0; i < elem->n_neighbors(); ++i)
1561  {
1562  const Elem * neighbor_ancestor = nullptr;
1563  bool topological_neighbor = false;
1564 
1569  neighbor_ancestor = elem->neighbor_ptr(i);
1570  if (neighbor_ancestor)
1571  {
1572  if (neighbor_ancestor == libMesh::remote_elem)
1573  continue;
1574 
1575  neighbor_ancestor->active_family_tree_by_neighbor(all_active_neighbors, elem, false);
1576  }
1577  else
1578  {
1579  neighbor_ancestor = elem->topological_neighbor(i, mesh, *_point_locator, _pbs);
1580 
1588  if (neighbor_ancestor)
1589  {
1590  neighbor_ancestor->active_family_tree_by_topological_neighbor(
1591  all_active_neighbors, elem, mesh, *_point_locator, _pbs, false);
1592 
1593  topological_neighbor = true;
1594  }
1595  else
1596  {
1602  updateBBoxExtremesHelper(feature->_bboxes[0], *elem);
1603  }
1604  }
1605 
1606  visitNeighborsHelper(elem,
1607  all_active_neighbors,
1608  feature,
1609  expand_halos_only,
1610  topological_neighbor,
1611  disjoint_only);
1612 
1613  all_active_neighbors.clear();
1614  }
1615 }
void updateBBoxExtremesHelper(MeshTools::BoundingBox &bbox, const Point &node)
std::unique_ptr< PointLocatorBase > _point_locator
PeriodicBoundaries * _pbs
A pointer to the periodic boundary constraints object.
void visitNeighborsHelper(const T *curr_entity, std::vector< const T *> neighbor_entities, FeatureData *feature, bool expand_halos_only, bool topological_neighbor, bool disjoint_only)
The actual logic for visiting neighbors is abstracted out here.
MooseMesh & _mesh
A reference to the mesh.

◆ visitNeighborsHelper()

template<typename T >
void FeatureFloodCount::visitNeighborsHelper ( const T *  curr_entity,
std::vector< const T *>  neighbor_entities,
FeatureData feature,
bool  expand_halos_only,
bool  topological_neighbor,
bool  disjoint_only 
)
protectedinherited

The actual logic for visiting neighbors is abstracted out here.

This method is templated to handle the Nodal and Elemental cases together.

Only recurse where we own this entity and it's a topologically connected entity. We shouldn't even attempt to flood to the periodic boundary because we won't have solution information and if we are using DistributedMesh we probably won't have geometric information either.

When we only recurse on entities we own, we can never get more than one away from a local entity which should be in the ghosted zone.

Premark neighboring entities with a halo mark. These entities may or may not end up being part of the feature. We will not update the _entities_visited data structure here.

Definition at line 1632 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::visitElementalNeighbors(), and FeatureFloodCount::visitNodalNeighbors().

1638 {
1639  // Loop over all active element neighbors
1640  for (const auto neighbor : neighbor_entities)
1641  {
1642  if (neighbor && (!_is_boundary_restricted || isBoundaryEntity(neighbor)))
1643  {
1644  if (expand_halos_only)
1645  {
1646  auto entity_id = neighbor->id();
1647 
1648  if (topological_neighbor || disjoint_only)
1649  feature->_disjoint_halo_ids.insert(feature->_disjoint_halo_ids.end(), entity_id);
1650  else if (feature->_local_ids.find(entity_id) == feature->_local_ids.end())
1651  feature->_halo_ids.insert(feature->_halo_ids.end(), entity_id);
1652  }
1653  else
1654  {
1655  auto my_processor_id = processor_id();
1656 
1657  if (!topological_neighbor && neighbor->processor_id() != my_processor_id)
1658  feature->_ghosted_ids.insert(feature->_ghosted_ids.end(), curr_entity->id());
1659 
1669  if (curr_entity->processor_id() == my_processor_id ||
1670  neighbor->processor_id() == my_processor_id)
1671  {
1678  if (topological_neighbor || disjoint_only)
1679  feature->_disjoint_halo_ids.insert(feature->_disjoint_halo_ids.end(), neighbor->id());
1680  else
1681  _entity_queue.push_front(neighbor);
1682  }
1683  }
1684  }
1685  }
1686 }
bool isBoundaryEntity(const T *entity) const
Returns a Boolean indicating whether the entity is on one of the desired boundaries.
bool _is_boundary_restricted
Indicates that this object should only run on one or more boundaries.
std::deque< const DofObject * > _entity_queue
The data structure for maintaining entities to flood during discovery.

◆ visitNodalNeighbors()

void FeatureFloodCount::visitNodalNeighbors ( const Node *  node,
FeatureData feature,
bool  expand_halos_only 
)
protectedinherited

These two routines are utility routines used by the flood routine and by derived classes for visiting neighbors.

Since the logic is different for the elemental versus nodal case it's easier to split them up.

Definition at line 1618 of file FeatureFloodCount.C.

Referenced by FeatureFloodCount::expandEdgeHalos(), and FeatureFloodCount::flood().

1621 {
1622  mooseAssert(node, "Node is NULL");
1623 
1624  std::vector<const Node *> all_active_neighbors;
1625  MeshTools::find_nodal_neighbors(_mesh.getMesh(), *node, _nodes_to_elem_map, all_active_neighbors);
1626 
1627  visitNeighborsHelper(node, all_active_neighbors, feature, expand_halos_only, false, false);
1628 }
std::vector< std::vector< const Elem * > > _nodes_to_elem_map
The data structure used to find neighboring elements give a node ID.
void visitNeighborsHelper(const T *curr_entity, std::vector< const T *> neighbor_entities, FeatureData *feature, bool expand_halos_only, bool topological_neighbor, bool disjoint_only)
The actual logic for visiting neighbors is abstracted out here.
MooseMesh & _mesh
A reference to the mesh.

Member Data Documentation

◆ _all_boundary_entity_ids

std::unordered_set<dof_id_type> FeatureFloodCount::_all_boundary_entity_ids
protectedinherited

The set of entities on the boundary of the domain used for determining if features intersect any boundary.

Definition at line 709 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::meshChanged().

◆ _bnd_elem_range

ConstBndElemRange* FeatureFloodCount::_bnd_elem_range
protectedinherited

Boundary element range pointer.

Definition at line 725 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::execute(), and FeatureFloodCount::isBoundaryEntity().

◆ _centroid

std::map<unsigned int, Point> FauxGrainTracker::_centroid
private

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

Definition at line 79 of file FauxGrainTracker.h.

Referenced by execute(), finalize(), getEntityValue(), getGrainCentroid(), and initialize().

◆ _compute_halo_maps

const bool FeatureFloodCount::_compute_halo_maps
protectedinherited

Indicates whether or not to communicate halo map information with all ranks.

Definition at line 602 of file FeatureFloodCount.h.

Referenced by GrainTracker::communicateHaloMap(), GrainTracker::meshChanged(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _compute_var_to_feature_map

const bool FeatureFloodCount::_compute_var_to_feature_map
protectedinherited

Indicates whether or not the var to feature map is populated.

Definition at line 605 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::getVarToFeatureVector(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _condense_map_info

const bool FeatureFloodCount::_condense_map_info
protectedinherited

◆ _connecting_threshold

const Real FeatureFloodCount::_connecting_threshold
protectedinherited

The threshold above (or below) which neighboring entities are flooded (where regions can be extended but not started)

Definition at line 575 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::initialize().

◆ _dof_map

const DofMap& FeatureFloodCount::_dof_map
protectedinherited

Reference to the dof_map containing the coupled variables.

Definition at line 567 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::flood().

◆ _element_average_value

const PostprocessorValue& FeatureFloodCount::_element_average_value
protectedinherited

Average value of the domain which can optionally be used to find features in a field.

Definition at line 690 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::initialize().

◆ _empty_var_to_features

std::vector<unsigned int> FauxGrainTracker::_empty_var_to_features
private

Definition at line 55 of file FauxGrainTracker.h.

Referenced by FauxGrainTracker(), and getVarToFeatureVector().

◆ _entities_visited

std::vector<std::set<dof_id_type> > FeatureFloodCount::_entities_visited
protectedinherited

This variable keeps track of which nodes have been visited during execution.

We don't use the _feature_map for this since we don't want to explicitly store data for all the unmarked nodes in a serialized datastructures. This keeps our overhead down since this variable never needs to be communicated.

Definition at line 629 of file FeatureFloodCount.h.

Referenced by PolycrystalUserObjectBase::execute(), FeatureFloodCount::flood(), FeatureFloodCount::initialize(), FeatureFloodCount::initialSetup(), and PolycrystalUserObjectBase::isNewFeatureOrConnectedRegion().

◆ _entity_id_to_var_num

std::map<dof_id_type, unsigned int> FauxGrainTracker::_entity_id_to_var_num
private

The mapping of entities to grains, in this case always the order parameter.

Definition at line 52 of file FauxGrainTracker.h.

Referenced by execute(), finalize(), getEntityValue(), and initialize().

◆ _entity_var_to_features

std::map<dof_id_type, std::vector<unsigned int> > FauxGrainTracker::_entity_var_to_features
private

Definition at line 54 of file FauxGrainTracker.h.

Referenced by execute(), getVarToFeatureVector(), and initialize().

◆ _fe_vars

std::vector<MooseVariableFEBase *> FeatureFloodCount::_fe_vars
protectedinherited

The vector of coupled in variables.

Definition at line 562 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::FeatureFloodCount(), and FeatureFloodCount::getFECoupledVars().

◆ _feature_count

unsigned int FeatureFloodCount::_feature_count
protectedinherited

◆ _feature_counts_per_map

std::vector<unsigned int> FeatureFloodCount::_feature_counts_per_map
protectedinherited

The number of features seen by this object per map.

Definition at line 643 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::consolidateMergedFeatures(), FeatureFloodCount::sortAndLabel(), and GrainTracker::trackGrains().

◆ _feature_id_to_local_index

std::vector<std::size_t> FeatureFloodCount::_feature_id_to_local_index
protectedinherited

◆ _feature_maps

std::vector<std::map<dof_id_type, int> > FeatureFloodCount::_feature_maps
protectedinherited

The feature maps contain the raw flooded node information and eventually the unique grain numbers.

We have a vector of them so we can create one per variable if that level of detail is desired.

Definition at line 676 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::getEntityValue(), FeatureFloodCount::initialize(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _feature_sets

std::vector<FeatureData>& FeatureFloodCount::_feature_sets
protectedinherited

◆ _ghosted_entity_ids

std::map<dof_id_type, int> FeatureFloodCount::_ghosted_entity_ids
protectedinherited

The map for holding reconstructed ghosted element information.

Definition at line 693 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::getEntityValue(), FeatureFloodCount::initialize(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _global_numbering

const bool FeatureFloodCount::_global_numbering
protectedinherited

This variable is used to indicate whether or not we identify features with unique numbers on multiple maps.

Definition at line 595 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::updateFieldInfo().

◆ _grain_count

std::size_t FauxGrainTracker::_grain_count
private

Total Grain Count.

Definition at line 61 of file FauxGrainTracker.h.

Referenced by execute(), and getTotalFeatureCount().

◆ _halo_ids

std::vector<std::map<dof_id_type, int> > FeatureFloodCount::_halo_ids
protectedinherited

The data structure for looking up halos around features.

The outer vector is for splitting out the information per variable. The inner map holds the actual halo information

Definition at line 699 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::FeatureData::clear(), GrainTracker::communicateHaloMap(), FeatureFloodCount::getEntityValue(), FeatureFloodCount::FeatureData::halosIntersect(), FeatureFloodCount::initialize(), FeatureFloodCount::FeatureData::merge(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _is_boundary_restricted

bool FeatureFloodCount::_is_boundary_restricted
protectedinherited

Indicates that this object should only run on one or more boundaries.

Definition at line 722 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::execute(), FeatureFloodCount::FeatureFloodCount(), and FeatureFloodCount::visitNeighborsHelper().

◆ _is_elemental

const bool FeatureFloodCount::_is_elemental
protectedinherited

◆ _is_master

const bool FeatureFloodCount::_is_master
protectedinherited

◆ _local_to_global_feature_map

std::vector<std::size_t> FeatureFloodCount::_local_to_global_feature_map
protectedinherited

The vector recording the local to global feature indices.

Definition at line 679 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::scatterAndUpdateRanks().

◆ _maps_size

const std::size_t FeatureFloodCount::_maps_size
protectedinherited

◆ _mesh

MooseMesh& FeatureFloodCount::_mesh
protectedinherited

◆ _n_procs

const processor_id_type FeatureFloodCount::_n_procs
protectedinherited

Convenience variable holding the number of processors in this simulation.

Definition at line 621 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::buildLocalToGlobalIndices(), and GrainTracker::communicateHaloMap().

◆ _n_vars

const std::size_t FauxGrainTracker::_n_vars
private

◆ _nodes_to_elem_map

std::vector<std::vector<const Elem *> > FeatureFloodCount::_nodes_to_elem_map
protectedinherited

The data structure used to find neighboring elements give a node ID.

Definition at line 640 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::meshChanged(), and FeatureFloodCount::visitNodalNeighbors().

◆ _op_to_grains

std::vector<unsigned int> FauxGrainTracker::_op_to_grains
private

Order parameter to grain indices (just a reflexive vector)

Definition at line 70 of file FauxGrainTracker.h.

Referenced by FauxGrainTracker().

◆ _partial_feature_sets

std::vector<std::list<FeatureData> > FeatureFloodCount::_partial_feature_sets
protectedinherited

The data structure used to hold partial and communicated feature data, during the discovery and merging phases.

The outer vector is indexed by map number (often variable number). The inner list is an unordered list of partially discovered features.

Definition at line 653 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::communicateAndMerge(), FeatureFloodCount::consolidateMergedFeatures(), FeatureFloodCount::deserialize(), FeatureFloodCount::expandEdgeHalos(), FeatureFloodCount::expandPointHalos(), FeatureFloodCount::flood(), FeatureFloodCount::initialize(), PolycrystalUserObjectBase::mergeSets(), FeatureFloodCount::mergeSets(), FeatureFloodCount::prepareDataForTransfer(), GrainTracker::prepopulateState(), FeatureFloodCount::scatterAndUpdateRanks(), and FeatureFloodCount::serialize().

◆ _pbs

PeriodicBoundaries* FeatureFloodCount::_pbs
protectedinherited

◆ _periodic_node_map

std::multimap<dof_id_type, dof_id_type> FeatureFloodCount::_periodic_node_map
protectedinherited

The data structure which is a list of nodes that are constrained to other nodes based on the imposed periodic boundary conditions.

Definition at line 705 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::appendPeriodicNeighborNodes(), getEntityValue(), FeatureFloodCount::getEntityValue(), and FeatureFloodCount::meshChanged().

◆ _point_locator

std::unique_ptr<PointLocatorBase> FeatureFloodCount::_point_locator
protectedinherited

◆ _primary_perc_bnds

std::vector<BoundaryID> FeatureFloodCount::_primary_perc_bnds
protectedinherited

◆ _secondary_perc_bnds

std::vector<BoundaryID> FeatureFloodCount::_secondary_perc_bnds
protectedinherited

◆ _single_map_mode

const bool FeatureFloodCount::_single_map_mode
protectedinherited

This variable is used to indicate whether or not multiple maps are used during flooding.

Definition at line 589 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::flood(), PolycrystalUserObjectBase::PolycrystalUserObjectBase(), FeatureFloodCount::sortAndLabel(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _step_connecting_threshold

Real FeatureFloodCount::_step_connecting_threshold
protectedinherited

◆ _step_threshold

Real FeatureFloodCount::_step_threshold
protectedinherited

◆ _threshold

const Real FeatureFloodCount::_threshold
protectedinherited

The threshold above (or below) where an entity may begin a new region (feature)

Definition at line 570 of file FeatureFloodCount.h.

Referenced by execute(), and FeatureFloodCount::initialize().

◆ _tracking_step

const int FauxGrainTracker::_tracking_step
private

Used to emulate the tracking step of the real grain tracker object.

Definition at line 67 of file FauxGrainTracker.h.

◆ _use_less_than_threshold_comparison

const bool FeatureFloodCount::_use_less_than_threshold_comparison
protectedinherited

Use less-than when comparing values against the threshold value.

True by default. If false, then greater-than comparison is used instead.

Definition at line 612 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::compareValueWithThreshold(), and execute().

◆ _var_index_maps

std::vector<std::map<dof_id_type, int> > FeatureFloodCount::_var_index_maps
protectedinherited

This map keeps track of which variables own which nodes.

We need a vector of them for multimap mode where multiple variables can own a single mode.

Note: This map is only populated when "show_var_coloring" is set to true.

Definition at line 637 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::FeatureFloodCount(), FeatureFloodCount::getEntityValue(), FeatureFloodCount::initialize(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _var_index_mode

const bool FeatureFloodCount::_var_index_mode
protectedinherited

This variable is used to indicate whether the maps will contain unique region information or just the variable numbers owning those regions.

Definition at line 599 of file FeatureFloodCount.h.

Referenced by FeatureFloodCount::FeatureFloodCount(), FeatureFloodCount::getEntityValue(), FeatureFloodCount::initialize(), GrainTracker::updateFieldInfo(), and FeatureFloodCount::updateFieldInfo().

◆ _var_number

unsigned long FeatureFloodCount::_var_number
protectedinherited

This variable is used to build the periodic node map.

Assumption: We are going to assume that either all variables are periodic or none are. This assumption can be relaxed at a later time if necessary.

Definition at line 586 of file FeatureFloodCount.h.

Referenced by GrainTracker::centroidRegionDistance(), and FeatureFloodCount::meshChanged().

◆ _variables_used

std::set<unsigned int> FauxGrainTracker::_variables_used
private

Used as the lightweight grain counter.

Definition at line 58 of file FauxGrainTracker.h.

Referenced by execute(), finalize(), getNumberActiveGrains(), getValue(), and initialize().

◆ _vars

std::vector<MooseVariable *> FeatureFloodCount::_vars
protectedinherited

◆ _vol_count

std::map<unsigned int, unsigned int> FauxGrainTracker::_vol_count
private

The count of entities contributing to the volume calculation.

Definition at line 76 of file FauxGrainTracker.h.

Referenced by execute(), finalize(), and initialize().

◆ _volatile_feature_sets

std::vector<FeatureData> FeatureFloodCount::_volatile_feature_sets
protectedinherited

Derived objects (e.g.

the GrainTracker) may require restartable data to track information across time steps. The FeatureFloodCounter however does not. This container is here so that we have the flexabilty to switch between volatile and non-volatile storage. The _feature_sets data structure can conditionally refer to this structure or a MOOSE-provided structure, which is backed up.

Definition at line 669 of file FeatureFloodCount.h.

◆ _volume

std::map<unsigned int, Real> FauxGrainTracker::_volume
private

The volume of the feature.

Definition at line 73 of file FauxGrainTracker.h.

Referenced by execute(), finalize(), and initialize().

◆ invalid_id

const unsigned int FeatureFloodCount::invalid_id = std::numeric_limits<unsigned int>::max()
staticinherited

◆ invalid_size_t

const std::size_t FeatureFloodCount::invalid_size_t = std::numeric_limits<std::size_t>::max()
staticinherited

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