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