www.mooseframework.org
GrainAdvectionAux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "GrainAdvectionAux.h"
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<AuxKernel>();
14  params.addClassDescription(
15  "Calculates the advection velocity of grain due to rigid body translation and rotation");
16  params.addParam<Real>(
17  "translation_constant", 1.0, "constant value characterizing grain translation");
18  params.addParam<Real>("rotation_constant", 1.0, "constant value characterizing grain rotation");
19  params.addParam<UserObjectName>("grain_tracker_object",
20  "userobject for getting volume and center of mass of grains");
21  params.addParam<VectorPostprocessorName>("grain_volumes",
22  "The feature volume VectorPostprocessorValue.");
23  params.addParam<UserObjectName>("grain_force",
24  "userobject for getting force and torque acting on grains");
25  MooseEnum component("x=0 y=1 z=2");
26  params.addParam<MooseEnum>("component", component, "The gradient component to compute");
27  return params;
28 }
29 
30 GrainAdvectionAux::GrainAdvectionAux(const InputParameters & parameters)
31  : AuxKernel(parameters),
32  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
33  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
34  _grain_force_torque(getUserObject<GrainForceAndTorqueInterface>("grain_force")),
35  _grain_forces(_grain_force_torque.getForceValues()),
36  _grain_torques(_grain_force_torque.getTorqueValues()),
37  _mt(getParam<Real>("translation_constant")),
38  _mr(getParam<Real>("rotation_constant")),
39  _component(getParam<MooseEnum>("component"))
40 {
41  if (isNodal())
42  mooseError("Advection velocity can be assigned to elemental variables only.");
43 }
44 
45 void
47 {
48  // ID of unique grain at current point
49  const auto grain_id = _grain_tracker.getEntityValue(
50  _current_elem->id(), FeatureFloodCount::FieldType::UNIQUE_REGION, 0);
51  if (grain_id >= 0)
52  {
53  mooseAssert(grain_id < _grain_volumes.size(), "grain index is out of bounds");
54  const auto volume = _grain_volumes[grain_id];
55  const auto centroid = _grain_tracker.getGrainCentroid(grain_id);
56 
57  const RealGradient velocity_translation = _mt / volume * _grain_forces[grain_id];
58  const RealGradient velocity_rotation =
59  _mr / volume * (_grain_torques[grain_id].cross(_current_elem->centroid() - centroid));
60  _velocity_advection = velocity_translation + velocity_rotation;
61  }
62  else
63  _velocity_advection.zero();
64 }
65 
66 Real
68 {
70 }
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
This class defines the interface for the GrainTracking objects.
This class provides interface for extracting the forces and torques computed in other UserObjects...
const Real _mr
constant value corresponding to grain rotation
virtual Real computeValue()
output the component of advection velocity
const Real _mt
constant value corresponding to grain translation
Real component(const SymmTensor &symm_tensor, unsigned int index)
virtual void precalculateValue()
calculate the advection velocity
virtual Real getEntityValue(dof_id_type entity_id, FeatureFloodCount::FieldType, std::size_t var_index=0) const =0
Accessor for retrieving either nodal or elemental information (unique grains or variable indicies) ...
GrainAdvectionAux(const InputParameters &parameters)
const VectorPostprocessorValue & _grain_volumes
The grain volumes.
const GrainTrackerInterface & _grain_tracker
getting userobject for calculating grain centers and volumes
const std::vector< RealGradient > & _grain_torques
RealGradient _velocity_advection
const std::vector< RealGradient > & _grain_forces
InputParameters validParams< GrainAdvectionAux >()