www.mooseframework.org
ComputePolycrystalElasticityTensor.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 #include "RotationTensor.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<ComputeElasticityTensorBase>();
16  params.addClassDescription(
17  "Compute an evolving elasticity tensor coupled to a grain growth phase field model.");
18  params.addRequiredParam<UserObjectName>(
19  "grain_tracker", "Name of GrainTracker user object that provides RankFourTensors");
20  params.addParam<Real>("length_scale", 1.0e-9, "Lengthscale of the problem, in meters");
21  params.addParam<Real>("pressure_scale", 1.0e6, "Pressure scale of the problem, in pa");
22  params.addRequiredCoupledVarWithAutoBuild(
23  "v", "var_name_base", "op_num", "Array of coupled variables");
24  return params;
25 }
26 
28  const InputParameters & parameters)
29  : ComputeElasticityTensorBase(parameters),
30  _length_scale(getParam<Real>("length_scale")),
31  _pressure_scale(getParam<Real>("pressure_scale")),
32  _grain_tracker(getUserObject<GrainDataTracker<RankFourTensor>>("grain_tracker")),
33  _op_num(coupledComponents("v")),
34  _vals(_op_num),
35  _D_elastic_tensor(_op_num),
36  _JtoeV(6.24150974e18)
37 {
38  // Loop over variables (ops)
39  for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index)
40  {
41  // Initialize variables
42  _vals[op_index] = &coupledValue("v", op_index);
43 
44  // declare elasticity tensor derivative properties
45  _D_elastic_tensor[op_index] = &declarePropertyDerivative<RankFourTensor>(
46  _elasticity_tensor_name, getVar("v", op_index)->name());
47  }
48 }
49 
50 void
52 {
53  // Get list of active order parameters from grain tracker
54  const auto & op_to_grains = _grain_tracker.getVarToFeatureVector(_current_elem->id());
55 
56  // Calculate elasticity tensor
57  _elasticity_tensor[_qp].zero();
58  Real sum_h = 0.0;
59  for (auto op_index = beginIndex(op_to_grains); op_index < op_to_grains.size(); ++op_index)
60  {
61  auto grain_id = op_to_grains[op_index];
62  if (grain_id == FeatureFloodCount::invalid_id)
63  continue;
64 
65  // Interpolation factor for elasticity tensors
66  Real h = (1.0 + std::sin(libMesh::pi * ((*_vals[op_index])[_qp] - 0.5))) / 2.0;
67 
68  // Sum all rotated elasticity tensors
69  _elasticity_tensor[_qp] += _grain_tracker.getData(grain_id) * h;
70  sum_h += h;
71  }
72 
73  const Real tol = 1.0e-10;
74  sum_h = std::max(sum_h, tol);
75  _elasticity_tensor[_qp] /= sum_h;
76 
77  // Calculate elasticity tensor derivative: Cderiv = dhdopi/sum_h * (Cop - _Cijkl)
78  for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index)
79  (*_D_elastic_tensor[op_index])[_qp].zero();
80 
81  for (auto op_index = beginIndex(op_to_grains); op_index < op_to_grains.size(); ++op_index)
82  {
83  auto grain_id = op_to_grains[op_index];
84  if (grain_id == FeatureFloodCount::invalid_id)
85  continue;
86 
87  Real dhdopi = libMesh::pi * std::cos(libMesh::pi * ((*_vals[op_index])[_qp] - 0.5)) / 2.0;
88  RankFourTensor & C_deriv = (*_D_elastic_tensor[op_index])[_qp];
89 
90  C_deriv = (_grain_tracker.getData(grain_id) - _elasticity_tensor[_qp]) * dhdopi / sum_h;
91 
92  // Convert from XPa to eV/(xm)^3, where X is pressure scale and x is length scale;
94  }
95 }
virtual const std::vector< unsigned int > & getVarToFeatureVector(dof_id_type elem_id) const override
Returns a list of active unique feature ids for a particular element.
Definition: GrainTracker.C:95
const Real _JtoeV
Conversion factor from J to eV.
InputParameters validParams< ComputePolycrystalElasticityTensor >()
ComputeElasticityTensorBase the base class for computing elasticity tensors.
ComputePolycrystalElasticityTensor(const InputParameters &parameters)
static const unsigned int invalid_id
static const double tol
Definition: XFEMFuncs.h:26
const T & getData(unsigned int grain_id) const
return data for selected grain
InputParameters validParams< ComputeElasticityTensorBase >()
const unsigned int _op_num
Number of order parameters.
std::vector< MaterialProperty< RankFourTensor > * > _D_elastic_tensor
vector of elasticity tensor material properties
const GrainDataTracker< RankFourTensor > & _grain_tracker
Grain tracker object.
std::vector< const VariableValue * > _vals
Order parameters.
MaterialProperty< RankFourTensor > & _elasticity_tensor
GrainTracker derived class template to base objects on which maintain physical parameters for individ...