Go to the documentation of this file.
12 #include "Coupleable.h"
13 #include "GeneralPostprocessor.h"
14 #include "InfixIterator.h"
15 #include "MooseVariableDependencyInterface.h"
16 #include "BoundaryRestrictable.h"
23 #include "libmesh/bounding_box.h"
24 #include "libmesh/periodic_boundaries.h"
27 #include "bitmask_operators.h"
46 public MooseVariableDependencyInterface,
47 public BoundaryRestrictable
55 virtual void execute()
override;
86 virtual unsigned int getFeatureVar(
unsigned int feature_id)
const;
154 unsigned int local_index,
155 processor_id_type rank,
159 _orig_ids = {std::make_pair(rank, local_index)};
165 std::vector<BoundingBox> bboxes = {BoundingBox()})
253 mooseAssert(rhs.
_id !=
invalid_id,
"Asymmetric setting of ids detected during sort");
294 std::list<std::pair<processor_id_type, unsigned int>>
_orig_ids;
314 #ifndef __INTEL_COMPILER
346 template <
typename T>
363 bool flood(
const DofObject * dof_object, std::size_t current_index);
369 virtual Real
getThreshold(std::size_t current_index)
const;
390 std::size_t & current_index,
391 FeatureData *& feature,
393 unsigned int & new_id);
415 void visitNodalNeighbors(
const Node * node, FeatureData * feature,
bool expand_halos_only);
417 FeatureData * feature,
418 bool expand_halos_only,
427 template <
typename T>
429 std::vector<const T *> neighbor_entities,
430 FeatureData * feature,
431 bool expand_halos_only,
432 bool topological_neighbor,
461 void deserialize(std::vector<std::string> & serialized_buffers,
505 std::vector<int> & counts)
const;
542 template <
class InputIterator>
545 InputIterator first2,
548 while (first1 != last1 && first2 != last2)
550 if (*first1 == *first2)
553 if (*first1 < *first2)
555 else if (*first1 > *first2)
565 std::vector<MooseVariableFEBase *>
_fe_vars;
567 std::vector<MooseVariable *>
_vars;
688 PeriodicBoundaries *
_pbs;
702 std::vector<std::map<dof_id_type, int>>
_halo_ids;
737 static inline void sort(std::set<T> & )
743 static inline void sort(std::vector<T> & container)
745 std::sort(container.begin(), container.end());
749 static inline void reserve(std::set<T> & , std::size_t )
755 static inline void reserve(std::vector<T> & container, std::size_t size)
757 container.reserve(size);
786 void dataStore(std::ostream & stream, BoundingBox & bbox,
void * context);
791 void dataLoad(std::istream & stream, BoundingBox & bbox,
void * context);
796 static const bool enable =
true;
802 static const bool enable =
true;
void consolidate(FeatureData &&rhs)
Consolidates features, i.e.
void expandEdgeHalos(unsigned int num_layers_to_expand)
This method expands the existing halo set by some width determined by the passed in value.
const bool _var_index_mode
This variable is used to indicate whether the maps will contain unique region information or just the...
const bool _condense_map_info
InputParameters validParams< FeatureFloodCount >()
std::vector< BoundaryID > _secondary_perc_bnds
static const std::size_t invalid_size_t
void scatterAndUpdateRanks()
Calls buildLocalToGlobalIndices to build the individual local to global indicies for each rank and sc...
MooseMesh & _mesh
A reference to the mesh.
unsigned int _id
An ID for this feature.
void prepareDataForTransfer()
This routine uses the local flooded data to build up the local feature data structures (_feature_sets...
virtual Real getEntityValue(dof_id_type entity_id, FieldType field_type, std::size_t var_index=0) const
FeatureFloodCount(const InputParameters ¶meters)
virtual bool doesFeatureIntersectBoundary(unsigned int feature_id) const
Returns a Boolean indicating whether this feature intersects any boundary.
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.
container_type _disjoint_halo_ids
Holds halo ids that extend onto a non-topologically connected surface.
const PerfID _merge_timer
std::set< dof_id_type > container_type
The primary underlying container type used to hold the data in each FeatureData.
virtual Point featureCentroid(unsigned int feature_id) const
Returns the centroid of the designated feature (only supported without periodic boundaries)
bool mergeable(const FeatureData &rhs) const
The routine called to see if two features are mergeable:
const PerfID _comm_and_merge
Status
This enumeration is used to indicate status of the grains in the _unique_grains data structure.
void communicateAndMerge()
This routine handles all of the serialization, communication and deserialization of the data structur...
std::vector< std::set< dof_id_type > > _entities_visited
This variable keeps track of which nodes have been visited during execution.
const PerfID _execute_timer
Timers.
virtual Real getThreshold(std::size_t current_index) const
Return the starting comparison threshold to use when inspecting an entity during the flood stage.
bool periodicBoundariesIntersect(const FeatureData &rhs) const
virtual bool areFeaturesMergeable(const FeatureData &f1, const FeatureData &f2) const
Method for determining whether two features are mergeable.
bool isBoundaryEntity(const T *entity) const
Returns a Boolean indicating whether the entity is on one of the desired boundaries.
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...
BoundaryIntersection _boundary_intersection
Enumaration indicating boundary intersection status.
const bool _is_master
Convenience variable for testing master rank.
const PerfID _finalize_timer
virtual bool isFeaturePercolated(unsigned int feature_id) const
Returns a Boolean indicating whether this feature is percolated (e.g.
FeatureData duplicate() const
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< BoundaryID > _specified_bnds
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
dof_id_type _min_entity_id
The minimum entity seen in the _local_ids, used for sorting features.
virtual std::size_t getTotalFeatureCount() const
Returns the total feature count (active and inactive ids, useful for sizing vectors)
void expandPointHalos()
This method takes all of the partial features and expands the local, ghosted, and halo sets around th...
virtual void initialize() override
void dataStore(std::ostream &stream, FeatureFloodCount::FeatureData &feature, void *context)
void sortAndLabel()
Sort and assign ids to features based on their position in the container after sorting.
void expandBBox(const FeatureData &rhs)
Located the overlapping bounding box between this Feature and the other Feature and expands that over...
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...
friend std::ostream & operator<<(std::ostream &out, const FeatureData &feature)
stream output operator
static void sort(std::set< T > &)
void appendPeriodicNeighborNodes(FeatureData &feature) const
This routine adds the periodic node information to our data structure prior to packing the data this ...
FeatureData(std::size_t var_index, Status status, unsigned int id=invalid_id, std::vector< BoundingBox > bboxes={BoundingBox()})
virtual void finalize() override
container_type _ghosted_ids
Holds the ghosted ids for a feature (the ids which will be used for stitching.
Real _step_connecting_threshold
const std::vector< MooseVariable * > & getCoupledVars() const
Returns a const vector to the coupled variable pointers.
const PerfID _consolidate_merged_features
const std::vector< FeatureData > & getFeatures() const
Return a constant reference to the vector of all discovered 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.
unsigned long _var_number
This variable is used to build the periodic node map.
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
const bool _global_numbering
This variable is used to indicate whether or not we identify features with unique numbers on multiple...
std::vector< FeatureData > _volatile_feature_sets
Derived objects (e.g.
container_type _halo_ids
Holds the ids surrounding the feature.
bool operator<(const FeatureData &rhs) const
Comparison operator for sorting individual FeatureDatas.
std::list< std::pair< processor_id_type, unsigned int > > _orig_ids
Original processor/local ids.
virtual unsigned int getFeatureVar(unsigned int feature_id) const
Returns the variable representing the passed in feature.
BoundaryIntersection
This enumeration is used to inidacate status of boundary intersections.
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::vector< const Elem * > > _nodes_to_elem_map
The data structure used to find neighboring elements give a node ID.
const bool _single_map_mode
This variable is used to indicate whether or not multiple maps are used during flooding.
std::unique_ptr< PointLocatorBase > _point_locator
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.
virtual bool doesFeatureIntersectSpecifiedBoundary(unsigned int feature_id) const
Returns a Boolean indicating whether this feature intersects boundaries in a user-supplied list.
std::map< dof_id_type, int > _ghosted_entity_ids
The map for holding reconstructed ghosted element information.
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...
const DofMap & _dof_map
Reference to the dof_map containing the coupled variables.
void merge(FeatureData &&rhs)
Merges another Feature Data into this one.
std::vector< MooseVariableFEBase * > _fe_vars
The vector of coupled in variables.
bool boundingBoxesIntersect(const FeatureData &rhs) const
Determines if any of this FeatureData's bounding boxes overlap with the other FeatureData's bounding ...
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
void dataLoad(std::istream &stream, FeatureFloodCount::FeatureData &feature, void *context)
std::vector< unsigned int > _empty_var_to_features
void visitElementalNeighbors(const Elem *elem, FeatureData *feature, bool expand_halos_only, bool disjoint_only)
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 ...
std::vector< std::map< dof_id_type, int > > _halo_ids
The data structure for looking up halos around features.
bool ghostedIntersect(const FeatureData &rhs) const
virtual void execute() override
static const unsigned int invalid_id
virtual void mergeSets()
This routine is called on the master rank only and stitches together the partial feature pieces seen ...
void updateRegionOffsets()
This routine updates the _region_offsets variable which is useful for quickly determining the proper ...
PeriodicBoundaries * _pbs
A pointer to the periodic boundary constraints object.
virtual void clearDataStructures()
Helper routine for clearing up data structures during initialize and prior to parallel communication.
FeatureData(std::size_t var_index, unsigned int local_index, processor_id_type rank, Status status)
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 void initialSetup() override
container_type _periodic_nodes
Holds the nodes that belong to the feature on a periodic boundary.
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.
std::size_t _var_index
The Moose variable where this feature was found (often the "order parameter")
std::size_t numCoupledVars() const
Returns the number of coupled varaibles.
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...
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)
const bool _distribute_merge_work
Keeps track of whether we are distributing the merge work.
const bool _compute_halo_maps
Indicates whether or not to communicate halo map information with all ranks.
Point _centroid
The centroid of the feature (average of coordinates from entities participating in the volume calcula...
virtual Real getConnectingThreshold(std::size_t current_index) const
Return the "connecting" comparison threshold to use when inspecting an entity during the flood stage.
bool halosIntersect(const FeatureData &rhs) const
Determine if one of this FeaturesData's member sets intersects the other FeatureData's corresponding ...
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.
unsigned int _feature_count
The number of features seen by this object (same as summing _feature_counts_per_map)
container_type _local_ids
Holds the local ids in the interior of a feature.
const Real _threshold
The threshold above (or below) where an entity may begin a new region (feature)
const PerfID _update_field_info
bool _is_boundary_restricted
Indicates that this object should only run on one or more boundaries.
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...
static void reserve(std::set< T > &, std::size_t)
void updateBBoxExtremes(MeshBase &mesh)
Update the minimum and maximum coordinates of a bounding box given a Point, Elem or BBox parameter.
std::size_t _vol_count
The count of entities contributing to the volume calculation.
ConstBndElemRange * _bnd_elem_range
Boundary element range pointer.
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::deque< const DofObject * > _entity_queue
The data structure for maintaining entities to flood during discovery.
const bool _compute_var_to_feature_map
Indicates whether or not the var to feature map is populated.
const PostprocessorValue & _element_average_value
Average value of the domain which can optionally be used to find features in a field.
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 ...
std::vector< BoundingBox > _bboxes
The vector of bounding boxes completely enclosing this feature (multiple used with periodic constrain...
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...
FeatureData & operator=(FeatureData &&)=default
const PerfID _prepare_for_transfer
static bool setsIntersect(InputIterator first1, InputIterator last1, InputIterator first2, InputIterator last2)
This method detects whether two sets intersect without building a result set.
const processor_id_type _n_procs
Convenience variable holding the number of processors in this simulation.
virtual Real getValue() override
const PerfID _expand_halos
std::vector< std::map< dof_id_type, int > > _var_index_maps
This map keeps track of which variables own which nodes.
const std::size_t _n_vars
std::vector< std::size_t > _local_to_global_feature_map
The vector recording the local to global feature indices.
void updateBoundaryIntersections(FeatureData &feature) const
Update the feature's attributes to indicate boundary intersections.
virtual void meshChanged() override
std::vector< unsigned int > _feature_counts_per_map
The number of features seen by this object per map.
Status _status
The status of a feature (used mostly in derived classes like the GrainTracker)
std::vector< BoundaryID > _primary_perc_bnds
virtual void updateFieldInfo()
This method is used to populate any of the data structures used for storing field data (nodal or elem...
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 std::vector< MooseVariableFEBase * > & getFECoupledVars() const
Returns a const vector to the coupled MooseVariableFEBase pointers.
std::size_t getNumberActiveFeatures() const
Return the number of active features.