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 "MooseTypes.h" 11 : 12 : namespace StabilizationUtils 13 : { 14 : template <typename Functor> 15 : auto 16 4841348 : elementAverage(const Functor & f, const MooseArray<Real> & JxW, const MooseArray<Real> & coord) 17 : { 18 : using ret_type = decltype(f(std::declval<unsigned int>())); 19 4841348 : ret_type avg; 20 4841348 : MathUtils::mooseSetToZero(avg); 21 4841348 : Real v = 0; 22 40971124 : for (auto qp : make_range(JxW.size())) 23 : { 24 36129776 : avg += f(qp) * JxW[qp] * coord[qp]; 25 36129776 : v += JxW[qp] * coord[qp]; 26 : } 27 4841348 : avg /= v; 28 4841348 : return avg; 29 : } 30 : }