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 "FunctionNodalAverageIC.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("ThermalHydraulicsApp", FunctionNodalAverageIC); 14 : 15 : InputParameters 16 2788 : FunctionNodalAverageIC::validParams() 17 : { 18 2788 : InputParameters params = InitialCondition::validParams(); 19 : 20 2788 : params.addClassDescription( 21 : "Initial conditions for an elemental variable from a function using nodal average."); 22 : 23 5576 : params.addRequiredParam<FunctionName>("function", "The initial condition function."); 24 : 25 2788 : return params; 26 0 : } 27 : 28 1523 : FunctionNodalAverageIC::FunctionNodalAverageIC(const InputParameters & parameters) 29 1523 : : InitialCondition(parameters), _func(getFunction("function")) 30 : { 31 1523 : } 32 : 33 : Real 34 9062 : FunctionNodalAverageIC::value(const Point & /*p*/) 35 : { 36 9062 : const unsigned int n_nodes = _current_elem->n_nodes(); 37 : 38 : Real sum = 0.0; 39 27186 : for (unsigned int i = 0; i < n_nodes; i++) 40 : { 41 18124 : const Node & node = _current_elem->node_ref(i); 42 18124 : sum += _func.value(_t, node); 43 : } 44 : 45 9062 : return sum / n_nodes; 46 : }