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 27 of file ComputeExternalGrainForceAndTorque.h.

Constructor & Destructor Documentation

◆ ComputeExternalGrainForceAndTorque()

ComputeExternalGrainForceAndTorque::ComputeExternalGrainForceAndTorque ( const InputParameters &  parameters)

Definition at line 30 of file ComputeExternalGrainForceAndTorque.C.

32  : DerivativeMaterialInterface<ShapeElementUserObject>(parameters),
34  _c_name(getVar("c", 0)->name()),
35  _c_var(coupled("c")),
36  _dF_name(getParam<MaterialPropertyName>("force_density")),
37  _dF(getMaterialPropertyByName<std::vector<RealGradient>>(_dF_name)),
38  _dFdc(
39  getMaterialPropertyByName<std::vector<RealGradient>>(propertyNameFirst(_dF_name, _c_name))),
40  _op_num(coupledComponents("etas")),
41  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_data")),
45 {
46  for (unsigned int i = 0; i < _op_num; ++i)
47  {
48  _vals_var[i] = coupled("etas", i);
49  _vals_name[i] = getVar("etas", i)->name();
50  _dFdeta[i] = &getMaterialPropertyByName<std::vector<RealGradient>>(
51  propertyNameFirst(_dF_name, _vals_name[i]));
52  }
53 }
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 std::string name
Definition: Setup.h:22
const MaterialProperty< std::vector< RealGradient > > & _dF

Member Function Documentation

◆ execute()

void ComputeExternalGrainForceAndTorque::execute ( )
virtual

Definition at line 77 of file ComputeExternalGrainForceAndTorque.C.

78 {
79  const auto & op_to_grains = _grain_tracker.getVarToFeatureVector(_current_elem->id());
80 
81  for (unsigned int i = 0; i < _grain_num; ++i)
82  for (unsigned int j = 0; j < _op_num; ++j)
83  if (i == op_to_grains[j])
84  {
85  const auto centroid = _grain_tracker.getGrainCentroid(i);
86  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
87  if (_dF[_qp][j](0) != 0.0 || _dF[_qp][j](1) != 0.0 || _dF[_qp][j](2) != 0.0)
88  {
89  const RealGradient compute_torque =
90  _JxW[_qp] * _coord[_qp] * (_current_elem->centroid() - centroid).cross(_dF[_qp][j]);
91  _force_torque_store[6 * i + 0] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](0);
92  _force_torque_store[6 * i + 1] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](1);
93  _force_torque_store[6 * i + 2] += _JxW[_qp] * _coord[_qp] * _dF[_qp][j](2);
94  _force_torque_store[6 * i + 3] += compute_torque(0);
95  _force_torque_store[6 * i + 4] += compute_torque(1);
96  _force_torque_store[6 * i + 5] += compute_torque(2);
97  }
98  }
99 }
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.
virtual Point getGrainCentroid(unsigned int grain_id) const =0
Returns the centroid for the given grain number.
const MaterialProperty< std::vector< RealGradient > > & _dF
std::vector< Real > _force_torque_store
vector storing grain force and torque values

◆ executeJacobian()

void ComputeExternalGrainForceAndTorque::executeJacobian ( unsigned int  jvar)
virtual

Definition at line 102 of file ComputeExternalGrainForceAndTorque.C.

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

◆ finalize()

void ComputeExternalGrainForceAndTorque::finalize ( )
virtual

Definition at line 164 of file ComputeExternalGrainForceAndTorque.C.

165 {
166  gatherSum(_force_torque_store);
167  for (unsigned int i = 0; i < _grain_num; ++i)
168  {
169  _force_values[i](0) = _force_torque_store[6 * i + 0];
170  _force_values[i](1) = _force_torque_store[6 * i + 1];
171  _force_values[i](2) = _force_torque_store[6 * i + 2];
172  _torque_values[i](0) = _force_torque_store[6 * i + 3];
173  _torque_values[i](1) = _force_torque_store[6 * i + 4];
174  _torque_values[i](2) = _force_torque_store[6 * i + 5];
175  }
176 
177  if (_fe_problem.currentlyComputingJacobian())
178  {
180  for (unsigned int i = 0; i < _op_num; ++i)
181  gatherSum(_force_torque_eta_jacobian_store[i]);
182  }
183 }
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

◆ getForceCJacobians()

const std::vector< Real > & ComputeExternalGrainForceAndTorque::getForceCJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 215 of file ComputeExternalGrainForceAndTorque.C.

216 {
218 }
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values

