23 #include "libmesh/bounding_box.h" 24 #include "libmesh/periodic_boundaries.h" 27 #include "boost/bitmask_operators.h" 53 virtual void execute()
override;
84 virtual unsigned int getFeatureVar(
unsigned int feature_id)
const;
155 unsigned int local_index,
160 _orig_ids = {std::make_pair(rank, local_index)};
166 std::vector<BoundingBox> bboxes = {BoundingBox()})
233 void mergeBBoxes(std::vector<BoundingBox> & bboxes,
bool physical_intersection);
254 mooseAssert(rhs.
_id !=
invalid_id,
"Asymmetric setting of ids detected during sort");
295 std::list<std::pair<processor_id_type, unsigned int>>
_orig_ids;
334 template <
typename T>
351 bool flood(
const DofObject * dof_object, std::size_t current_index);
378 std::size_t & current_index,
379 FeatureData *& feature,
381 unsigned int & new_id);
403 void visitNodalNeighbors(
const Node * node, FeatureData * feature,
bool expand_halos_only);
405 FeatureData * feature,
406 bool expand_halos_only,
415 template <
typename T>
417 std::vector<const T *> neighbor_entities,
418 FeatureData * feature,
419 bool expand_halos_only,
420 bool topological_neighbor,
450 void deserialize(std::vector<std::string> & serialized_buffers,
511 std::vector<int> & counts)
const;
720 static inline void sort(std::set<T> & )
726 static inline void sort(std::vector<T> & container)
728 std::sort(container.begin(), container.end());
732 static inline void reserve(std::set<T> & , std::size_t )
738 static inline void reserve(std::vector<T> & container, std::size_t size)
740 container.reserve(size);
744 static inline bool contains(std::set<T> & container,
const T & item)
746 return container.find(item) != container.end();
750 static inline bool contains(std::vector<T> & container,
const T & item)
752 for (
const auto & cont_item : container)
753 if (item == cont_item)
765 void dataStore(std::ostream & stream, BoundingBox & bbox,
void * context);
770 void dataLoad(std::istream & stream, BoundingBox & bbox,
void * context);
775 static const bool enable =
true;
781 static const bool enable =
true;
FeatureFloodCount(const InputParameters ¶meters)
std::vector< BoundaryID > _primary_perc_bnds
FeatureData(std::size_t var_index, Status status, unsigned int id=invalid_id, std::vector< BoundingBox > bboxes={BoundingBox()})
Point _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
std::size_t getNumberActiveFeatures() const
Return the number of active features.
bool halosIntersect(const FeatureData &rhs) const
Determine if one of this FeaturesData's member sets intersects the other FeatureData's corresponding ...
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 ...
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::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
const PostprocessorValue & _element_average_value
Average value of the domain which can optionally be used to find features in a field.
void expandEdgeHalos(unsigned int num_layers_to_expand)
This method expands the existing halo set by some width determined by the passed in value...
std::vector< BoundaryID > _specified_bnds
std::vector< BoundaryID > _secondary_perc_bnds
void expandPointHalos()
This method takes all of the partial features and expands the local, ghosted, and halo sets around th...
container_type _halo_ids
Holds the ids surrounding the feature.
const std::size_t _n_vars
static const std::size_t invalid_size_t
virtual void updateFieldInfo()
This method is used to populate any of the data structures used for storing field data (nodal or elem...
static InputParameters validParams()
std::vector< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
static bool contains(std::vector< T > &container, const T &item)
void appendPeriodicNeighborNodes(FeatureData &feature) const
This routine adds the periodic node information to our data structure prior to packing the data this ...
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const
Returns a list of active unique feature ids for a particular element.
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...
Real _step_connecting_threshold
const bool _condense_map_info
const std::vector< MooseVariable * > & getCoupledVars() const
Returns a const vector to the coupled variable pointers.
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
StoredRange< MooseMesh::const_bnd_elem_iterator, const BndElement *> ConstBndElemRange
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 updateBBoxExtremes(MeshBase &mesh)
Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter...
friend std::ostream & operator<<(std::ostream &out, const FeatureData &feature)
stream output operator
bool mergeable(const FeatureData &rhs) const
The routine called to see if two features are mergeable:
bool boundingBoxesIntersect(const FeatureData &rhs) const
Determines if any of this FeatureData's bounding boxes overlap with the other FeatureData's bounding ...
static void sort(std::set< T > &)
virtual void finalize() override
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
std::vector< FeatureData > & _feature_sets
The data structure used to hold the globally unique features.
bool isBoundaryEntity(const T *entity) const
Returns a Boolean indicating whether the entity is on one of the desired boundaries.
const bool _is_primary
Convenience variable for testing primary rank.
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
virtual std::size_t getTotalFeatureCount() const
Returns the total feature count (active and inactive ids, useful for sizing vectors) ...
void communicateAndMerge()
This routine handles all of the serialization, communication and deserialization of the data structur...
virtual void initialize() override
const std::vector< FeatureData > & getFeatures() const
Return a constant reference to the vector of all discovered features.
FeatureData duplicate() const
bool operator<(const FeatureData &rhs) const
Comparison operator for sorting individual FeatureDatas.
virtual bool areFeaturesMergeable(const FeatureData &f1, const FeatureData &f2) const
Method for determining whether two features are mergeable.
std::map< dof_id_type, int > _ghosted_entity_ids
The map for holding reconstructed ghosted element information.
auto max(const L &left, const R &right)
virtual bool isFeaturePercolated(unsigned int feature_id) const
Returns a Boolean indicating whether this feature is percolated (e.g.
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< FeatureData > _volatile_feature_sets
Derived objects (e.g.
void sortAndLabel()
Sort and assign ids to features based on their position in the container after sorting.
virtual 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...
uint8_t processor_id_type
static bool contains(std::set< T > &container, const T &item)
virtual unsigned int getFeatureVar(unsigned int feature_id) const
Returns the variable representing the passed in feature.
dof_id_type _min_entity_id
The minimum entity seen in the _local_ids, used for sorting features.
std::vector< std::map< dof_id_type, int > > _halo_ids
The data structure for looking up halos around features.
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
const Real _connecting_threshold
The threshold above (or below) which neighboring entities are flooded (where regions can be extended ...
virtual void execute() override
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
virtual void clearDataStructures()
Helper routine for clearing up data structures during initialize and prior to parallel communication...
BoundaryIntersection
This enumeration is used to inidacate status of boundary intersections.
unsigned long _var_number
This variable is used to build the periodic node map.
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
virtual processor_id_type numberOfDistributedMergeHelpers() const
Returns a number indicating the number of merge helpers when running in parallel based on certain imp...
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.
void visitElementalNeighbors(const Elem *elem, FeatureData *feature, bool expand_halos_only, bool disjoint_only)
const std::size_t _maps_size
Convenience variable holding the size of all the datastructures size by the number of maps...
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.
bool ghostedIntersect(const FeatureData &rhs) const
const bool _global_numbering
This variable is used to indicate whether or not we identify features with unique numbers on multiple...
std::size_t numCoupledVars() const
Returns the number of coupled varaibles.
const DofMap & _dof_map
Reference to the dof_map containing the coupled variables.
static const unsigned int invalid_id
void updateRegionOffsets()
This routine updates the _region_offsets variable which is useful for quickly determining the proper ...
FeatureData(std::size_t var_index, unsigned int local_index, processor_id_type rank, Status status)
bool canConsolidate(const FeatureData &rhs) const
This routine indicates whether two features can be consolidated, that is, one feature is reasonably e...
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...
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 _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 Real getValue() const override
static void reserve(std::vector< T > &container, std::size_t size)
virtual bool doesFeatureIntersectSpecifiedBoundary(unsigned int feature_id) const
Returns a Boolean indicating whether this feature intersects boundaries in a user-supplied list...
const Real _threshold
The threshold above (or below) where an entity may begin a new region (feature)
void consolidate(FeatureData &&rhs)
Consolidates features, i.e.
std::unique_ptr< PointLocatorBase > _point_locator
virtual void mergeSets()
This routine is called on the primary rank only and stitches together the partial feature pieces seen...
bool _is_boundary_restricted
Indicates that this object should only run on one or more boundaries.
std::vector< MooseVariableFEBase * > _fe_vars
The vector of coupled in variables.
virtual bool isNewFeatureOrConnectedRegion(const DofObject *dof_object, std::size_t ¤t_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...
static void reserve(std::set< T > &, std::size_t)
void merge(FeatureData &&rhs)
Merges another Feature Data into this one.
virtual void restoreOriginalDataStructures(std::vector< std::list< FeatureData >> &)
const bool _compute_halo_maps
Indicates whether or not to communicate halo map information with all ranks.
PeriodicBoundaries * _pbs
A pointer to the periodic boundary constraints object.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unordered_map< dof_id_type, std::vector< const Elem * > > _nodes_to_elem_map
The data structure used to find neighboring elements give a node ID.
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::vector< unsigned int > _empty_var_to_features
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.
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...
container_type _local_ids
Holds the local ids in the interior of a feature.
static void sort(std::vector< T > &container)
const processor_id_type _n_procs
Convenience variable holding the number of processors in this simulation.
FeatureData & operator=(FeatureData &&)=default
void updateBoundaryIntersections(FeatureData &feature) const
Update the feature's attributes to indicate boundary intersections.
void dataStore(std::ostream &stream, FeatureFloodCount::FeatureData &feature, void *context)
virtual void meshChanged() override
std::vector< unsigned int > _feature_counts_per_map
The number of features seen by this object per map.
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) ...
ConstBndElemRange * _bnd_elem_range
Boundary element range pointer.
static const processor_id_type invalid_proc_id
const InputParameters & parameters() const
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.
virtual void initialSetup() override
BoundaryIntersection _boundary_intersection
Enumeration indicating boundary intersection status.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
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...
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 mergeBBoxes(std::vector< BoundingBox > &bboxes, bool physical_intersection)
Located the overlapping bounding box between this Feature and the other Feature and expands that over...
MooseMesh & _mesh
A reference to the mesh.
void dataLoad(std::istream &stream, FeatureFloodCount::FeatureData &feature, void *context)
virtual Real getEntityValue(dof_id_type entity_id, FieldType field_type, std::size_t var_index=0) const
void buildFeatureIdToLocalIndices(unsigned int max_id)
This method builds a lookup map for retrieving the right local feature (by index) given a global inde...
void scatterAndUpdateRanks()
Calls buildLocalToGlobalIndices to build the individual local to global indicies for each rank and sc...
virtual bool doesFeatureIntersectBoundary(unsigned int feature_id) const
Returns a Boolean indicating whether this feature intersects any boundary.
std::deque< const DofObject * > _entity_queue
The data structure for maintaining entities to flood during discovery.
bool periodicBoundariesIntersect(const FeatureData &rhs) const
const std::vector< MooseVariableFEBase * > & getFECoupledVars() const
Returns a const vector to the coupled MooseVariableFEBase pointers.
const bool _compute_var_to_feature_map
Indicates whether or not the var to feature map is populated.
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...
const bool _var_index_mode
This variable is used to indicate whether the maps will contain unique region information or just the...
std::size_t _vol_count
The count of entities contributing to the volume calculation.
unsigned int _id
An ID for this feature.
std::vector< std::map< dof_id_type, int > > _var_index_maps
This map keeps track of which variables own which nodes.
virtual Point featureCentroid(unsigned int feature_id) const
Returns the centroid of the designated feature (only supported without periodic boundaries) ...
virtual Real getThreshold(std::size_t current_index) const
Return the starting comparison threshold to use when inspecting an entity during the flood stage...
std::vector< std::size_t > _local_to_global_feature_map
The vector recording the local to global feature indices.
virtual void prepareDataForTransfer()
This routine uses the local flooded data to build up the local feature data structures (_partial feat...