LCOV - code coverage report
Current view: top level - src/userobjects - ElementIntegralUserObject.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 19 28 67.9 %
Date: 2025-07-17 01:28:37 Functions: 5 8 62.5 %
Legend: Lines: hit not hit

          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             : // MOOSE includes
      11             : #include "ElementIntegralUserObject.h"
      12             : 
      13             : #include "libmesh/quadrature.h"
      14             : 
      15             : InputParameters
      16      207946 : ElementIntegralUserObject::validParams()
      17             : {
      18      207946 :   InputParameters params = ElementUserObject::validParams();
      19      207946 :   params.addClassDescription("Performs a spatial integration");
      20      207946 :   return params;
      21           0 : }
      22             : 
      23        4176 : ElementIntegralUserObject::ElementIntegralUserObject(const InputParameters & parameters)
      24        4176 :   : ElementUserObject(parameters), _qp(0), _integral_value(0)
      25             : {
      26        4176 : }
      27             : 
      28             : void
      29        6027 : ElementIntegralUserObject::initialize()
      30             : {
      31        6027 :   _integral_value = 0;
      32        6027 : }
      33             : 
      34             : void
      35           0 : ElementIntegralUserObject::execute()
      36             : {
      37           0 :   _integral_value += computeIntegral();
      38           0 : }
      39             : 
      40             : void
      41           0 : ElementIntegralUserObject::finalize()
      42             : {
      43           0 :   gatherSum(_integral_value);
      44           0 : }
      45             : 
      46             : Real
      47           0 : ElementIntegralUserObject::getValue() const
      48             : {
      49           0 :   return _integral_value;
      50             : }
      51             : 
      52             : void
      53         515 : ElementIntegralUserObject::threadJoin(const UserObject & y)
      54             : {
      55         515 :   const auto & pps = static_cast<const ElementIntegralUserObject &>(y);
      56         515 :   _integral_value += pps._integral_value;
      57         515 : }
      58             : 
      59             : Real
      60      522170 : ElementIntegralUserObject::computeIntegral()
      61             : {
      62      522170 :   Real sum = 0;
      63             : 
      64     3753254 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      65     3231084 :     sum += _JxW[_qp] * _coord[_qp] * computeQpIntegral();
      66      522170 :   return sum;
      67             : }

Generated by: LCOV version 1.14