www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
ComputeGrainForceAndTorque Class Reference

This class is here to get the force and torque acting on a grain. More...

#include <ComputeGrainForceAndTorque.h>

Inheritance diagram for ComputeGrainForceAndTorque:
[legend]

Public Member Functions

 ComputeGrainForceAndTorque (const InputParameters &parameters)
 
virtual void initialize ()
 
virtual void execute ()
 
virtual void executeJacobian (unsigned int jvar)
 
virtual void finalize ()
 
virtual void threadJoin (const UserObject &y)
 
virtual const std::vector< RealGradient > & getForceValues () const
 
virtual const std::vector< RealGradient > & getTorqueValues () const
 
virtual const std::vector< Real > & getForceCJacobians () const
 
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians () const
 

Protected Attributes

unsigned int _qp
 
VariableName _c_name
 
unsigned int _c_var
 
MaterialPropertyName _dF_name
 material property that provides force density More...
 
const MaterialProperty< std::vector< RealGradient > > & _dF
 
const MaterialProperty< std::vector< RealGradient > > & _dFdc
 material property that provides jacobian of force density with respect to c More...
 
unsigned int _op_num
 no. of order parameters More...
 
const GrainTrackerInterface_grain_tracker
 provide UserObject for calculating grain volumes and centers More...
 
unsigned int _grain_num
 
unsigned int _ncomp
 
std::vector< unsigned int > _vals_var
 
std::vector< VariableName > _vals_name
 
std::vector< const MaterialProperty< std::vector< Real > > * > _dFdgradeta
 
std::vector< const MaterialProperty< Real > * > _test_derivatives
 
std::vector< RealGradient > _force_values
 providing grain forces, torques and their jacobians w. r. t c More...
 
std::vector< RealGradient > _torque_values
 
std::vector< Real > _force_torque_store
 vector storing grain force and torque values More...
 
std::vector< Real > _force_torque_c_jacobian_store
 vector storing jacobian of grain force and torque values More...
 
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
 
unsigned int _total_dofs
 

Detailed Description

This class is here to get the force and torque acting on a grain.

Definition at line 24 of file ComputeGrainForceAndTorque.h.

Constructor & Destructor Documentation

ComputeGrainForceAndTorque::ComputeGrainForceAndTorque ( const InputParameters &  parameters)

Definition at line 25 of file ComputeGrainForceAndTorque.C.

26  : DerivativeMaterialInterface<ShapeElementUserObject>(parameters),
28  _c_name(getVar("c", 0)->name()),
29  _c_var(coupled("c")),
30  _dF_name(getParam<MaterialPropertyName>("force_density")),
31  _dF(getMaterialPropertyByName<std::vector<RealGradient>>(_dF_name)),
32  _dFdc(
33  getMaterialPropertyByName<std::vector<RealGradient>>(propertyNameFirst(_dF_name, _c_name))),
34  _op_num(coupledComponents("etas")),
35  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_data")),
39 {
40  for (unsigned int i = 0; i < _op_num; ++i)
41  {
42  _vals_var[i] = coupled("etas", i);
43  _vals_name[i] = getVar("etas", i)->name();
44  _dFdgradeta[i] =
45  &getMaterialPropertyByName<std::vector<Real>>(propertyNameFirst(_dF_name, _vals_name[i]));
46  }
47 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
This class provides interface for extracting the forces and torques computed in other UserObjects...
const MaterialProperty< std::vector< RealGradient > > & _dF
std::vector< const MaterialProperty< std::vector< Real > > * > _dFdgradeta
std::vector< unsigned int > _vals_var
MaterialPropertyName _dF_name
material property that provides force density
unsigned int _op_num
no. of order parameters
const MaterialProperty< std::vector< RealGradient > > & _dFdc
material property that provides jacobian of force density with respect to c
std::vector< VariableName > _vals_name

Member Function Documentation

void ComputeGrainForceAndTorque::execute ( )
virtual

Definition at line 71 of file ComputeGrainForceAndTorque.C.

72 {
73  const auto & op_to_grains = _grain_tracker.getVarToFeatureVector(_current_elem->id());
74 
75  for (unsigned int i = 0; i < _grain_num; ++i)
76  for (unsigned int j = 0; j < _op_num; ++j)
77  if (i == op_to_grains[j])
78  {
79  const auto centroid = _grain_tracker.getGrainCentroid(i);
80  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
81  if (_dF[_qp][j](0) != 0.0 || _dF[_qp][j](1) != 0.0 || _dF[_qp][j](2) != 0.0)
82  {
83  const RealGradient compute_torque =
84  _JxW[_qp] * _coord[_qp] * (_current_elem->centroid() - centroid).cross(_dF[_qp][j]);
85  _force_torque_store[6 * i + 0] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](0);
86  _force_torque_store[6 * i + 1] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](1);
87  _force_torque_store[6 * i + 2] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](2);
88  _force_torque_store[6 * i + 3] += compute_torque(0);
89  _force_torque_store[6 * i + 4] += compute_torque(1);
90  _force_torque_store[6 * i + 5] += compute_torque(2);
91  }
92  }
93 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
const MaterialProperty< std::vector< RealGradient > > & _dF
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const =0
Returns a list of active unique feature ids for a particular element.
unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_store
vector storing grain force and torque values
void ComputeGrainForceAndTorque::executeJacobian ( unsigned int  jvar)
virtual

