www.mooseframework.org
MultiPhaseStressMaterial.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 #include "RankFourTensor.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Material>();
16  params.addClassDescription("Compute a global stress form multiple phase stresses");
17  params.addParam<std::vector<MaterialPropertyName>>(
18  "h", "Switching Function Materials that provide h(eta_i)");
19  params.addRequiredParam<std::vector<std::string>>("phase_base",
20  "Base names for the Phase strains");
21  params.addParam<std::string>("base_name", "Base name for the computed global stress (optional)");
22  return params;
23 }
24 
25 MultiPhaseStressMaterial::MultiPhaseStressMaterial(const InputParameters & parameters)
26  : Material(parameters),
27  _h_list(getParam<std::vector<MaterialPropertyName>>("h")),
28  _n_phase(_h_list.size()),
29  _h_eta(_n_phase),
30  _phase_base(getParam<std::vector<std::string>>("phase_base")),
31  _phase_stress(_n_phase),
32  _dphase_stress_dstrain(_n_phase),
33  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
34  _stress(declareProperty<RankTwoTensor>(_base_name + "stress")),
35  _dstress_dstrain(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult"))
36 {
37  // verify parameter length
38  if (_n_phase != _phase_base.size())
39  mooseError(
40  "h and phase_base input vectors need to have the same length in MultiPhaseStressMaterial ",
41  name());
42 
43  for (unsigned int i = 0; i < _n_phase; ++i)
44  {
45  _h_eta[i] = &getMaterialProperty<Real>(_h_list[i]);
46  _phase_stress[i] = &getMaterialProperty<RankTwoTensor>(_phase_base[i] + "_stress");
48  &getMaterialProperty<RankFourTensor>(_phase_base[i] + "_Jacobian_mult");
49  }
50 }
51 
52 void
54 {
55  _stress[_qp].zero();
56  _dstress_dstrain[_qp].zero();
57 
58  for (unsigned int i = 0; i < _n_phase; ++i)
59  {
60  _stress[_qp] += (*_h_eta[i])[_qp] * (*_phase_stress[i])[_qp];
61  _dstress_dstrain[_qp] += (*_h_eta[i])[_qp] * (*_dphase_stress_dstrain[i])[_qp];
62  }
63 }
std::vector< const MaterialProperty< RankFourTensor > * > _dphase_stress_dstrain
MaterialProperty< RankTwoTensor > & _stress
unsigned int _n_phase
number of phases handled by this material
MaterialProperty< RankFourTensor > & _dstress_dstrain
MultiPhaseStressMaterial(const InputParameters &parameters)
std::vector< const MaterialProperty< RankTwoTensor > * > _phase_stress
InputParameters validParams< MultiPhaseStressMaterial >()
std::vector< std::string > _phase_base
std::vector< const MaterialProperty< Real > * > _h_eta
switching functions
std::vector< MaterialPropertyName > _h_list
switching function name list