www.mooseframework.org
ComputeVolumetricEigenstrain.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 /****************************************************************/
8 #include "RankTwoTensor.h"
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<ComputeEigenstrainBase>();
15  params.addClassDescription("Computes an eigenstrain that is defined by a set of scalar material "
16  "properties that summed together define the volumetric change. This "
17  "also computes the derivatives of that eigenstrain with respect to a "
18  "supplied set of variable dependencies.");
19  params.addRequiredParam<std::vector<MaterialPropertyName>>(
20  "volumetric_materials", "List of scalar materials defining the volumetric change");
21  params.addRequiredCoupledVar("args", "variable dependencies for the volumetric_expansion");
22  return params;
23 }
24 
26  : DerivativeMaterialInterface<ComputeEigenstrainBase>(parameters),
27  _num_args(coupledComponents("args")),
28  _volumetric_material_names(getParam<std::vector<MaterialPropertyName>>("volumetric_materials")),
29  _volumetric_materials(_volumetric_material_names.size()),
30  _dvolumetric_materials(_volumetric_material_names.size()),
31  _d2volumetric_materials(_volumetric_material_names.size()),
32  _delastic_strain(_num_args),
33  _d2elastic_strain(_num_args)
34 {
35  for (unsigned int i = 0; i < _volumetric_material_names.size(); ++i)
36  _volumetric_materials[i] = &getMaterialProperty<Real>(_volumetric_material_names[i]);
37 
38  // fetch prerequisite derivatives and build elastic_strain derivatives and cross-derivatives
39  for (unsigned int i = 0; i < _volumetric_material_names.size(); ++i)
40  {
41  const MaterialPropertyName & vol_matl_name = _volumetric_material_names[i];
44  for (unsigned int j = 0; j < _num_args; ++j)
45  {
46  const VariableName & jname = getVar("args", j)->name();
47  _dvolumetric_materials[i][j] = &getMaterialPropertyDerivative<Real>(vol_matl_name, jname);
48  _d2volumetric_materials[i][j].resize(_num_args);
49 
50  for (unsigned int k = j; k < _num_args; ++k)
51  {
52  const VariableName & kname = getVar("args", k)->name();
53  _d2volumetric_materials[i][j][k] =
54  &getMaterialPropertyDerivative<Real>("prefactor", jname, kname);
55  }
56  }
57  }
58 
59  for (unsigned int j = 0; j < _num_args; ++j)
60  {
61  const VariableName & jname = getVar("args", j)->name();
62  _delastic_strain[j] =
63  &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", jname);
64  _d2elastic_strain[j].resize(_num_args);
65 
66  for (unsigned int k = j; k < _num_args; ++k)
67  {
68  const VariableName & kname = getVar("args", k)->name();
69  _d2elastic_strain[j][k] =
70  &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", jname, kname);
71  }
72  }
73 }
74 
75 void
77 {
78  for (auto vmn : _volumetric_material_names)
79  validateCoupling<Real>(vmn);
80 
81  for (unsigned int i = 0; i < _num_args; ++i)
82  {
83  const VariableName & iname = getVar("args", i)->name();
84  if (_fe_problem.isMatPropRequested(propertyNameFirst(_base_name + "elastic_strain", iname)))
85  mooseError("Derivative of elastic_strain requested, but not yet implemented");
86  else
87  _delastic_strain[i] = nullptr;
88  for (unsigned int j = 0; j < _num_args; ++j)
89  {
90  const VariableName & jname = getVar("args", j)->name();
91  if (_fe_problem.isMatPropRequested(
92  propertyNameSecond(_base_name + "elastic_strain", iname, jname)))
93  mooseError("Second Derivative of elastic_strain requested, but not yet implemented");
94  else
95  _d2elastic_strain[i][j] = nullptr;
96  }
97  }
98 }
99 
100 void
102 {
103  Real volumetric_strain = 0;
104  for (unsigned int i = 0; i < _volumetric_materials.size(); ++i)
105  volumetric_strain += (*_volumetric_materials[i])[_qp];
106 
107  const Real eigenstrain_comp = computeVolumetricStrainComponent(volumetric_strain);
108  _eigenstrain[_qp].zero();
109  _eigenstrain[_qp].addIa(eigenstrain_comp);
110 
111  // TODO: Compute derivatives of the elastic strain wrt the variables specified in args
112 }
ComputeVolumetricEigenstrain(const InputParameters &parameters)
InputParameters validParams< ComputeEigenstrainBase >()
std::vector< MaterialProperty< RankTwoTensor > * > _delastic_strain
first derivatives of the elastic strain with respect to the args
std::vector< std::vector< MaterialProperty< RankTwoTensor > * > > _d2elastic_strain
second derivatives of the elastic strain with respect to the args
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2volumetric_materials
second derivatives of the volumetric materials with respect to the args
const std::vector< MaterialPropertyName > _volumetric_material_names
Names of the material properties that define volumetric change.
InputParameters validParams< ComputeVolumetricEigenstrain >()
const unsigned int _num_args
number of variables the material depends on
std::vector< std::vector< const MaterialProperty< Real > * > > _dvolumetric_materials
first derivatives of the volumetric materials with respect to the args
ComputeEigenstrainBase is the base class for eigenstrain tensors.
std::vector< const MaterialProperty< Real > * > _volumetric_materials
The material properties that define volumetric change.