23 params.
addClassDescription(
"Fake grain tracker object for cases where the number of grains is " 24 "equal to the number of order parameters.");
33 _n_vars(_vars.size()),
34 _tracking_step(getParam<
int>(
"tracking_step"))
49 std::size_t var_idx)
const 54 mooseAssert(var_idx <
_n_vars,
"Index out of range");
64 return entity_it->second;
74 "Centroids are not correct when using periodic boundaries, contact the MOOSE team"));
78 for (MooseIndex(
_vars) var_num = 0; var_num <
_n_vars; ++var_num)
80 const auto centroid =
_centroid.find(var_num);
82 if (elem_ptr->contains_point(centroid->second))
99 const std::vector<unsigned int> &
105 mooseAssert(pos->second.size() ==
_n_vars,
"Variable to feature vector not sized properly");
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");
137 return grain_center->second;
157 TIME_SECTION(
"execute", 2,
"Executing grain tracker");
159 for (
const auto & current_elem :
_mesh.
getMesh().active_local_element_ptr_range())
165 std::vector<Point> centroid(1, current_elem->vertex_average());
168 auto entity = current_elem->id();
173 auto & vec_ref = insert_pair.first->second;
175 for (MooseIndex(
_vars) var_num = 0; var_num <
_n_vars; ++var_num)
177 auto entity_value =
_vars[var_num]->sln()[0];
187 _centroid[var_num] += current_elem->vertex_average();
188 vec_ref[var_num] = var_num;
195 unsigned int n_nodes = current_elem->n_vertices();
196 for (
unsigned int i = 0; i <
n_nodes; ++i)
198 const Node * current_node = current_elem->node_ptr(i);
200 for (MooseIndex(
_vars) var_num = 0; var_num <
_n_vars; ++var_num)
202 auto entity_value =
_vars[var_num]->getNodalValue(*current_node);
221 TIME_SECTION(
"finalize", 2,
"Finalizing grain tracker");
227 for (MooseIndex(
_vars) var_num = 0; var_num <
_n_vars; ++var_num)
233 unsigned int vol_count;
234 std::vector<Real> grain_data(4);
238 vol_count = count->second;
240 const auto vol =
_volume.find(var_num);
242 grain_data[0] = vol->second;
244 const auto centroid =
_centroid.find(var_num);
247 grain_data[1] = centroid->second(0);
248 grain_data[2] = centroid->second(1);
249 grain_data[3] = centroid->second(2);
254 _volume[var_num] = grain_data[0];
255 _centroid[var_num] = {grain_data[1], grain_data[2], grain_data[3]};
269 mooseDoOnce(
mooseWarning(
"FauxGrainTracker::doesFeatureIntersectboundary() is unimplemented"));
virtual ~FauxGrainTracker()
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< unsigned int > _empty_var_to_features
This class defines the interface for the GrainTracking objects.
static const std::size_t invalid_size_t
virtual Elem * elemPtr(const dof_id_type i)
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
static InputParameters validParams()
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.
virtual void finalize() override
std::vector< unsigned int > _op_to_grains
Order parameter to grain indices (just a reflexive vector)
FauxGrainTracker(const InputParameters ¶meters)
static InputParameters validParams()
const Parallel::Communicator & _communicator
virtual Point getGrainCentroid(unsigned int grain_id) const override
Returns the centroid for the given grain number.
std::pair< typename M::iterator, bool > moose_try_emplace(M &m, const typename M::key_type &k, Args &&... args)
std::map< unsigned int, unsigned int > _vol_count
The count of entities contributing to the volume calculation.
virtual bool doesFeatureIntersectBoundary(unsigned int feature_id) const override
Returns a Boolean indicating whether this feature intersects any boundary.
void mooseWarning(Args &&... args) const
virtual std::size_t getTotalFeatureCount() const override
Returns the total feature count (active and inactive ids, useful for sizing vectors) ...
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.
const dof_id_type n_nodes
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
virtual void initialize() override
Real elementVolume(const Elem *elem) const
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.
virtual Real getEntityValue(dof_id_type entity_id, FeatureFloodCount::FieldType field_type, std::size_t var_idx) const override
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)
virtual void execute() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
FEProblemBase & _fe_problem
virtual std::size_t getNumberActiveGrains() const override
Returns the number of active grains current stored in the GrainTracker.
std::size_t _grain_count
Total Grain Count.
registerMooseObject("PhaseFieldApp", FauxGrainTracker)
This class is a fake grain tracker object, it will not actually track grains nor remap them but will ...
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.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid) override
const std::size_t _n_vars
void ErrorVector unsigned int
virtual unsigned int getFeatureVar(unsigned int feature_id) const override
Returns the variable representing the passed in feature.
void set_union(T &data, const unsigned int root_id) const
virtual Real getValue() const override