https://mooseframework.inl.gov
FunctionElementLoopIntegralUserObject.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 "Assembly.h"
12 #include "Function.h"
13 
15 
18 {
20 
21  params.addClassDescription("Computes the integral of a function using an element loop.");
22 
23  params.addRequiredParam<FunctionName>("function", "Function to integrate.");
24 
25  return params;
26 }
27 
29  const InputParameters & parameters)
30  : ElementLoopUserObject(parameters),
31 
32  _function(getFunction("function")),
33  _qp(0),
34  _integral_value(0)
35 {
36 }
37 
38 void
40 {
41  _integral_value = 0;
42 }
43 
44 void
46 {
49 }
50 
51 void
53 {
54  const auto & uo = static_cast<const FunctionElementLoopIntegralUserObject &>(y);
55  _integral_value += uo._integral_value;
56 }
57 
58 void
60 {
62 }
63 
64 Real
66 {
67  Real sum = 0;
68  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
69  sum += _JxW[_qp] * _coord[_qp] * computeQpIntegral();
70  return sum;
71 }
72 
73 Real
75 {
76  return _function.value(_t, _q_point[_qp]);
77 }
78 
79 Real
81 {
82  return _integral_value;
83 }
Assembly & _assembly
virtual Real computeIntegral()
Computes integral on an element.
const MooseArray< Real > & _JxW
A base class that loops over elements and do things.
const MooseArray< Point > & _q_point
virtual Real computeQpIntegral()
Computes value of integrand at quadrature point.
const std::vector< double > y
FunctionElementLoopIntegralUserObject(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Computes the integral of a function using an element loop.
static InputParameters validParams()
void reinit(const Elem *elem)
const MooseArray< Real > & _coord
void gatherSum(T &value)
registerMooseObject("ThermalHydraulicsApp", FunctionElementLoopIntegralUserObject)
virtual Real getValue() const
Returns the integral value.
const QBase *const & _qrule
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void threadJoin(const UserObject &y) override
const Function & _function
Function to integrate.
void addClassDescription(const std::string &doc_string)
virtual Real value(Real t, const Point &p) const