https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FunctionNodalAverageIC.C
Go to the documentation of this file.
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
11#include "Function.h"
12
14
17{
19
21 "Initial conditions for an elemental variable from a function using nodal average.");
22
23 params.addRequiredParam<FunctionName>("function", "The initial condition function.");
24
25 return params;
26}
27
29 : InitialCondition(parameters), _func(getFunction("function"))
30{
31}
32
33Real
35{
36 const unsigned int n_nodes = _current_elem->n_nodes();
37
38 Real sum = 0.0;
39 for (unsigned int i = 0; i < n_nodes; i++)
40 {
41 const Node & node = _current_elem->node_ref(i);
42 sum += _func.value(_t, node);
43 }
44
45 return sum / n_nodes;
46}
registerMooseObject("ThermalHydraulicsApp", FunctionNodalAverageIC)
Initial conditions for an elemental variable from a function using nodal average.
FunctionNodalAverageIC(const InputParameters &parameters)
const Function & _func
function
static InputParameters validParams()
virtual Real value(const Point &p) override
virtual Real value(Real t, const Point &p) const
const Elem *const & _current_elem
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
const dof_id_type n_nodes