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 "GenericFunctionRankTwoTensor.h" 11 : 12 : #include "Function.h" 13 : 14 : registerMooseObject("MooseApp", GenericFunctionRankTwoTensor); 15 : registerMooseObject("MooseApp", ADGenericFunctionRankTwoTensor); 16 : 17 : template <bool is_ad> 18 : InputParameters 19 28632 : GenericFunctionRankTwoTensorTempl<is_ad>::validParams() 20 : { 21 28632 : InputParameters params = Material::validParams(); 22 28632 : params.addClassDescription( 23 : "Material object for defining rank two tensor properties using functions."); 24 28632 : params.addRequiredParam<std::vector<FunctionName>>( 25 : "tensor_functions", "Vector of Function names defining the rank two tensor"); 26 28632 : params.addRequiredParam<MaterialPropertyName>( 27 : "tensor_name", "Name of the tensor material property to be created"); 28 28632 : return params; 29 0 : } 30 : 31 : template <bool is_ad> 32 78 : GenericFunctionRankTwoTensorTempl<is_ad>::GenericFunctionRankTwoTensorTempl( 33 : const InputParameters & parameters) 34 : : Material(parameters), 35 234 : _prop(declareGenericProperty<RankTwoTensor, is_ad>( 36 78 : getParam<MaterialPropertyName>("tensor_name"))), 37 78 : _function_names(getParam<std::vector<FunctionName>>("tensor_functions")), 38 78 : _num_functions(_function_names.size()), 39 156 : _functions(_num_functions) 40 : { 41 780 : for (unsigned int i = 0; i < _num_functions; i++) 42 702 : _functions[i] = &getFunctionByName(_function_names[i]); 43 78 : } 44 : 45 : template <bool is_ad> 46 : void 47 0 : GenericFunctionRankTwoTensorTempl<is_ad>::initQpStatefulProperties() 48 : { 49 0 : GenericFunctionRankTwoTensorTempl<is_ad>::computeQpProperties(); 50 0 : } 51 : 52 : template <bool is_ad> 53 : void 54 48 : GenericFunctionRankTwoTensorTempl<is_ad>::computeQpProperties() 55 : { 56 48 : std::vector<GenericReal<is_ad>> values(_num_functions); 57 480 : for (unsigned int i = 0; i < _num_functions; i++) 58 432 : values[i] = (*_functions[i]).value(_t, _q_point[_qp]); 59 : 60 48 : _prop[_qp].fillFromInputVector(values); 61 48 : }