www.mooseframework.org
ComputeVolumetricEigenstrain.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 "RankTwoTensor.h"
12 
14 
17 {
19  params.addClassDescription("Computes an eigenstrain that is defined by a set of scalar material "
20  "properties that summed together define the volumetric change. This "
21  "also computes the derivatives of that eigenstrain with respect to a "
22  "supplied set of variable dependencies.");
23  params.addRequiredParam<std::vector<MaterialPropertyName>>(
24  "volumetric_materials", "List of scalar material properties defining the volumetric change");
25  params.addRequiredCoupledVar("args", "variable dependencies for the volumetric_expansion");
26  return params;
27 }
28 
31  _num_args(coupledComponents("args")),
32  _volumetric_material_names(getParam<std::vector<MaterialPropertyName>>("volumetric_materials")),
33  _volumetric_materials(_volumetric_material_names.size()),
34  _dvolumetric_materials(_volumetric_material_names.size()),
35  _d2volumetric_materials(_volumetric_material_names.size()),
36  _delastic_strain(_num_args),
37  _d2elastic_strain(_num_args)
38 {
39  for (unsigned int i = 0; i < _volumetric_material_names.size(); ++i)
40  _volumetric_materials[i] = &getMaterialProperty<Real>(_volumetric_material_names[i]);
41 
42  // fetch prerequisite derivatives and build elastic_strain derivatives and cross-derivatives
43  for (unsigned int i = 0; i < _volumetric_material_names.size(); ++i)
44  {
45  const MaterialPropertyName & vol_matl_name = _volumetric_material_names[i];
48  for (unsigned int j = 0; j < _num_args; ++j)
49  {
50  const VariableName & jname = coupledName("args", j);
51  _dvolumetric_materials[i][j] = &getMaterialPropertyDerivative<Real>(vol_matl_name, jname);
53 
54  for (unsigned int k = j; k < _num_args; ++k)
55  {
56  const VariableName & kname = coupledName("args", k);
58  &getMaterialPropertyDerivative<Real>("prefactor", jname, kname);
59  }
60  }
61  }
62 
63  for (unsigned int j = 0; j < _num_args; ++j)
64  {
65  const VariableName & jname = coupledName("args", j);
67  &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", jname);
68  _d2elastic_strain[j].resize(_num_args);
69 
70  for (unsigned int k = j; k < _num_args; ++k)
71  {
72  const VariableName & kname = coupledName("args", k);
74  &declarePropertyDerivative<RankTwoTensor>(_base_name + "elastic_strain", jname, kname);
75  }
76  }
77 }
78 
79 void
81 {
82  for (auto vmn : _volumetric_material_names)
83  validateCoupling<Real>(vmn);
84 
85  for (unsigned int i = 0; i < _num_args; ++i)
86  {
87  const VariableName & iname = coupledName("args", i);
88  if (_fe_problem.isMatPropRequested(
89  derivativePropertyNameFirst(_base_name + "elastic_strain", iname)))
90  mooseError("Derivative of elastic_strain requested, but not yet implemented");
91  else
92  _delastic_strain[i] = nullptr;
93  for (unsigned int j = 0; j < _num_args; ++j)
94  {
95  const VariableName & jname = coupledName("args", j);
96  if (_fe_problem.isMatPropRequested(
97  derivativePropertyNameSecond(_base_name + "elastic_strain", iname, jname)))
98  mooseError("Second Derivative of elastic_strain requested, but not yet implemented");
99  else
100  _d2elastic_strain[i][j] = nullptr;
101  }
102  }
103 }
104 
105 void
107 {
108  Real volumetric_strain = 0;
109  for (unsigned int i = 0; i < _volumetric_materials.size(); ++i)
110  volumetric_strain += (*_volumetric_materials[i])[_qp];
111 
112  const Real eigenstrain_comp = computeVolumetricStrainComponent(volumetric_strain);
113  _eigenstrain[_qp].zero();
114  _eigenstrain[_qp].addIa(eigenstrain_comp);
115 
116  // TODO: Compute derivatives of the elastic strain wrt the variables specified in args
117 }
ComputeVolumetricEigenstrain(const InputParameters &parameters)
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
void mooseError(Args &&... args)
std::vector< std::vector< std::vector< const MaterialProperty< Real > * > > > _d2volumetric_materials
second derivatives of the volumetric materials with respect to the args
const MaterialPropertyName derivativePropertyNameSecond(const MaterialPropertyName &base, const SymbolName &c1, const SymbolName &c2) const
const MaterialPropertyName derivativePropertyNameFirst(const MaterialPropertyName &base, const SymbolName &c1) const
registerMooseObject("SolidMechanicsApp", ComputeVolumetricEigenstrain)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const std::vector< MaterialPropertyName > _volumetric_material_names
Names of the material properties that define volumetric change.
ComputeVolumetricEigenstrain computes an eigenstrain that is defined by a set of scalar material prop...
static InputParameters validParams()
ComputeEigenstrainBase is the base class for eigenstrain tensors.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const unsigned int _num_args
number of variables the material depends on
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
std::vector< std::vector< const MaterialProperty< Real > * > > _dvolumetric_materials
first derivatives of the volumetric materials with respect to the args
std::vector< const MaterialProperty< Real > * > _volumetric_materials
The material properties that define volumetric change.
static const std::string k
Definition: NS.h:124