Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 : 10 : #include "MultiPhaseStressMaterial.h" 11 : #include "RankTwoTensor.h" 12 : #include "RankFourTensor.h" 13 : 14 : registerMooseObject("SolidMechanicsApp", MultiPhaseStressMaterial); 15 : 16 : InputParameters 17 0 : MultiPhaseStressMaterial::validParams() 18 : { 19 0 : InputParameters params = Material::validParams(); 20 0 : params.addClassDescription("Compute a global stress from multiple phase stresses"); 21 0 : params.addParam<std::vector<MaterialPropertyName>>( 22 : "h", "Switching Function Materials that provide h(eta_i)"); 23 0 : params.addRequiredParam<std::vector<std::string>>("phase_base", 24 : "Base names for the Phase strains"); 25 0 : params.addParam<std::string>("base_name", "Base name for the computed global stress (optional)"); 26 0 : return params; 27 0 : } 28 : 29 0 : MultiPhaseStressMaterial::MultiPhaseStressMaterial(const InputParameters & parameters) 30 : : Material(parameters), 31 0 : _h_list(getParam<std::vector<MaterialPropertyName>>("h")), 32 0 : _n_phase(_h_list.size()), 33 0 : _h_eta(_n_phase), 34 0 : _phase_base(getParam<std::vector<std::string>>("phase_base")), 35 0 : _phase_stress(_n_phase), 36 0 : _dphase_stress_dstrain(_n_phase), 37 0 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 38 0 : _stress(declareProperty<RankTwoTensor>(_base_name + "stress")), 39 0 : _dstress_dstrain(declareProperty<RankFourTensor>(_base_name + "Jacobian_mult")) 40 : { 41 : // verify parameter length 42 0 : if (_n_phase != _phase_base.size()) 43 0 : mooseError( 44 : "h and phase_base input vectors need to have the same length in MultiPhaseStressMaterial ", 45 : name()); 46 : 47 0 : for (unsigned int i = 0; i < _n_phase; ++i) 48 : { 49 0 : _h_eta[i] = &getMaterialProperty<Real>(_h_list[i]); 50 0 : _phase_stress[i] = &getMaterialProperty<RankTwoTensor>(_phase_base[i] + "_stress"); 51 0 : _dphase_stress_dstrain[i] = 52 0 : &getMaterialProperty<RankFourTensor>(_phase_base[i] + "_Jacobian_mult"); 53 : } 54 0 : } 55 : 56 : void 57 0 : MultiPhaseStressMaterial::computeQpProperties() 58 : { 59 0 : _stress[_qp].zero(); 60 0 : _dstress_dstrain[_qp].zero(); 61 : 62 0 : for (unsigned int i = 0; i < _n_phase; ++i) 63 : { 64 0 : _stress[_qp] += (*_h_eta[i])[_qp] * (*_phase_stress[i])[_qp]; 65 0 : _dstress_dstrain[_qp] += (*_h_eta[i])[_qp] * (*_dphase_stress_dstrain[i])[_qp]; 66 : } 67 0 : }