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");
32 _c_name(coupledName(
"c", 0)),
34 _dF_name(getParam<MaterialPropertyName>(
"force_density")),
35 _dF(getMaterialPropertyByName<
std::vector<RealGradient>>(_dF_name)),
36 _dFdc(getMaterialPropertyByName<
std::vector<RealGradient>>(
37 derivativePropertyNameFirst(_dF_name, _c_name))),
38 _op_num(coupledComponents(
"etas")),
44 for (
unsigned int i = 0; i <
_op_num; ++i)
48 _dFdgradeta[i] = &getMaterialPropertyByName<std::vector<Real>>(
63 if (_fe_problem.currentlyComputingJacobian())
69 for (
unsigned int i = 0; i <
_op_num; ++i)
80 for (
unsigned int j = 0; j <
_op_num; ++j)
81 if (i == op_to_grains[j])
84 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
87 const RealGradient compute_torque =
89 (_current_elem->vertex_average() - centroid).cross(
_dF[
_qp][j]);
107 for (
unsigned int j = 0; j <
_op_num; ++j)
108 if (i == op_to_grains[j])
111 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
114 const Real factor = _JxW[
_qp] * _coord[
_qp] * _phi[_j][
_qp];
115 const RealGradient compute_torque_jacobian_c =
116 factor * (_current_elem->vertex_average() - centroid).cross(
_dFdc[
_qp][j]);
124 compute_torque_jacobian_c(0);
126 compute_torque_jacobian_c(1);
128 compute_torque_jacobian_c(2);
132 for (
unsigned int i = 0; i <
_op_num; ++i)
135 for (
unsigned int k = 0; k <
_op_num; ++k)
136 if (j == op_to_grains[k])
139 for (
_qp = 0;
_qp < _qrule->n_points(); ++
_qp)
143 const RealGradient compute_torque_jacobian_eta =
144 factor * (_current_elem->vertex_average() - centroid).cross(_grad_phi[_j][
_qp]);
146 factor * _grad_phi[_j][
_qp](0);
148 factor * _grad_phi[_j][
_qp](1);
150 factor * _grad_phi[_j][
_qp](2);
152 compute_torque_jacobian_eta(0);
154 compute_torque_jacobian_eta(1);
156 compute_torque_jacobian_eta(2);
175 if (_fe_problem.currentlyComputingJacobian())
178 for (
unsigned int i = 0; i <
_op_num; ++i)
187 for (
unsigned int i = 0; i <
_ncomp; ++i)
189 if (_fe_problem.currentlyComputingJacobian())
193 for (
unsigned int i = 0; i <
_op_num; ++i)
199const std::vector<RealGradient> &
205const std::vector<RealGradient> &
211const std::vector<Real> &
216const std::vector<std::vector<Real>> &
registerMooseObject("PhaseFieldApp", ComputeGrainForceAndTorque)
const std::vector< double > y
This class is here to get the force and torque acting on a grain.
std::vector< std::vector< Real > > _force_torque_eta_jacobian_store
virtual void executeJacobian(unsigned int jvar)
virtual void initialize()
ComputeGrainForceAndTorque(const InputParameters ¶meters)
std::vector< RealGradient > _force_values
providing grain forces, torques and their jacobians w. r. t c
const MaterialProperty< std::vector< RealGradient > > & _dF
static InputParameters validParams()
std::vector< Real > _force_torque_store
vector storing grain force and torque values
virtual const std::vector< RealGradient > & getForceValues() const
std::vector< VariableName > _vals_name
const GrainTrackerInterface & _grain_tracker
provide UserObject for calculating grain volumes and centers
std::vector< const MaterialProperty< std::vector< Real > > * > _dFdgradeta
virtual const std::vector< std::vector< Real > > & getForceEtaJacobians() const
std::vector< RealGradient > _torque_values
virtual void threadJoin(const UserObject &y)
virtual const std::vector< RealGradient > & getTorqueValues() const
std::vector< Real > _force_torque_c_jacobian_store
vector storing jacobian of grain force and torque values
MaterialPropertyName _dF_name
material property that provides force density
virtual const std::vector< Real > & getForceCJacobians() const
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
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()