Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 2432706 : elementAverage(const Functor & f, const MooseArray<Real> & JxW, const MooseArray<Real> & coord) 17 : { 18 : using ret_type = decltype(f(std::declval<unsigned int>())); 19 2432706 : ret_type avg; 20 2432706 : MathUtils::mooseSetToZero(avg); 21 2432706 : Real v = 0; 22 20579522 : for (auto qp : make_range(JxW.size())) 23 : { 24 18146816 : avg += f(qp) * JxW[qp] * coord[qp]; 25 18146816 : v += JxW[qp] * coord[qp]; 26 : } 27 2432706 : avg /= v; 28 2432706 : return avg; 29 : } 30 : }