https://mooseframework.inl.gov
StabilizationUtils.h
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 "MooseTypes.h"
11 
13 {
14 template <typename Functor>
15 auto
16 elementAverage(const Functor & f, const MooseArray<Real> & JxW, const MooseArray<Real> & coord)
17 {
18  using ret_type = decltype(f(std::declval<unsigned int>()));
19  ret_type avg;
21  Real v = 0;
22  for (auto qp : make_range(JxW.size()))
23  {
24  avg += f(qp) * JxW[qp] * coord[qp];
25  v += JxW[qp] * coord[qp];
26  }
27  avg /= v;
28  return avg;
29 }
30 }
void mooseSetToZero(T &v)
unsigned int size() const
FunctorEnvelope< T > Functor
Real f(Real x)
Test function for Brents method.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
IntRange< T > make_range(T beg, T end)
auto elementAverage(const Functor &f, const MooseArray< Real > &JxW, const MooseArray< Real > &coord)