Line data Source code
1 : //* This file is part of the RACCOON application 2 : //* being developed at Dolbow lab at Duke University 3 : //* http://dolbow.pratt.duke.edu 4 : 5 : #include "ComputeEigenstrainFromFunctionInitialStress.h" 6 : 7 : registerMooseObject("raccoonApp", ComputeEigenstrainFromFunctionInitialStress); 8 : 9 : InputParameters 10 136 : ComputeEigenstrainFromFunctionInitialStress::validParams() 11 : { 12 136 : InputParameters params = Material::validParams(); 13 136 : params += BaseNameInterface::validParams(); 14 136 : params.addClassDescription( 15 : "This class computes the eigenstrain given a predefined intial stress. The eigenstrain is " 16 : "defined as $\\strain_0 = - \\mathbb{S} : \\stress_0$, where $\\mathbb{S}$ is the compliance " 17 : "tensor. Isotropic linear elasticity is " 18 : "assumed."); 19 : 20 272 : params.addRequiredParam<MaterialPropertyName>("bulk_modulus", "The bulk modulus $\\K$"); 21 272 : params.addRequiredParam<MaterialPropertyName>("shear_modulus", "The shear modulus $\\G$"); 22 272 : params.addRequiredParam<MaterialPropertyName>( 23 : "eigenstrain_name", 24 : "Material property name for the eigenstrain tensor computed " 25 : "by this model. IMPORTANT: The name of this property must " 26 : "also be provided to the strain calculator."); 27 272 : params.addRequiredParam<std::vector<FunctionName>>( 28 : "initial_stress", "A list of functions describing the eigen stress."); 29 136 : return params; 30 0 : } 31 : 32 0 : ComputeEigenstrainFromFunctionInitialStress::ComputeEigenstrainFromFunctionInitialStress( 33 0 : const InputParameters & parameters) 34 : : Material(parameters), 35 : BaseNameInterface(parameters), 36 0 : _K(getADMaterialPropertyByName<Real>(prependBaseName("bulk_modulus", true))), 37 0 : _G(getADMaterialPropertyByName<Real>(prependBaseName("shear_modulus", true))), 38 0 : _eigenstrain_name(prependBaseName("eigenstrain_name", true)), 39 0 : _eigenstrain(declareADProperty<RankTwoTensor>(_eigenstrain_name)) 40 : { 41 : const std::vector<FunctionName> & fcn_names( 42 0 : getParam<std::vector<FunctionName>>("initial_stress")); 43 : const std::size_t num = fcn_names.size(); 44 : 45 0 : if (num != 1 && num != 3 && num != 6 && num != 9) 46 0 : paramError( 47 : "initial_stress", 48 0 : name() + ": " + 49 0 : "Either 1, 3, 6, or 9 initial stress functions should be provided. You supplied " + 50 0 : Moose::stringify(num) + "."); 51 : 52 0 : _initial_stress_fcn.resize(num); 53 0 : for (unsigned i = 0; i < num; ++i) 54 0 : _initial_stress_fcn[i] = &getFunctionByName(fcn_names[i]); 55 0 : } 56 : 57 : void 58 0 : ComputeEigenstrainFromFunctionInitialStress::initQpStatefulProperties() 59 : { 60 0 : computeQpProperties(); 61 0 : } 62 : 63 : void 64 0 : ComputeEigenstrainFromFunctionInitialStress::computeQpProperties() 65 : { 66 : const std::size_t num = _initial_stress_fcn.size(); 67 0 : std::vector<ADReal> initial_stress_vector(num); 68 0 : for (unsigned i = 0; i < num; ++i) 69 0 : initial_stress_vector[i] = _initial_stress_fcn[i]->value(_t, _q_point[_qp]); 70 0 : ADRankTwoTensor initial_stress; 71 0 : initial_stress.fillFromInputVector(initial_stress_vector); 72 : 73 0 : const ADRankTwoTensor I2(ADRankTwoTensor::initIdentity); 74 0 : _eigenstrain[_qp] = 75 0 : -initial_stress.trace() / 9 / _K[_qp] * I2 - initial_stress.deviatoric() / 2 / _G[_qp]; 76 0 : }