13#include "libmesh/quadrature.h"
21 params.
addClassDescription(
"Userobject for calculating force and torque acting on a grain");
22 params.
addParam<MaterialPropertyName>(
"force_density",
"force_density",
"Force density material");
23 params.
addParam<UserObjectName>(
"grain_data",
"center of mass of grains");
25 params.
addCoupledVar(
"etas",
"Array of coupled order parameters");
33 _c_name(coupledName(
"c", 0)),
35 _dF_name(getParam<MaterialPropertyName>(
"force_density")),
36 _dF(getMaterialPropertyByName<
std::vector<RealGradient>>(_dF_name)),
37 _dFdc(getMaterialPropertyByName<
std::vector<RealGradient>>(
38 derivativePropertyNameFirst(_dF_name, _c_name))),
39 _op_num(coupledComponents(
"etas")),
45 for (
unsigned int i = 0; i <
_op_num; ++i)
49 _dFdeta[i] = &getMaterialPropertyByName<std::vector<RealGradient>>(
64 if (_fe_problem.currentlyComputingJacobian())
70 for (
unsigned int i = 0; i <
_op_num; ++i)
81 for (
unsigned int j = 0; j <
_op_num; ++j)
82 if (i == op_to_grains[j])
85 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
88 const RealGradient compute_torque =
90 (_current_elem->vertex_average() - centroid).cross(
_dF[
_qp][j]);
108 for (
unsigned int j = 0; j <
_op_num; ++j)
109 if (i == op_to_grains[j])
112 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
115 const Real factor = _JxW[
_qp] * _coord[
_qp] * _phi[_j][
_qp];
116 const RealGradient compute_torque_jacobian_c =
117 factor * (_current_elem->vertex_average() - centroid).cross(
_dFdc[
_qp][j]);
125 compute_torque_jacobian_c(0);
127 compute_torque_jacobian_c(1);
129 compute_torque_jacobian_c(2);
133 for (
unsigned int i = 0; i <
_op_num; ++i)
136 for (
unsigned int k = 0; k <
_op_num; ++k)
137 if (j == op_to_grains[k])
140 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
144 const Real factor = _JxW[
_qp] * _coord[
_qp] * _phi[_j][
_qp];
145 const RealGradient compute_torque_jacobian_eta =
147 (_current_elem->vertex_average() - centroid).cross((*
_dFdeta[i])[
_qp][k]);
155 compute_torque_jacobian_eta(0);
157 compute_torque_jacobian_eta(1);
159 compute_torque_jacobian_eta(2);
178 if (_fe_problem.currentlyComputingJacobian())
181 for (
unsigned int i = 0; i <
_op_num; ++i)
190 for (
unsigned int i = 0; i <
_ncomp; ++i)
192 if (_fe_problem.currentlyComputingJacobian())
196 for (
unsigned int i = 0; i <
_op_num; ++i)
202const std::vector<RealGradient> &
208const std::vector<RealGradient> &
214const std::vector<Real> &
219const std::vector<std::vector<Real>> &
registerMooseObject("PhaseFieldApp", ComputeExternalGrainForceAndTorque)
const std::vector< double > y
This class is here to get the force and torque acting on a grain.
virtual void executeJacobian(unsigned int jvar)
ComputeExternalGrainForceAndTorque(const InputParameters ¶meters)
std::vector< const MaterialProperty< std::vector< RealGradient > > * > _dFdeta
const unsigned int _op_num
no. of order parameters
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
virtual void initialize()
virtual const std::vector< RealGradient > & getForceValues() const
virtual const std::vector< RealGradient > & getTorqueValues() const
const MaterialProperty< std::vector< RealGradient > > & _dF
MaterialPropertyName _dF_name
material property that provides force density
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
const MaterialProperty< std::vector< RealGradient > > & _dFdc
material property that provides jacobian of force density with respect to c
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< RealGradient > _torque_values
std::vector< Real > _force_torque_store
vector storing grain force and torque values
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
virtual const std::vector< Real > & getForceCJacobians() const
std::vector< VariableName > _vals_name
static InputParameters validParams()
std::vector< unsigned int > _vals_var
virtual void threadJoin(const UserObject &y)
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
This class provides interface for extracting the forces and torques computed in other UserObjects.
This class defines the interface for the GrainTracking objects.
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
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.
static InputParameters validParams()