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 "ConstantsFromElasticityTensor.h" 11 : #include "ElasticityTensorTools.h" 12 : 13 : #include "metaphysicl/raw_type.h" 14 : 15 : registerMooseObject("SolidMechanicsApp", ConstantsFromElasticityTensor); 16 : registerMooseObject("SolidMechanicsApp", ADConstantsFromElasticityTensor); 17 : 18 : template <bool is_ad> 19 : InputParameters 20 36 : ConstantsFromElasticityTensorTempl<is_ad>::validParams() 21 : { 22 36 : InputParameters params = Material::validParams(); 23 36 : params.addClassDescription("Calculate elastic constants from an isotropic elasticity tensor"); 24 72 : params.addParam<MaterialPropertyName>( 25 : "elasticity_tensor", "elasticity_tensor", "The name of the elasticity tensor."); 26 72 : params.addParam<std::string>("base_name", 27 : "Optional parameter that allows the user to define " 28 : "multiple mechanics material systems on the same " 29 : "block, i.e. for multiple phases"); 30 : 31 36 : return params; 32 0 : } 33 : 34 : template <bool is_ad> 35 27 : ConstantsFromElasticityTensorTempl<is_ad>::ConstantsFromElasticityTensorTempl( 36 : const InputParameters & parameters) 37 : : Material(parameters), 38 : GuaranteeConsumer(this), 39 27 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 40 27 : _youngs_modulus(this->template declareGenericProperty<Real, is_ad>( 41 27 : _base_name + "youngs_modulus_from_tensor")), 42 54 : _poissons_ratio(this->template declareGenericProperty<Real, is_ad>( 43 : _base_name + "poissons_ratio_from_tensor")), 44 54 : _shear_modulus(this->template declareGenericProperty<Real, is_ad>(_base_name + 45 : "shear_modulus_from_tensor")), 46 54 : _bulk_modulus(this->template declareGenericProperty<Real, is_ad>(_base_name + 47 : "bulk_modulus_from_tensor")), 48 54 : _elasticity_tensor_name(getParam<MaterialPropertyName>("elasticity_tensor")), 49 27 : _elasticity_tensor(this->template getGenericMaterialPropertyByName<RankFourTensor, is_ad>( 50 27 : _base_name + _elasticity_tensor_name)) 51 : { 52 27 : } 53 : 54 : template <bool is_ad> 55 : void 56 25 : ConstantsFromElasticityTensorTempl<is_ad>::initialSetup() 57 : { 58 75 : if (!hasGuaranteedMaterialProperty(_base_name + _elasticity_tensor_name, Guarantee::ISOTROPIC)) 59 1 : mooseError("ConstantsFromElasticityTensor requires that the elasticity tensor be " 60 : "guaranteed isotropic"); 61 24 : } 62 : 63 : template <bool is_ad> 64 : void 65 18 : ConstantsFromElasticityTensorTempl<is_ad>::computeQpProperties() 66 : { 67 18 : const auto & elasticity_tensor = MetaPhysicL::raw_value(_elasticity_tensor[_qp]); 68 : 69 18 : _youngs_modulus[_qp] = ElasticityTensorTools::getIsotropicYoungsModulus(elasticity_tensor); 70 18 : _poissons_ratio[_qp] = ElasticityTensorTools::getIsotropicPoissonsRatio(elasticity_tensor); 71 18 : _shear_modulus[_qp] = ElasticityTensorTools::getIsotropicShearModulus(elasticity_tensor); 72 18 : _bulk_modulus[_qp] = ElasticityTensorTools::getIsotropicBulkModulus(elasticity_tensor); 73 18 : } 74 : 75 : template class ConstantsFromElasticityTensorTempl<false>; 76 : template class ConstantsFromElasticityTensorTempl<true>;