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

Constructor & Destructor Documentation

◆ ComputeGrainForceAndTorque()

ComputeGrainForceAndTorque::ComputeGrainForceAndTorque ( const InputParameters &  parameters)

Definition at line 30 of file ComputeGrainForceAndTorque.C.

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

◆ execute()

void ComputeGrainForceAndTorque::execute ( )
virtual

Definition at line 76 of file ComputeGrainForceAndTorque.C.

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

◆ executeJacobian()

void ComputeGrainForceAndTorque::executeJacobian ( unsigned int  jvar)
virtual

Definition at line 101 of file ComputeGrainForceAndTorque.C.

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

◆ finalize()

void ComputeGrainForceAndTorque::finalize ( )
virtual

Definition at line 162 of file ComputeGrainForceAndTorque.C.

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

◆ getForceCJacobians()

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

Implements GrainForceAndTorqueInterface.

Definition at line 212 of file ComputeGrainForceAndTorque.C.

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

◆ getForceEtaJacobians()

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

Implements GrainForceAndTorqueInterface.

Definition at line 217 of file ComputeGrainForceAndTorque.C.

218 {
220 }
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store

◆ getForceValues()

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

Implements GrainForceAndTorqueInterface.

Definition at line 200 of file ComputeGrainForceAndTorque.C.

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

◆ getTorqueValues()

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

Implements GrainForceAndTorqueInterface.

Definition at line 206 of file ComputeGrainForceAndTorque.C.

207 {
208  return _torque_values;
209 }
std::vector< RealGradient > _torque_values

◆ initialize()

void ComputeGrainForceAndTorque::initialize ( )
virtual

Definition at line 55 of file ComputeGrainForceAndTorque.C.

56 {
58  _ncomp = 6 * _grain_num;
59 
60  _force_values.resize(_grain_num);
61  _torque_values.resize(_grain_num);
62  _force_torque_store.assign(_ncomp, 0.0);
63 
64  if (_fe_problem.currentlyComputingJacobian())
65  {
66  _total_dofs = _subproblem.es().n_dofs();
69 
70  for (unsigned int i = 0; i < _op_num; ++i)
72  }
73 }
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
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.
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

◆ threadJoin()

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

Definition at line 184 of file ComputeGrainForceAndTorque.C.

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

◆ _c_name

VariableName ComputeGrainForceAndTorque::_c_name
protected

Definition at line 47 of file ComputeGrainForceAndTorque.h.

◆ _c_var

unsigned int ComputeGrainForceAndTorque::_c_var
protected

Definition at line 48 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian().

◆ _dF

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

Definition at line 51 of file ComputeGrainForceAndTorque.h.

Referenced by execute().

◆ _dF_name

MaterialPropertyName ComputeGrainForceAndTorque::_dF_name
protected

material property that provides force density

Definition at line 50 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque().

◆ _dFdc

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

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

Definition at line 53 of file ComputeGrainForceAndTorque.h.

Referenced by executeJacobian().

◆ _dFdgradeta

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

Definition at line 63 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque(), and executeJacobian().

◆ _force_torque_c_jacobian_store

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

vector storing jacobian of grain force and torque values

Definition at line 73 of file ComputeGrainForceAndTorque.h.

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

◆ _force_torque_eta_jacobian_store

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

◆ _force_torque_store

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

vector storing grain force and torque values

Definition at line 71 of file ComputeGrainForceAndTorque.h.

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

◆ _force_values

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

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

Definition at line 67 of file ComputeGrainForceAndTorque.h.

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

◆ _grain_num

unsigned int ComputeGrainForceAndTorque::_grain_num
protected

Definition at line 58 of file ComputeGrainForceAndTorque.h.

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

◆ _grain_tracker

const GrainTrackerInterface& ComputeGrainForceAndTorque::_grain_tracker
protected

provide UserObject for calculating grain volumes and centers

Definition at line 57 of file ComputeGrainForceAndTorque.h.

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

◆ _ncomp

unsigned int ComputeGrainForceAndTorque::_ncomp
protected

Definition at line 59 of file ComputeGrainForceAndTorque.h.

Referenced by initialize(), and threadJoin().

◆ _op_num

unsigned int ComputeGrainForceAndTorque::_op_num
protected

no. of order parameters

Definition at line 55 of file ComputeGrainForceAndTorque.h.

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

◆ _qp

unsigned int ComputeGrainForceAndTorque::_qp
protected

Definition at line 45 of file ComputeGrainForceAndTorque.h.

Referenced by execute(), and executeJacobian().

◆ _test_derivatives

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

Definition at line 64 of file ComputeGrainForceAndTorque.h.

◆ _torque_values

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

Definition at line 68 of file ComputeGrainForceAndTorque.h.

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

◆ _total_dofs

unsigned int ComputeGrainForceAndTorque::_total_dofs
protected

Definition at line 76 of file ComputeGrainForceAndTorque.h.

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

◆ _vals_name

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

Definition at line 62 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque().

◆ _vals_var

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

Definition at line 61 of file ComputeGrainForceAndTorque.h.

Referenced by ComputeGrainForceAndTorque(), and executeJacobian().


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