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 "ComputeGlobalStrain.h" 11 : #include "GlobalStrainUserObjectInterface.h" 12 : 13 : // MOOSE includes 14 : #include "RankTwoTensor.h" 15 : 16 : registerMooseObject("SolidMechanicsApp", ComputeGlobalStrain); 17 : 18 : InputParameters 19 192 : ComputeGlobalStrain::validParams() 20 : { 21 192 : InputParameters params = Material::validParams(); 22 192 : params.addClassDescription( 23 : "Material for storing the global strain values from the scalar variable"); 24 384 : params.addParam<std::string>("base_name", 25 : "Optional parameter that allows the user to define " 26 : "multiple mechanics material systems on the same " 27 : "block, i.e. for multiple phases"); 28 384 : params.addCoupledVar("scalar_global_strain", "Scalar variable for global strain"); 29 384 : params.addCoupledVar("displacements", "The name of the displacement variables"); 30 384 : params.addRequiredParam<UserObjectName>("global_strain_uo", 31 : "The name of the GlobalStrainUserObject"); 32 : 33 384 : params.set<MooseEnum>("constant_on") = "SUBDOMAIN"; 34 192 : return params; 35 0 : } 36 : 37 144 : ComputeGlobalStrain::ComputeGlobalStrain(const InputParameters & parameters) 38 : : Material(parameters), 39 144 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 40 144 : _scalar_global_strain(coupledScalarValue("scalar_global_strain")), 41 144 : _global_strain(declareProperty<RankTwoTensor>(_base_name + "global_strain")), 42 144 : _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")), 43 144 : _periodic_dir(_pst.getPeriodicDirections()), 44 144 : _dim(_mesh.dimension()), 45 288 : _ndisp(coupledComponents("displacements")) 46 : { 47 144 : } 48 : 49 : void 50 0 : ComputeGlobalStrain::initQpStatefulProperties() 51 : { 52 0 : _global_strain[_qp].zero(); 53 0 : } 54 : 55 : void 56 1682 : ComputeGlobalStrain::computeQpProperties() 57 : { 58 1682 : RankTwoTensor & strain = _global_strain[_qp]; 59 1682 : strain.fillFromScalarVariable(_scalar_global_strain); 60 : 61 6496 : for (unsigned int dir = 0; dir < _dim; ++dir) 62 4814 : if (!_periodic_dir(dir)) 63 6516 : for (unsigned int var = 0; var < _ndisp; ++var) 64 4862 : strain(dir, var) = 0.0; 65 1682 : }