Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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("TensorMechanicsApp", ComputeGlobalStrain); 17 : 18 : InputParameters 19 96 : ComputeGlobalStrain::validParams() 20 : { 21 96 : InputParameters params = Material::validParams(); 22 96 : params.addClassDescription( 23 : "Material for storing the global strain values from the scalar variable"); 24 192 : 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 192 : params.addCoupledVar("scalar_global_strain", "Scalar variable for global strain"); 29 192 : params.addCoupledVar("displacements", "The name of the displacement variables"); 30 192 : params.addRequiredParam<UserObjectName>("global_strain_uo", 31 : "The name of the GlobalStrainUserObject"); 32 : 33 192 : params.set<MooseEnum>("constant_on") = "SUBDOMAIN"; 34 96 : return params; 35 0 : } 36 : 37 72 : ComputeGlobalStrain::ComputeGlobalStrain(const InputParameters & parameters) 38 : : Material(parameters), 39 72 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 40 72 : _scalar_global_strain(coupledScalarValue("scalar_global_strain")), 41 72 : _global_strain(declareProperty<RankTwoTensor>(_base_name + "global_strain")), 42 72 : _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")), 43 72 : _periodic_dir(_pst.getPeriodicDirections()), 44 72 : _dim(_mesh.dimension()), 45 144 : _ndisp(coupledComponents("displacements")) 46 : { 47 72 : } 48 : 49 : void 50 0 : ComputeGlobalStrain::initQpStatefulProperties() 51 : { 52 0 : _global_strain[_qp].zero(); 53 0 : } 54 : 55 : void 56 974 : ComputeGlobalStrain::computeQpProperties() 57 : { 58 974 : RankTwoTensor & strain = _global_strain[_qp]; 59 974 : strain.fillFromScalarVariable(_scalar_global_strain); 60 : 61 3756 : for (unsigned int dir = 0; dir < _dim; ++dir) 62 2782 : if (!_periodic_dir(dir)) 63 3734 : for (unsigned int var = 0; var < _ndisp; ++var) 64 2785 : strain(dir, var) = 0.0; 65 974 : }