www.mooseframework.org
GrainRigidBodyMotionBase.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 
11 
12 // MOOSE includes
13 #include "GrainTrackerInterface.h"
14 #include "MooseVariable.h"
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<NonlocalKernel>();
21  params.addClassDescription("Base class for adding rigid body motion to grains");
22  params.addRequiredCoupledVar("c", "Concentration");
23  params.addRequiredCoupledVarWithAutoBuild(
24  "v", "var_name_base", "op_num", "Array of coupled variable names");
25  params.addParam<std::string>("base_name",
26  "Optional parameter that allows the user to define "
27  "type of force density under consideration");
28  params.addParam<Real>(
29  "translation_constant", 500, "constant value characterizing grain translation");
30  params.addParam<Real>("rotation_constant", 1.0, "constant value characterizing grain rotation");
31  params.addRequiredParam<UserObjectName>(
32  "grain_force", "UserObject for getting force and torque acting on grains");
33  params.addRequiredParam<UserObjectName>("grain_tracker_object",
34  "The FeatureFloodCount UserObject to get values from.");
35  params.addRequiredParam<VectorPostprocessorName>("grain_volumes",
36  "The feature volume VectorPostprocessorValue.");
37  return params;
38 }
39 
40 GrainRigidBodyMotionBase::GrainRigidBodyMotionBase(const InputParameters & parameters)
41  : NonlocalKernel(parameters),
42  _var_dofs(_var.dofIndices()),
43  _c_var(coupled("c")),
44  _c(coupledValue("c")),
45  _grad_c(coupledGradient("c")),
46  _c_dofs(getVar("c", 0)->dofIndices()),
47  _op_num(coupledComponents("v")),
48  _vals(_op_num),
49  _vals_var(_op_num),
50  _grad_vals(_op_num),
51  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
52  _grain_force_torque(getUserObject<GrainForceAndTorqueInterface>("grain_force")),
53  _grain_forces(_grain_force_torque.getForceValues()),
54  _grain_torques(_grain_force_torque.getTorqueValues()),
55  _grain_force_c_jacobians(_grain_force_torque.getForceCJacobians()),
56  _grain_force_eta_jacobians(_grain_force_torque.getForceEtaJacobians()),
57  _mt(getParam<Real>("translation_constant")),
58  _mr(getParam<Real>("rotation_constant")),
59  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
60  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes"))
61 {
62  // Loop through grains and load coupled variables into the arrays
63  for (unsigned int i = 0; i < _op_num; ++i)
64  {
65  _vals[i] = &coupledValue("v", i);
66  _vals_var[i] = coupled("v", i);
67  _grad_vals[i] = &coupledGradient("v", i);
68  }
69 }
70 
71 void
73 {
74  _total_dofs = _subproblem.es().n_dofs();
75 }
76 
77 bool
78 GrainRigidBodyMotionBase::globalDoFEnabled(MooseVariableFEBase & /*var*/, dof_id_type /*dof_index*/)
79 {
82  return false;
83 
84  return true;
85 }
86 
87 void
89 {
91 }
92 
93 void
95 {
97 }
98 
99 void
101 {
103 }
virtual void precalculateOffDiagJacobian(unsigned int jvar)
const unsigned int _op_num
no. of order parameters
GrainRigidBodyMotionBase(const InputParameters &parameters)
This class defines the interface for the GrainTracking objects.
This class provides interface for extracting the forces and torques computed in other UserObjects...
std::vector< unsigned int > _vals_var
virtual bool globalDoFEnabled(MooseVariableFEBase &, dof_id_type)
unsigned int _total_dofs
get the total no. of dofs in the system
std::vector< const VariableValue * > _vals
Variable value for the order parameters.
InputParameters validParams< GrainRigidBodyMotionBase >()
std::vector< const VariableGradient * > _grad_vals