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 "LinearViscoelasticityManager.h" 11 : #include "libmesh/quadrature.h" 12 : 13 : registerMooseObject("TensorMechanicsApp", LinearViscoelasticityManager); 14 : 15 : InputParameters 16 48 : LinearViscoelasticityManager::validParams() 17 : { 18 48 : InputParameters params = ElementUserObject::validParams(); 19 48 : params.addClassDescription("Manages the updating of the semi-implicit " 20 : "single-step first-order finite difference " 21 : "time-stepping scheme"); 22 96 : params.addRequiredParam<std::string>("viscoelastic_model", 23 : "name of the LinearViscoelasticityBase object to manage"); 24 96 : params.addParam<std::string>( 25 : "stress_name", "stress", "name of the stress tensor used for the viscoelastic update"); 26 96 : params.addParam<std::string>("creep_strain_name", 27 : "creep_strain", 28 : "name of the creep strain tensor used for the viscoelastic update"); 29 96 : params.addParam<std::string>( 30 : "elastic_strain_name", 31 : "elastic_strain", 32 : "name of the elastic strain tensor used for the viscoelastic update"); 33 192 : params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_BEGIN, EXEC_TIMESTEP_END}; 34 48 : params.suppressParameter<ExecFlagEnum>("execute_on"); 35 48 : return params; 36 48 : } 37 : 38 24 : LinearViscoelasticityManager::LinearViscoelasticityManager(const InputParameters & parameters) 39 : : ElementUserObject(parameters), 40 24 : _stress_name(getParam<std::string>("stress_name")), 41 48 : _stress(getMaterialPropertyByName<RankTwoTensor>(_stress_name)), 42 72 : _creep_strain_name(getParam<std::string>("creep_strain_name")), 43 24 : _creep_strain(getMaterialPropertyByName<RankTwoTensor>(_creep_strain_name)), 44 72 : _elastic_strain_name(getParam<std::string>("elastic_strain_name")), 45 24 : _elastic_strain(getMaterialPropertyByName<RankTwoTensor>(_elastic_strain_name)), 46 48 : _viscoelastic_model_name(getParam<std::string>("viscoelastic_model")), 47 24 : _viscoelastic_model(nullptr) 48 : { 49 24 : } 50 : 51 : void 52 24 : LinearViscoelasticityManager::initialSetup() 53 : { 54 24 : MaterialBase * test = &getMaterialByName(_viscoelastic_model_name, /*no_warn =*/true); 55 24 : if (!test) 56 0 : mooseError(_viscoelastic_model_name + " does not exist"); 57 : 58 24 : _viscoelastic_model = dynamic_cast<LinearViscoelasticityBase *>(test); 59 24 : if (!_viscoelastic_model) 60 0 : mooseError(_viscoelastic_model_name + " is not a LinearViscoelasticityBase object"); 61 24 : } 62 : 63 : void 64 912 : LinearViscoelasticityManager::execute() 65 : { 66 912 : if (_mi_feproblem.getCurrentExecuteOnFlag() == EXEC_TIMESTEP_BEGIN) 67 : { 68 4104 : for (unsigned int _qp = 0; _qp < _qrule->n_points(); ++_qp) 69 3648 : _viscoelastic_model->recomputeQpApparentProperties(_qp); 70 : } 71 912 : }