◆ getForceEtaJacobians()

const std::vector< std::vector< Real > > & ComputeExternalGrainForceAndTorque::getForceEtaJacobians ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 220 of file ComputeExternalGrainForceAndTorque.C.

221 {
223 }
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store

◆ getForceValues()

const std::vector< RealGradient > & ComputeExternalGrainForceAndTorque::getForceValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 203 of file ComputeExternalGrainForceAndTorque.C.

204 {
205  return _force_values;
206 }
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c

◆ getTorqueValues()

const std::vector< RealGradient > & ComputeExternalGrainForceAndTorque::getTorqueValues ( ) const
virtual

Implements GrainForceAndTorqueInterface.

Definition at line 209 of file ComputeExternalGrainForceAndTorque.C.

210 {
211  return _torque_values;
212 }

◆ initialize()

void ComputeExternalGrainForceAndTorque::initialize ( )
virtual

Definition at line 56 of file ComputeExternalGrainForceAndTorque.C.

57 {
59  _ncomp = 6 * _grain_num;
60 
61  _force_values.resize(_grain_num);
62  _torque_values.resize(_grain_num);
63  _force_torque_store.assign(_ncomp, 0.0);
64 
65  if (_fe_problem.currentlyComputingJacobian())
66  {
67  _total_dofs = _subproblem.es().n_dofs();
70 
71  for (unsigned int i = 0; i < _op_num; ++i)
73  }
74 }
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
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
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
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

◆ threadJoin()

void ComputeExternalGrainForceAndTorque::threadJoin ( const UserObject &  y)
virtual

Definition at line 186 of file ComputeExternalGrainForceAndTorque.C.

187 {
189  static_cast<const ComputeExternalGrainForceAndTorque &>(y);
190  for (unsigned int i = 0; i < _ncomp; ++i)
192  if (_fe_problem.currentlyComputingJacobian())
193  {
194  for (unsigned int i = 0; i < _ncomp * _total_dofs; ++i)
196  for (unsigned int i = 0; i < _op_num; ++i)
197  for (unsigned int j = 0; j < _ncomp * _total_dofs; ++j)
199  }
200 }
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

◆ _c_name

VariableName ComputeExternalGrainForceAndTorque::_c_name
protected

Definition at line 48 of file ComputeExternalGrainForceAndTorque.h.

◆ _c_var

unsigned int ComputeExternalGrainForceAndTorque::_c_var
protected

Definition at line 49 of file ComputeExternalGrainForceAndTorque.h.

Referenced by executeJacobian().

◆ _dF

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

Definition at line 52 of file ComputeExternalGrainForceAndTorque.h.

Referenced by execute().

◆ _dF_name

MaterialPropertyName ComputeExternalGrainForceAndTorque::_dF_name
protected

material property that provides force density

Definition at line 51 of file ComputeExternalGrainForceAndTorque.h.

Referenced by ComputeExternalGrainForceAndTorque().

◆ _dFdc

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

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

Definition at line 54 of file ComputeExternalGrainForceAndTorque.h.

Referenced by executeJacobian().

◆ _dFdeta

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

◆ _force_torque_c_jacobian_store

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

vector storing jacobian of grain force and torque values

Definition at line 73 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _force_torque_eta_jacobian_store

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

◆ _force_torque_store

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

vector storing grain force and torque values

Definition at line 71 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _force_values

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

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

Definition at line 67 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _grain_num

unsigned int ComputeExternalGrainForceAndTorque::_grain_num
protected

◆ _grain_tracker

const GrainTrackerInterface& ComputeExternalGrainForceAndTorque::_grain_tracker
protected

provide UserObject for calculating grain volumes and centers

Definition at line 58 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _ncomp

unsigned int ComputeExternalGrainForceAndTorque::_ncomp
protected

Definition at line 60 of file ComputeExternalGrainForceAndTorque.h.

Referenced by initialize(), and threadJoin().

◆ _op_num

const unsigned int ComputeExternalGrainForceAndTorque::_op_num
protected

◆ _qp

unsigned int ComputeExternalGrainForceAndTorque::_qp
protected

Definition at line 46 of file ComputeExternalGrainForceAndTorque.h.

Referenced by execute(), and executeJacobian().

◆ _torque_values

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

Definition at line 68 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _total_dofs

unsigned int ComputeExternalGrainForceAndTorque::_total_dofs
protected

Definition at line 76 of file ComputeExternalGrainForceAndTorque.h.

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

◆ _vals_name

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

◆ _vals_var

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

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