www.mooseframework.org
GrainAdvectionAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "GrainAdvectionAux.h"
11 
12 registerMooseObject("PhaseFieldApp", GrainAdvectionAux);
13 
16 {
18  params.addClassDescription(
19  "Calculates the advection velocity of grain due to rigid body translation and rotation");
20  params.addParam<Real>(
21  "translation_constant", 1.0, "constant value characterizing grain translation");
22  params.addParam<Real>("rotation_constant", 1.0, "constant value characterizing grain rotation");
23  params.addParam<UserObjectName>("grain_tracker_object",
24  "userobject for getting volume and center of mass of grains");
25  params.addParam<VectorPostprocessorName>("grain_volumes",
26  "The feature volume VectorPostprocessorValue.");
27  params.addParam<UserObjectName>("grain_force",
28  "userobject for getting force and torque acting on grains");
29  MooseEnum component("x=0 y=1 z=2");
30  params.addParam<MooseEnum>("component", component, "The gradient component to compute");
31  return params;
32 }
33 
35  : AuxKernel(parameters),
36  _grain_tracker(
37  dynamic_cast<const GrainTrackerInterface &>(getUserObjectBase("grain_tracker_object"))),
38  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
39  _grain_force_torque(
40  dynamic_cast<const GrainForceAndTorqueInterface &>(getUserObjectBase("grain_force"))),
41  _grain_forces(_grain_force_torque.getForceValues()),
42  _grain_torques(_grain_force_torque.getTorqueValues()),
43  _mt(getParam<Real>("translation_constant")),
44  _mr(getParam<Real>("rotation_constant")),
45  _component(getParam<MooseEnum>("component"))
46 {
47  if (isNodal())
48  mooseError("Advection velocity can be assigned to elemental variables only.");
49 }
50 
51 void
53 {
54  // ID of unique grain at current point
55  const auto grain_id = _grain_tracker.getEntityValue(
57  if (grain_id >= 0)
58  {
59  mooseAssert(grain_id < _grain_volumes.size(), "grain index is out of bounds");
60  const auto volume = _grain_volumes[grain_id];
61  const auto centroid = _grain_tracker.getGrainCentroid(grain_id);
62 
63  const RealGradient velocity_translation = _mt / volume * _grain_forces[grain_id];
64  const RealGradient velocity_rotation =
65  _mr / volume * (_grain_torques[grain_id].cross(_current_elem->vertex_average() - centroid));
66  _velocity_advection = velocity_translation + velocity_rotation;
67  }
68  else
70 }
71 
72 Real
74 {
76 }
static InputParameters validParams()
This class defines the interface for the GrainTracking objects.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
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
static const std::string component
Definition: NS.h:138
const Real _mt
constant value corresponding to grain translation
virtual void precalculateValue()
calculate the advection velocity
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
GrainAdvectionAux(const InputParameters &parameters)
const VectorPostprocessorValue & _grain_volumes
The grain volumes.
Calculates the advection velocity of grain due to rigid body motion Reports the components of the vel...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const GrainTrackerInterface & _grain_tracker
getting userobject for calculating grain centers and volumes
void mooseError(Args &&... args) const
const Elem *const & _current_elem
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
registerMooseObject("PhaseFieldApp", GrainAdvectionAux)
const std::vector< RealGradient > & _grain_torques
RealGradient _velocity_advection
const std::vector< RealGradient > & _grain_forces
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) ...