https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GrainForceAndTorqueSum.C
Go to the documentation of this file.
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
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
40void
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);
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)
69 _eta_jacobians[i][j] += (_sum_forces[k]->getForceEtaJacobians())[i][j];
70 }
71 }
72}
73
74const std::vector<RealGradient> &
79
80const std::vector<RealGradient> &
85
86const std::vector<Real> &
91
92const std::vector<std::vector<Real>> &
registerMooseObject("PhaseFieldApp", GrainForceAndTorqueSum)
void ErrorVector unsigned int
static InputParameters validParams()
This class provides interface for extracting the forces and torques computed in other UserObjects.
This class is here to get the force and torque acting on a grain from different userobjects and sum t...
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
std::vector< const GrainForceAndTorqueInterface * > _sum_forces
unsigned int _num_forces
Total no. of userobjects that provides forces and torques acting on grains.
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
std::vector< UserObjectName > _sum_objects
Vector of userobjects providing forces and torques acting on grains.
static InputParameters validParams()
std::vector< std::vector< Real > > _eta_jacobians
virtual const std::vector< Real > & getForceCJacobians() const
std::vector< Real > _c_jacobians
virtual const std::vector< RealGradient > & getForceValues() const
GrainForceAndTorqueSum(const InputParameters &parameters)
std::vector< RealGradient > _torque_values
virtual const std::vector< RealGradient > & getTorqueValues() const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const bool & currentlyComputingJacobian() const
virtual libMesh::EquationSystems & es()=0
SubProblem & _subproblem
FEProblemBase & _fe_problem
std::size_t n_dofs() const