www.mooseframework.org
ComputePolycrystalElasticityTensor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "RotationTensor.h"
12 
14 
17 {
19  params.addClassDescription(
20  "Compute an evolving elasticity tensor coupled to a grain growth phase field model.");
21  params.addRequiredParam<UserObjectName>(
22  "grain_tracker", "Name of GrainTracker user object that provides RankFourTensors");
23  params.addParam<Real>("length_scale", 1.0e-9, "Length scale of the problem, in meters");
24  params.addParam<Real>("pressure_scale", 1.0e6, "Pressure scale of the problem, in pa");
26  "v", "var_name_base", "op_num", "Array of coupled variables");
27  return params;
28 }
29 
31  const InputParameters & parameters)
32  : ComputeElasticityTensorBase(parameters),
33  _length_scale(getParam<Real>("length_scale")),
34  _pressure_scale(getParam<Real>("pressure_scale")),
35  _grain_tracker(getUserObject<GrainDataTracker<RankFourTensor>>("grain_tracker")),
36  _op_num(coupledComponents("v")),
37  _vals(coupledValues("v")),
38  _D_elastic_tensor(_op_num),
39  _JtoeV(6.24150974e18)
40 {
41  // Loop over variables (ops)
42  for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index)
43  {
44  // declare elasticity tensor derivative properties
45  _D_elastic_tensor[op_index] = &declarePropertyDerivative<RankFourTensor>(
46  _elasticity_tensor_name, coupledName("v", op_index));
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 (MooseIndex(op_to_grains) op_index = 0; 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 (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index)
79  (*_D_elastic_tensor[op_index])[_qp].zero();
80 
81  for (MooseIndex(op_to_grains) op_index = 0; 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 }
const Real _JtoeV
Conversion factor from J to eV.
const T & getData(unsigned int grain_id) const
return data for selected grain
VariableName coupledName(const std::string &var_name, unsigned int comp=0) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const double tol
ComputeElasticityTensorBase the base class for computing elasticity tensors.
GenericMaterialProperty< T, is_ad > & _elasticity_tensor
ComputePolycrystalElasticityTensor(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const std::vector< const VariableValue * > _vals
Order parameters.
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:131
Compute an evolving elasticity tensor coupled to a grain growth phase field model.
registerMooseObject("PhaseFieldApp", ComputePolycrystalElasticityTensor)
static const unsigned int invalid_id
const unsigned int _op_num
Number of order parameters.
std::vector< MaterialProperty< RankFourTensor > * > _D_elastic_tensor
vector of elasticity tensor material properties
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addRequiredCoupledVarWithAutoBuild(const std::string &name, const std::string &base_name, const std::string &num_name, const std::string &doc_string)
const GrainDataTracker< RankFourTensor > & _grain_tracker
Grain tracker object.
void addClassDescription(const std::string &doc_string)
GrainTracker derived class template to base objects on which maintain physical parameters for individ...
const Real pi