Go to the documentation of this file.
13 #include "MooseMesh.h"
14 #include "MooseVariable.h"
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;
73 mooseDoOnce(mooseWarning(
74 "Centroids are not correct when using periodic boundaries, contact the MOOSE team"));
77 const auto * elem_ptr =
_mesh.elemPtr(entity_id);
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 Moose::perf_log.push(
"execute()",
"FauxGrainTracker");
159 for (
const auto & current_elem :
_mesh.getMesh().active_local_element_ptr_range())
165 std::vector<Point> centroid(1, current_elem->centroid());
166 _fe_problem.reinitElemPhys(current_elem, centroid, 0);
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];
184 _volume[var_num] += current_elem->volume();
187 _centroid[var_num] += current_elem->centroid();
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);
217 Moose::perf_log.pop(
"execute()",
"FauxGrainTracker");
223 Moose::perf_log.push(
"finalize()",
"FauxGrainTracker");
229 for (MooseIndex(
_vars) var_num = 0; var_num <
_n_vars; ++var_num)
235 unsigned int vol_count;
236 std::vector<Real> grain_data(4);
240 vol_count = count->second;
242 const auto vol =
_volume.find(var_num);
244 grain_data[0] = vol->second;
246 const auto centroid =
_centroid.find(var_num);
249 grain_data[1] = centroid->second(0);
250 grain_data[2] = centroid->second(1);
251 grain_data[3] = centroid->second(2);
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]};
261 Moose::perf_log.pop(
"finalize()",
"FauxGrainTracker");
273 mooseDoOnce(mooseWarning(
"FauxGrainTracker::doesFeatureIntersectboundary() is unimplemented"));
virtual std::size_t getTotalFeatureCount() const override
Returns the total feature count (active and inactive ids, useful for sizing vectors)
This class defines the interface for the GrainTracking objects.
static const std::size_t invalid_size_t
InputParameters validParams< FauxGrainTracker >()
MooseMesh & _mesh
A reference to the mesh.
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...
virtual std::size_t getNumberActiveGrains() const override
Returns the number of active grains current stored in the GrainTracker.
std::map< dof_id_type, std::vector< unsigned int > > _entity_var_to_features
virtual Real getEntityValue(dof_id_type entity_id, FeatureFloodCount::FieldType field_type, std::size_t var_idx) const override
This object will mark nodes or elements of continuous regions all with a unique number for the purpos...
InputParameters validParams< GrainTrackerInterface >()
virtual void finalize() override
This class is a fake grain tracker object, it will not actually track grains nor remap them but will ...
virtual void execute() override
std::set< unsigned int > _variables_used
Used as the lightweight grain counter.
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 initialize() override
virtual Real getValue() override
const bool _use_less_than_threshold_comparison
Use less-than when comparing values against the threshold value.
std::vector< unsigned int > _op_to_grains
Order parameter to grain indices (just a reflexive vector)
virtual Point getGrainCentroid(unsigned int grain_id) const override
Returns the centroid for the given grain number.
const bool _is_elemental
Determines if the flood counter is elements or not (nodes)
std::vector< MooseVariable * > _vars
The vector of coupled in variables cast to MooseVariable.
static const unsigned int invalid_id
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.
virtual ~FauxGrainTracker()
virtual unsigned int getFeatureVar(unsigned int feature_id) const override
Returns the variable representing the passed in feature.
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::vector< unsigned int > _empty_var_to_features
const Real _threshold
The threshold above (or below) where an entity may begin a new region (feature)
const std::size_t _n_vars
std::map< unsigned int, Real > _volume
The volume of the feature.
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 ...
FauxGrainTracker(const InputParameters ¶meters)
registerMooseObject("PhaseFieldApp", FauxGrainTracker)