https://mooseframework.inl.gov
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 
10 #include "FunctionNodalAverageIC.h"
11 #include "Function.h"
12 
13 registerMooseObject("ThermalHydraulicsApp", FunctionNodalAverageIC);
14 
17 {
19 
20  params.addClassDescription(
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 
33 Real
34 FunctionNodalAverageIC::value(const Point & /*p*/)
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 }
const Function & _func
function
virtual Real value(const Point &p) override
Initial conditions for an elemental variable from a function using nodal average. ...
static InputParameters validParams()
static InputParameters validParams()
registerMooseObject("ThermalHydraulicsApp", FunctionNodalAverageIC)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const dof_id_type n_nodes
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
FunctionNodalAverageIC(const InputParameters &parameters)
const Elem *const & _current_elem
virtual Real value(Real t, const Point &p) const