www.mooseframework.org
ConstantGrainForceAndTorque.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 /****************************************************************/
7 
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<GeneralUserObject>();
15  params.addClassDescription("Userobject for calculating force and torque acting on a grain");
16  params.addParam<std::vector<Real>>("force", "force acting on grains");
17  params.addParam<std::vector<Real>>("torque", "torque acting on grains");
18  return params;
19 }
20 
23  GeneralUserObject(parameters),
24  _F(getParam<std::vector<Real>>("force")),
25  _M(getParam<std::vector<Real>>("torque")),
26  _grain_num(_F.size() / 3),
27  _ncomp(6 * _grain_num),
28  _force_values(_grain_num),
29  _torque_values(_grain_num)
30 {
31 }
32 
33 void
35 {
36  unsigned int total_dofs = _subproblem.es().n_dofs();
37  for (unsigned int i = 0; i < _grain_num; ++i)
38  {
39  _force_values[i](0) = _F[3 * i + 0];
40  _force_values[i](1) = _F[3 * i + 1];
41  _force_values[i](2) = _F[3 * i + 2];
42  _torque_values[i](0) = _M[3 * i + 0];
43  _torque_values[i](1) = _M[3 * i + 1];
44  _torque_values[i](2) = _M[3 * i + 2];
45  }
46 
47  if (_fe_problem.currentlyComputingJacobian())
48  {
49  _c_jacobians.assign(6 * _grain_num * total_dofs, 0.0);
50  _eta_jacobians.resize(_grain_num);
51  for (unsigned int i = 0; i < _grain_num; ++i)
52  _eta_jacobians[i].assign(6 * _grain_num * total_dofs, 0.0);
53  }
54 }
55 
56 const std::vector<RealGradient> &
58 {
59  return _force_values;
60 }
61 
62 const std::vector<RealGradient> &
64 {
65  return _torque_values;
66 }
67 
68 const std::vector<Real> &
70 {
71  return _c_jacobians;
72 }
73 
74 const std::vector<std::vector<Real>> &
76 {
77  return _eta_jacobians;
78 }
ConstantGrainForceAndTorque(const InputParameters &parameters)
std::vector< Real > _M
Applied torque on particles, size should be 3 times no. of grains.
virtual const std::vector< RealGradient > & getForceValues() const
This class provides interface for extracting the forces and torques computed in other UserObjects...
std::vector< Real > _F
Applied force on particles, size should be 3 times no. of grains.
std::vector< RealGradient > _torque_values
std::vector< std::vector< Real > > _eta_jacobians
virtual const std::vector< Real > & getForceCJacobians() const
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
InputParameters validParams< ConstantGrainForceAndTorque >()
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
virtual const std::vector< RealGradient > & getTorqueValues() const