www.mooseframework.org
ConstantGrainForceAndTorque.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 
13 
16 {
18  params.addClassDescription("Userobject for calculating force and torque acting on a grain");
19  params.addParam<std::vector<Real>>("force", "force acting on grains");
20  params.addParam<std::vector<Real>>("torque", "torque acting on grains");
21  return params;
22 }
23 
26  GeneralUserObject(parameters),
27  _F(getParam<std::vector<Real>>("force")),
28  _M(getParam<std::vector<Real>>("torque")),
29  _grain_num(_F.size() / 3),
30  _ncomp(6 * _grain_num),
31  _force_values(_grain_num),
32  _torque_values(_grain_num)
33 {
34 }
35 
36 void
38 {
39  unsigned int total_dofs = _subproblem.es().n_dofs();
40  for (unsigned int i = 0; i < _grain_num; ++i)
41  {
42  _force_values[i](0) = _F[3 * i + 0];
43  _force_values[i](1) = _F[3 * i + 1];
44  _force_values[i](2) = _F[3 * i + 2];
45  _torque_values[i](0) = _M[3 * i + 0];
46  _torque_values[i](1) = _M[3 * i + 1];
47  _torque_values[i](2) = _M[3 * i + 2];
48  }
49 
51  {
52  _c_jacobians.assign(6 * _grain_num * total_dofs, 0.0);
53  _eta_jacobians.resize(_grain_num);
54  for (unsigned int i = 0; i < _grain_num; ++i)
55  _eta_jacobians[i].assign(6 * _grain_num * total_dofs, 0.0);
56  }
57 }
58 
59 const std::vector<RealGradient> &
61 {
62  return _force_values;
63 }
64 
65 const std::vector<RealGradient> &
67 {
68  return _torque_values;
69 }
70 
71 const std::vector<Real> &
73 {
74  return _c_jacobians;
75 }
76 
77 const std::vector<std::vector<Real>> &
79 {
80  return _eta_jacobians;
81 }
ConstantGrainForceAndTorque(const InputParameters &parameters)
std::vector< Real > _M
Applied torque on particles, size should be 3 times no. of grains.
static InputParameters validParams()
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...
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
virtual EquationSystems & es()=0
SubProblem & _subproblem
This class is here to get the force and torque acting on a grain.
virtual const std::vector< Real > & getForceCJacobians() const
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
static InputParameters validParams()
virtual const std::vector< RealGradient > & getForceValues() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
void addClassDescription(const std::string &doc_string)
virtual const std::vector< RealGradient > & getTorqueValues() const
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
const bool & currentlyComputingJacobian() const
registerMooseObject("PhaseFieldApp", ConstantGrainForceAndTorque)