www.mooseframework.org
GrainAdvectionVelocity.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 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<Material>();
14  params.addClassDescription(
15  "Calculation the advection velocity of grain due to rigid vody translation and rotation");
16  params.addRequiredCoupledVarWithAutoBuild(
17  "etas", "var_name_base", "op_num", "Array of other coupled order parameters");
18  params.addCoupledVar("c", "Concentration field");
19  params.addParam<Real>(
20  "translation_constant", 500, "constant value characterizing grain translation");
21  params.addParam<Real>("rotation_constant", 1.0, "constant value characterizing grain rotation");
22  params.addParam<std::string>("base_name",
23  "Optional parameter that allows the user to define "
24  "type of force density under consideration");
25  params.addParam<UserObjectName>("grain_data",
26  "UserObject for getting the center of mass of grains");
27  params.addParam<UserObjectName>("grain_force",
28  "userobject for getting force and torque acting on grains");
29  params.addParam<VectorPostprocessorName>("grain_volumes",
30  "The feature volume VectorPostprocessorValue.");
31  return params;
32 }
33 
34 GrainAdvectionVelocity::GrainAdvectionVelocity(const InputParameters & parameters)
35  : DerivativeMaterialInterface<Material>(parameters),
36  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_data")),
37  _grain_force_torque(getUserObject<GrainForceAndTorqueInterface>("grain_force")),
38  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
39  _grain_forces(_grain_force_torque.getForceValues()),
40  _grain_torques(_grain_force_torque.getTorqueValues()),
41  _mt(getParam<Real>("translation_constant")),
42  _mr(getParam<Real>("rotation_constant")),
43  _op_num(coupledComponents("etas")),
44  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
45  _velocity_advection(
46  declareProperty<std::vector<RealGradient>>(_base_name + "advection_velocity"))
47 {
48  mooseDeprecated("Use GrainAdvectionAux for visualizing advection velocities.");
49 }
50 
51 void
53 {
54  auto grain_num = _grain_tracker.getTotalFeatureCount();
55  const auto & op_to_grains = _grain_tracker.getVarToFeatureVector(_current_elem->id());
56 
57  _velocity_advection[_qp].resize(grain_num);
58 
59  for (unsigned int i = 0; i < _grain_volumes.size(); ++i)
60  {
61  mooseAssert(i < _grain_volumes.size(), "grain index is out of bounds");
62  const auto volume = _grain_volumes[i];
63  const auto centroid = _grain_tracker.getGrainCentroid(i);
64 
65  for (unsigned int j = 0; j < _op_num; ++j)
66  if (i == op_to_grains[j])
67  {
68  const RealGradient velocity_translation = _mt / volume * _grain_forces[i];
69  const RealGradient velocity_rotation =
70  _mr / volume * (_grain_torques[i].cross(_current_elem->centroid() - centroid));
71 
72  _velocity_advection[_qp][i] = velocity_translation + velocity_rotation;
73  }
74  }
75 }
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...
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
GrainAdvectionVelocity(const InputParameters &parameters)
const Real _mt
constant value corresponding to grain translation
const VectorPostprocessorValue & _grain_volumes
The grain volumes.
InputParameters validParams< GrainAdvectionVelocity >()
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const =0
Returns a list of active unique feature ids for a particular element.
MaterialProperty< std::vector< RealGradient > > & _velocity_advection
Material storing advection velocities of grains.
const std::vector< RealGradient > & _grain_forces
const GrainTrackerInterface & _grain_tracker
getting userobject for calculating grain centers and volumes
const Real _mr
constant value corresponding to grain rotation
const std::vector< RealGradient > & _grain_torques