www.mooseframework.org
GrainForceAndTorqueSum.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 
10 #include "GrainForceAndTorqueSum.h"
11 
13 
16 {
18  params.addClassDescription("Userobject for summing forces and torques acting on a grain");
19  params.addParam<std::vector<UserObjectName>>(
20  "grain_forces",
21  "List of names of user objects that provides forces and torques applied to grains");
22  params.addParam<unsigned int>("grain_num", "Number of grains");
23  return params;
24 }
25 
28  GeneralUserObject(parameters),
29  _sum_objects(getParam<std::vector<UserObjectName>>("grain_forces")),
30  _num_forces(_sum_objects.size()),
31  _grain_num(getParam<unsigned int>("grain_num")),
32  _sum_forces(_num_forces),
33  _force_values(_grain_num),
34  _torque_values(_grain_num)
35 {
36  for (unsigned int i = 0; i < _num_forces; ++i)
37  _sum_forces[i] = &getUserObjectByName<GrainForceAndTorqueInterface>(_sum_objects[i]);
38 }
39 
40 void
42 {
43  for (unsigned int i = 0; i < _grain_num; ++i)
44  {
45  _force_values[i] = 0.0;
46  _torque_values[i] = 0.0;
47  for (unsigned int j = 0; j < _num_forces; ++j)
48  {
49  _force_values[i] += (_sum_forces[j]->getForceValues())[i];
50  _torque_values[i] += (_sum_forces[j]->getTorqueValues())[i];
51  }
52  }
53 
55  {
56  unsigned int total_dofs = _subproblem.es().n_dofs();
57  _c_jacobians.resize(6 * _grain_num * total_dofs, 0.0);
58  _eta_jacobians.resize(_grain_num);
59 
60  for (unsigned int i = 0; i < _c_jacobians.size(); ++i)
61  for (unsigned int j = 0; j < _num_forces; ++j)
63 
64  for (unsigned int i = 0; i < _grain_num; ++i)
65  {
66  _eta_jacobians[i].resize(6 * _grain_num * total_dofs, 0.0);
67  for (unsigned int j = 0; j < _eta_jacobians[i].size(); ++j)
68  for (unsigned int k = 0; k < _num_forces; ++k)
70  }
71  }
72 }
73 
74 const std::vector<RealGradient> &
76 {
77  return _force_values;
78 }
79 
80 const std::vector<RealGradient> &
82 {
83  return _torque_values;
84 }
85 
86 const std::vector<Real> &
88 {
89  return _c_jacobians;
90 }
91 
92 const std::vector<std::vector<Real>> &
94 {
95  return _eta_jacobians;
96 }
virtual const std::vector< RealGradient > & getTorqueValues() const
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
std::vector< Real > _c_jacobians
virtual const std::vector< RealGradient > & getForceValues() const
static InputParameters validParams()
std::vector< const GrainForceAndTorqueInterface * > _sum_forces
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...
GrainForceAndTorqueSum(const InputParameters &parameters)
This class is here to get the force and torque acting on a grain from different userobjects and sum t...
virtual const std::vector< Real > & getForceCJacobians() const
virtual EquationSystems & es()=0
SubProblem & _subproblem
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
std::vector< UserObjectName > _sum_objects
Vector of userobjects providing forces and torques acting on grains.
std::vector< std::vector< Real > > _eta_jacobians
unsigned int _num_forces
Total no. of userobjects that provides forces and torques acting on grains.
FEProblemBase & _fe_problem
registerMooseObject("PhaseFieldApp", GrainForceAndTorqueSum)
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const bool & currentlyComputingJacobian() const
static const std::string k
Definition: NS.h:124
void ErrorVector unsigned int
std::vector< RealGradient > _torque_values
static InputParameters validParams()