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

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

#include <ComputeExternalGrainForceAndTorque.h>

Inheritance diagram for ComputeExternalGrainForceAndTorque:
[legend]

Public Member Functions

 ComputeExternalGrainForceAndTorque (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...
 
const 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< RealGradient > > * > _dFdeta
 
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 ComputeExternalGrainForceAndTorque.h.

Constructor & Destructor Documentation

ComputeExternalGrainForceAndTorque::ComputeExternalGrainForceAndTorque ( const InputParameters &  parameters)

Definition at line 25 of file ComputeExternalGrainForceAndTorque.C.

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

Member Function Documentation

void ComputeExternalGrainForceAndTorque::execute ( )
virtual

Definition at line 72 of file ComputeExternalGrainForceAndTorque.C.

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

Definition at line 97 of file ComputeExternalGrainForceAndTorque.C.

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

Definition at line 159 of file ComputeExternalGrainForceAndTorque.C.

160 {
161  gatherSum(_force_torque_store);
162  for (unsigned int i = 0; i < _grain_num; ++i)
163  {
164  _force_values[i](0) = _force_torque_store[6 * i + 0];
165  _force_values[i](1) = _force_torque_store[6 * i + 1];
166  _force_values[i](2) = _force_torque_store[6 * i + 2];
167  _torque_values[i](0) = _force_torque_store[6 * i + 3];
168  _torque_values[i](1) = _force_torque_store[6 * i + 4];
169  _torque_values[i](2) = _force_torque_store[6 * i + 5];
170  }
171 
172  if (_fe_problem.currentlyComputingJacobian())
173  {
175  for (unsigned int i = 0; i < _op_num; ++i)
176  gatherSum(_force_torque_eta_jacobian_store[i]);
177  }
178 }
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
const unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< Real > _force_torque_store
vector storing grain force and torque values
const std::vector< Real > & ComputeExternalGrainForceAndTorque::getForceCJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 210 of file ComputeExternalGrainForceAndTorque.C.

211 {
213 }
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
const std::vector< std::vector< Real > > & ComputeExternalGrainForceAndTorque::getForceEtaJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 215 of file ComputeExternalGrainForceAndTorque.C.

216 {
218 }
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
const std::vector< RealGradient > & ComputeExternalGrainForceAndTorque::getForceValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 198 of file ComputeExternalGrainForceAndTorque.C.

199 {
200  return _force_values;
201 }
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
const std::vector< RealGradient > & ComputeExternalGrainForceAndTorque::getTorqueValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 204 of file ComputeExternalGrainForceAndTorque.C.

205 {
206  return _torque_values;
207 }
void ComputeExternalGrainForceAndTorque::initialize ( )
virtual

Definition at line 51 of file ComputeExternalGrainForceAndTorque.C.

52 {
54  _ncomp = 6 * _grain_num;
55 
56  _force_values.resize(_grain_num);
57  _torque_values.resize(_grain_num);
58  _force_torque_store.assign(_ncomp, 0.0);
59 
60  if (_fe_problem.currentlyComputingJacobian())
61  {
62  _total_dofs = _subproblem.es().n_dofs();
65 
66  for (unsigned int i = 0; i < _op_num; ++i)
67  _force_torque_eta_jacobian_store[i].assign(_ncomp * _total_dofs, 0.0);
68  }
69 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
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
const unsigned int _op_num
no. of order parameters
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
std::vector< Real > _force_torque_store
vector storing grain force and torque values
void ComputeExternalGrainForceAndTorque::threadJoin ( const UserObject &  y)
virtual

Definition at line 181 of file ComputeExternalGrainForceAndTorque.C.

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

Member Data Documentation

VariableName ComputeExternalGrainForceAndTorque::_c_name
protected

Definition at line 45 of file ComputeExternalGrainForceAndTorque.h.

unsigned int ComputeExternalGrainForceAndTorque::_c_var
protected

Definition at line 46 of file ComputeExternalGrainForceAndTorque.h.

Referenced by executeJacobian().

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

Definition at line 49 of file ComputeExternalGrainForceAndTorque.h.

Referenced by execute().

MaterialPropertyName ComputeExternalGrainForceAndTorque::_dF_name
protected

material property that provides force density

Definition at line 48 of file ComputeExternalGrainForceAndTorque.h.

Referenced by ComputeExternalGrainForceAndTorque().

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

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

Definition at line 51 of file ComputeExternalGrainForceAndTorque.h.

Referenced by executeJacobian().

std::vector<const MaterialProperty<std::vector<RealGradient> > *> ComputeExternalGrainForceAndTorque::_dFdeta
protected
std::vector<Real> ComputeExternalGrainForceAndTorque::_force_torque_c_jacobian_store
protected

vector storing jacobian of grain force and torque values

Definition at line 70 of file ComputeExternalGrainForceAndTorque.h.

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

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

vector storing grain force and torque values

Definition at line 68 of file ComputeExternalGrainForceAndTorque.h.

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

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

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

Definition at line 64 of file ComputeExternalGrainForceAndTorque.h.

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

unsigned int ComputeExternalGrainForceAndTorque::_grain_num
protected
const GrainTrackerInterface& ComputeExternalGrainForceAndTorque::_grain_tracker
protected

provide UserObject for calculating grain volumes and centers

Definition at line 55 of file ComputeExternalGrainForceAndTorque.h.

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

unsigned int ComputeExternalGrainForceAndTorque::_ncomp
protected

Definition at line 57 of file ComputeExternalGrainForceAndTorque.h.

Referenced by initialize(), and threadJoin().

const unsigned int ComputeExternalGrainForceAndTorque::_op_num
protected
unsigned int ComputeExternalGrainForceAndTorque::_qp
protected

Definition at line 43 of file ComputeExternalGrainForceAndTorque.h.

Referenced by execute(), and executeJacobian().

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

Definition at line 65 of file ComputeExternalGrainForceAndTorque.h.

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

unsigned int ComputeExternalGrainForceAndTorque::_total_dofs
protected

Definition at line 73 of file ComputeExternalGrainForceAndTorque.h.

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

std::vector<VariableName> ComputeExternalGrainForceAndTorque::_vals_name
protected
std::vector<unsigned int> ComputeExternalGrainForceAndTorque::_vals_var
protected

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