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 "ArrayFunctionIC.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", ArrayFunctionIC); 14 : 15 : InputParameters 16 15265 : ArrayFunctionIC::validParams() 17 : { 18 15265 : InputParameters params = ArrayInitialCondition::validParams(); 19 15265 : params.addRequiredParam<std::vector<FunctionName>>("function", 20 : "The initial condition functions."); 21 15265 : params.addClassDescription("An initial condition that uses a normal function of x, y, z to " 22 : "produce values (and optionally gradients) for a field variable."); 23 15265 : return params; 24 0 : } 25 : 26 536 : ArrayFunctionIC::ArrayFunctionIC(const InputParameters & parameters) 27 536 : : ArrayInitialCondition(parameters) 28 : { 29 536 : auto & funcs = getParam<std::vector<FunctionName>>("function"); 30 536 : if (_var.count() != funcs.size()) 31 4 : mooseError("Number of functions does not agree with the number of array variable components"); 32 1596 : for (auto & func : funcs) 33 1064 : _func.push_back(&getFunctionByName(func)); 34 532 : } 35 : 36 : RealEigenVector 37 78460 : ArrayFunctionIC::value(const Point & p) 38 : { 39 78460 : RealEigenVector v(_var.count()); 40 235380 : for (unsigned int i = 0; i < _var.count(); ++i) 41 156920 : v(i) = _func[i]->value(_t, p); 42 78460 : return v; 43 0 : } 44 : 45 : RealVectorArrayValue 46 0 : ArrayFunctionIC::gradient(const Point & p) 47 : { 48 0 : RealVectorArrayValue v(_var.count(), LIBMESH_DIM); 49 0 : for (unsigned int i = 0; i < _var.count(); ++i) 50 : { 51 0 : auto gd = _func[i]->gradient(_t, p); 52 0 : for (const auto j : make_range(Moose::dim)) 53 0 : v(i, j) = gd(j); 54 : } 55 0 : return v; 56 0 : }