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 "GenericFunctionVectorMaterial.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", GenericFunctionVectorMaterial); 14 : registerMooseObject("MooseApp", ADGenericFunctionVectorMaterial); 15 : 16 : template <bool is_ad> 17 : InputParameters 18 28632 : GenericFunctionVectorMaterialTempl<is_ad>::validParams() 19 : { 20 28632 : InputParameters params = Material::validParams(); 21 28632 : params.addClassDescription("Material object for declaring vector properties that are populated " 22 : "by evaluation of Function objects."); 23 28632 : params.addParam<std::vector<std::string>>("prop_names", 24 : "The names of the properties this material will have"); 25 28632 : params.addParam<std::vector<FunctionName>>("prop_values", 26 : "The corresponding names of the " 27 : "functions that are going to provide " 28 : "the values for the variables, " 29 : "minor ordering by component"); 30 28632 : return params; 31 0 : } 32 : 33 : template <bool is_ad> 34 79 : GenericFunctionVectorMaterialTempl<is_ad>::GenericFunctionVectorMaterialTempl( 35 : const InputParameters & parameters) 36 : : Material(parameters), 37 79 : _prop_names(getParam<std::vector<std::string>>("prop_names")), 38 158 : _prop_values(getParam<std::vector<FunctionName>>("prop_values")) 39 : { 40 79 : unsigned int num_names = _prop_names.size(); 41 79 : unsigned int num_values = _prop_values.size(); 42 : 43 79 : if (num_names * LIBMESH_DIM != num_values) 44 4 : mooseError("Number of prop_names (", 45 : num_names, 46 : ") times the libmesh dimension (", 47 4 : LIBMESH_DIM, 48 : ") must match the number of prop_values (", 49 : num_values, 50 : ") for a GenericFunctionVectorMaterial!"); 51 : 52 75 : _num_props = num_names; 53 : 54 75 : _properties.resize(num_names); 55 75 : _functions.resize(num_names * LIBMESH_DIM); 56 : 57 150 : for (unsigned int i = 0; i < _num_props; i++) 58 : { 59 75 : _properties[i] = &declareGenericProperty<RealVectorValue, is_ad>(_prop_names[i]); 60 300 : for (const auto j : make_range(Moose::dim)) 61 225 : _functions[i * LIBMESH_DIM + j] = &getFunctionByName(_prop_values[i * LIBMESH_DIM + j]); 62 : } 63 75 : } 64 : 65 : template <bool is_ad> 66 : void 67 0 : GenericFunctionVectorMaterialTempl<is_ad>::initQpStatefulProperties() 68 : { 69 0 : computeQpFunctions(); 70 0 : } 71 : 72 : template <bool is_ad> 73 : void 74 1752800 : GenericFunctionVectorMaterialTempl<is_ad>::computeQpProperties() 75 : { 76 1752800 : computeQpFunctions(); 77 1752800 : } 78 : 79 : template <bool is_ad> 80 : void 81 1752800 : GenericFunctionVectorMaterialTempl<is_ad>::computeQpFunctions() 82 : { 83 3505600 : for (unsigned int i = 0; i < _num_props; i++) 84 7011200 : for (const auto j : make_range(Moose::dim)) 85 5258400 : (*_properties[i])[_qp](j) = (*_functions[i * LIBMESH_DIM + j]).value(_t, _q_point[_qp]); 86 1752800 : } 87 : 88 : template class GenericFunctionVectorMaterialTempl<false>; 89 : template class GenericFunctionVectorMaterialTempl<true>;