https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GrainAdvectionAux.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
13
16{
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(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
37 _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
38 _grain_force_torque(getUserObject<GrainForceAndTorqueInterface>("grain_force")),
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 _component(getParam<MooseEnum>("component"))
44{
45 if (isNodal())
46 mooseError("Advection velocity can be assigned to elemental variables only.");
47}
48
49void
51{
52 // ID of unique grain at current point
53 const auto grain_id = _grain_tracker.getEntityValue(
55 if (grain_id >= 0)
56 {
57 mooseAssert(grain_id < _grain_volumes.size(), "grain index is out of bounds");
58 const auto volume = _grain_volumes[grain_id];
59 const auto centroid = _grain_tracker.getGrainCentroid(grain_id);
60
61 const RealGradient velocity_translation = _mt / volume * _grain_forces[grain_id];
62 const RealGradient velocity_rotation =
63 _mr / volume * (_grain_torques[grain_id].cross(_current_elem->vertex_average() - centroid));
64 _velocity_advection = velocity_translation + velocity_rotation;
65 }
66 else
68}
69
70Real
registerMooseObject("PhaseFieldApp", GrainAdvectionAux)
const Elem *const & _current_elem
static InputParameters validParams()
Calculates the advection velocity of grain due to rigid body motion Reports the components of the vel...
GrainAdvectionAux(const InputParameters &parameters)
static InputParameters validParams()
const std::vector< RealGradient > & _grain_forces
const Real _mr
constant value corresponding to grain rotation
virtual Real computeValue()
output the component of advection velocity
const VectorPostprocessorValue & _grain_volumes
The grain volumes.
const Real _mt
constant value corresponding to grain translation
RealGradient _velocity_advection
const std::vector< RealGradient > & _grain_torques
const GrainTrackerInterface & _grain_tracker
getting userobject for calculating grain centers and volumes
virtual void precalculateValue()
calculate the advection velocity
This class provides interface for extracting the forces and torques computed in other UserObjects.
This class defines the interface for the GrainTracking objects.
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
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)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const