Definition at line 96 of file ComputeGrainForceAndTorque.C.

97 {
98  const auto & op_to_grains = _grain_tracker.getVarToFeatureVector(_current_elem->id());
99 
100  if (jvar == _c_var)
101  for (unsigned int i = 0; i < _grain_num; ++i)
102  for (unsigned int j = 0; j < _op_num; ++j)
103  if (i == op_to_grains[j])
104  {
105  const auto centroid = _grain_tracker.getGrainCentroid(i);
106  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
107  if (_dFdc[_qp][j](0) != 0.0 || _dFdc[_qp][j](1) != 0.0 || _dFdc[_qp][j](2) != 0.0)
108  {
109  const Real factor = _JxW[_qp] * _coord[_qp] * _phi[_j][_qp];
110  const RealGradient compute_torque_jacobian_c =
111  factor * (_current_elem->centroid() - centroid).cross(_dFdc[_qp][j]);
112  _force_torque_c_jacobian_store[(6 * i + 0) * _total_dofs + _j_global] +=
113  factor * _dFdc[_qp][j](0);
114  _force_torque_c_jacobian_store[(6 * i + 1) * _total_dofs + _j_global] +=
115  factor * _dFdc[_qp][j](1);
116  _force_torque_c_jacobian_store[(6 * i + 2) * _total_dofs + _j_global] +=
117  factor * _dFdc[_qp][j](2);
118  _force_torque_c_jacobian_store[(6 * i + 3) * _total_dofs + _j_global] +=
119  compute_torque_jacobian_c(0);
120  _force_torque_c_jacobian_store[(6 * i + 4) * _total_dofs + _j_global] +=
121  compute_torque_jacobian_c(1);
122  _force_torque_c_jacobian_store[(6 * i + 5) * _total_dofs + _j_global] +=
123  compute_torque_jacobian_c(2);
124  }
125  }
126 
127  for (unsigned int i = 0; i < _op_num; ++i)
128  if (jvar == _vals_var[i])
129  for (unsigned int j = 0; j < _grain_num; ++j)
130  for (unsigned int k = 0; k < _op_num; ++k)
131  if (j == op_to_grains[k])
132  {
133  const auto centroid = _grain_tracker.getGrainCentroid(j);
134  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
135  if ((*_dFdgradeta[i])[_qp][j] != 0.0)
136  {
137  const Real factor = _JxW[_qp] * _coord[_qp] * (*_dFdgradeta[i])[_qp][k];
138  const RealGradient compute_torque_jacobian_eta =
139  factor * (_current_elem->centroid() - centroid).cross(_grad_phi[_j][_qp]);
140  _force_torque_eta_jacobian_store[i][(6 * j + 0) * _total_dofs + _j_global] +=
141  factor * _grad_phi[_j][_qp](0);
142  _force_torque_eta_jacobian_store[i][(6 * j + 1) * _total_dofs + _j_global] +=
143  factor * _grad_phi[_j][_qp](1);
144  _force_torque_eta_jacobian_store[i][(6 * j + 2) * _total_dofs + _j_global] +=
145  factor * _grad_phi[_j][_qp](2);
146  _force_torque_eta_jacobian_store[i][(6 * j + 3) * _total_dofs + _j_global] +=
147  compute_torque_jacobian_eta(0);
148  _force_torque_eta_jacobian_store[i][(6 * j + 4) * _total_dofs + _j_global] +=
149  compute_torque_jacobian_eta(1);
150  _force_torque_eta_jacobian_store[i][(6 * j + 5) * _total_dofs + _j_global] +=
151  compute_torque_jacobian_eta(2);
152  }
153  }
154 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
std::vector< const MaterialProperty< std::vector< Real > > * > _dFdgradeta
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const =0
Returns a list of active unique feature ids for a particular element.
std::vector< unsigned int > _vals_var
unsigned int _op_num
no. of order parameters
const MaterialProperty< std::vector< RealGradient > > & _dFdc
material property that provides jacobian of force density with respect to c
void ComputeGrainForceAndTorque::finalize ( )
virtual

Definition at line 157 of file ComputeGrainForceAndTorque.C.

158 {
159  gatherSum(_force_torque_store);
160  for (unsigned int i = 0; i < _grain_num; ++i)
161  {
162  _force_values[i](0) = _force_torque_store[6 * i + 0];
163  _force_values[i](1) = _force_torque_store[6 * i + 1];
164  _force_values[i](2) = _force_torque_store[6 * i + 2];
165  _torque_values[i](0) = _force_torque_store[6 * i + 3];
166  _torque_values[i](1) = _force_torque_store[6 * i + 4];
167  _torque_values[i](2) = _force_torque_store[6 * i + 5];
168  }
169 
170  if (_fe_problem.currentlyComputingJacobian())
171  {
173  for (unsigned int i = 0; i < _op_num; ++i)
174  gatherSum(_force_torque_eta_jacobian_store[i]);
175  }
176 }
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
std::vector< RealGradient > _torque_values
unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_store
vector storing grain force and torque values
const std::vector< Real > & ComputeGrainForceAndTorque::getForceCJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 207 of file ComputeGrainForceAndTorque.C.

208 {
210 }
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
const std::vector< std::vector< Real > > & ComputeGrainForceAndTorque::getForceEtaJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 212 of file ComputeGrainForceAndTorque.C.

213 {
215 }
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
const std::vector< RealGradient > & ComputeGrainForceAndTorque::getForceValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 195 of file ComputeGrainForceAndTorque.C.

196 {
197  return _force_values;
198 }
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
const std::vector< RealGradient > & ComputeGrainForceAndTorque::getTorqueValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 201 of file ComputeGrainForceAndTorque.C.

202 {
203  return _torque_values;
204 }
std::vector< RealGradient > _torque_values
void ComputeGrainForceAndTorque::initialize ( )
virtual

Definition at line 50 of file ComputeGrainForceAndTorque.C.

51 {
53  _ncomp = 6 * _grain_num;
54 
55  _force_values.resize(_grain_num);
56  _torque_values.resize(_grain_num);
57  _force_torque_store.assign(_ncomp, 0.0);
58 
59  if (_fe_problem.currentlyComputingJacobian())
60  {
61  _total_dofs = _subproblem.es().n_dofs();
64 
65  for (unsigned int i = 0; i < _op_num; ++i)
66  _force_torque_eta_jacobian_store[i].assign(_ncomp * _total_dofs, 0.0);
67  }
68 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
std::vector< RealGradient > _torque_values
unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_store
vector storing grain force and torque values
void ComputeGrainForceAndTorque::threadJoin ( const UserObject &  y)
virtual

Definition at line 179 of file ComputeGrainForceAndTorque.C.

180 {
181  const ComputeGrainForceAndTorque & pps = static_cast<const ComputeGrainForceAndTorque &>(y);
182  for (unsigned int i = 0; i < _ncomp; ++i)
184  if (_fe_problem.currentlyComputingJacobian())
185  {
186  for (unsigned int i = 0; i < _ncomp * _total_dofs; ++i)
188  for (unsigned int i = 0; i < _op_num; ++i)
189  for (unsigned int j = 0; j < _ncomp * _total_dofs; ++j)
191  }
192 }
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
This class is here to get the force and torque acting on a grain.
unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_store
vector storing grain force and torque values

Member Data Documentation

VariableName ComputeGrainForceAndTorque::_c_name
protected

Definition at line 44 of file ComputeGrainForceAndTorque.h.

unsigned int ComputeGrainForceAndTorque::_c_var
protected

Definition at line 45 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian().

const MaterialProperty<std::vector<RealGradient> >& ComputeGrainForceAndTorque::_dF
protected

Definition at line 48 of file ComputeGrainForceAndTorque.h.

Referenced by execute().

MaterialPropertyName ComputeGrainForceAndTorque::_dF_name
protected

material property that provides force density

Definition at line 47 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque().

const MaterialProperty<std::vector<RealGradient> >& ComputeGrainForceAndTorque::_dFdc
protected

material property that provides jacobian of force density with respect to c

Definition at line 50 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian().

std::vector<const MaterialProperty<std::vector<Real> > *> ComputeGrainForceAndTorque::_dFdgradeta
protected

Definition at line 60 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque(), and executeJacobian().

std::vector<Real> ComputeGrainForceAndTorque::_force_torque_c_jacobian_store
protected

vector storing jacobian of grain force and torque values

Definition at line 70 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian(), finalize(), getForceCJacobians(), initialize(), and threadJoin().

std::vector<std::vector<Real> > ComputeGrainForceAndTorque::_force_torque_eta_jacobian_store
protected
std::vector<Real> ComputeGrainForceAndTorque::_force_torque_store
protected

vector storing grain force and torque values

Definition at line 68 of file ComputeGrainForceAndTorque.h.

Referenced by execute(), finalize(), initialize(), and threadJoin().

std::vector<RealGradient> ComputeGrainForceAndTorque::_force_values
protected

providing grain forces, torques and their jacobians w. r. t c

Definition at line 64 of file ComputeGrainForceAndTorque.h.

Referenced by finalize(), getForceValues(), and initialize().

unsigned int ComputeGrainForceAndTorque::_grain_num
protected

Definition at line 55 of file ComputeGrainForceAndTorque.h.

Referenced by execute(), executeJacobian(), finalize(), and initialize().

const GrainTrackerInterface& ComputeGrainForceAndTorque::_grain_tracker
protected

provide UserObject for calculating grain volumes and centers

Definition at line 54 of file ComputeGrainForceAndTorque.h.

Referenced by execute(), executeJacobian(), and initialize().

unsigned int ComputeGrainForceAndTorque::_ncomp
protected

Definition at line 56 of file ComputeGrainForceAndTorque.h.

Referenced by initialize(), and threadJoin().

unsigned int ComputeGrainForceAndTorque::_op_num
protected

no. of order parameters

Definition at line 52 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque(), execute(), executeJacobian(), finalize(), initialize(), and threadJoin().

unsigned int ComputeGrainForceAndTorque::_qp
protected

Definition at line 42 of file ComputeGrainForceAndTorque.h.

Referenced by execute(), and executeJacobian().

std::vector<const MaterialProperty<Real> *> ComputeGrainForceAndTorque::_test_derivatives
protected

Definition at line 61 of file ComputeGrainForceAndTorque.h.

std::vector<RealGradient> ComputeGrainForceAndTorque::_torque_values
protected

Definition at line 65 of file ComputeGrainForceAndTorque.h.

Referenced by finalize(), getTorqueValues(), and initialize().

unsigned int ComputeGrainForceAndTorque::_total_dofs
protected

Definition at line 73 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian(), initialize(), and threadJoin().

std::vector<VariableName> ComputeGrainForceAndTorque::_vals_name
protected

Definition at line 59 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque().

std::vector<unsigned int> ComputeGrainForceAndTorque::_vals_var
protected

Definition at line 58 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque(), and executeJacobian().


The documentation for this class was generated from the following files: