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 128 : ComputeGlobalStrain::validParams() 20 : { 21 128 : InputParameters params = Material::validParams(); 22 128 : params.addClassDescription( 23 : "Material for storing the global strain values from the scalar variable"); 24 256 : 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 256 : params.addCoupledVar("scalar_global_strain", "Scalar variable for global strain"); 29 256 : params.addCoupledVar("displacements", "The name of the displacement variables"); 30 256 : params.addRequiredParam<UserObjectName>("global_strain_uo", 31 : "The name of the GlobalStrainUserObject"); 32 : 33 256 : params.set<MooseEnum>("constant_on") = "SUBDOMAIN"; 34 128 : return params; 35 0 : } 36 : 37 96 : ComputeGlobalStrain::ComputeGlobalStrain(const InputParameters & parameters) 38 : : Material(parameters), 39 96 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 40 96 : _scalar_global_strain(coupledScalarValue("scalar_global_strain")), 41 96 : _global_strain(declareProperty<RankTwoTensor>(_base_name + "global_strain")), 42 96 : _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")), 43 96 : _periodic_dir(_pst.getPeriodicDirections()), 44 96 : _dim(_mesh.dimension()), 45 192 : _ndisp(coupledComponents("displacements")) 46 : { 47 96 : } 48 : 49 : void 50 0 : ComputeGlobalStrain::initQpStatefulProperties() 51 : { 52 0 : _global_strain[_qp].zero(); 53 0 : } 54 : 55 : void 56 960 : ComputeGlobalStrain::computeQpProperties() 57 : { 58 960 : RankTwoTensor & strain = _global_strain[_qp]; 59 960 : strain.fillFromScalarVariable(_scalar_global_strain); 60 : 61 3652 : for (unsigned int dir = 0; dir < _dim; ++dir) 62 2692 : if (!_periodic_dir(dir)) 63 3506 : for (unsigned int var = 0; var < _ndisp; ++var) 64 2609 : strain(dir, var) = 0.0; 65 960 : }