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 28628 : GenericFunctionVectorMaterialTempl<is_ad>::validParams() 19 : { 20 28628 : InputParameters params = Material::validParams(); 21 28628 : params.addClassDescription("Material object for declaring vector properties that are populated " 22 : "by evaluation of Function objects."); 23 28628 : params.addParam<std::vector<std::string>>("prop_names", 24 : "The names of the properties this material will have"); 25 28628 : 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 28628 : return params; 31 0 : } 32 : 33 : template <bool is_ad> 34 76 : GenericFunctionVectorMaterialTempl<is_ad>::GenericFunctionVectorMaterialTempl( 35 : const InputParameters & parameters) 36 : : Material(parameters), 37 76 : _prop_names(getParam<std::vector<std::string>>("prop_names")), 38 152 : _prop_values(getParam<std::vector<FunctionName>>("prop_values")) 39 : { 40 76 : unsigned int num_names = _prop_names.size(); 41 76 : unsigned int num_values = _prop_values.size(); 42 : 43 76 : 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 72 : _num_props = num_names; 53 : 54 72 : _properties.resize(num_names); 55 72 : _functions.resize(num_names * LIBMESH_DIM); 56 : 57 144 : for (unsigned int i = 0; i < _num_props; i++) 58 : { 59 72 : _properties[i] = &declareGenericProperty<RealVectorValue, is_ad>(_prop_names[i]); 60 288 : for (const auto j : make_range(Moose::dim)) 61 216 : _functions[i * LIBMESH_DIM + j] = &getFunctionByName(_prop_values[i * LIBMESH_DIM + j]); 62 : } 63 72 : } 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 1634400 : GenericFunctionVectorMaterialTempl<is_ad>::computeQpProperties() 75 : { 76 1634400 : computeQpFunctions(); 77 1634400 : } 78 : 79 : template <bool is_ad> 80 : void 81 1634400 : GenericFunctionVectorMaterialTempl<is_ad>::computeQpFunctions() 82 : { 83 3268800 : for (unsigned int i = 0; i < _num_props; i++) 84 6537600 : for (const auto j : make_range(Moose::dim)) 85 4903200 : (*_properties[i])[_qp](j) = (*_functions[i * LIBMESH_DIM + j]).value(_t, _q_point[_qp]); 86 1634400 : } 87 : 88 : template class GenericFunctionVectorMaterialTempl<false>; 89 : template class GenericFunctionVectorMaterialTempl<true>;