LCOV - code coverage report
Current view: top level - src/postprocessors - AverageNodalVariableValue.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 1f9d31 Lines: 26 27 96.3 %
Date: 2025-09-02 20:01:20 Functions: 7 7 100.0 %
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             : #include "AverageNodalVariableValue.h"
      11             : #include "MooseMesh.h"
      12             : #include "SubProblem.h"
      13             : 
      14             : registerMooseObject("MooseApp", AverageNodalVariableValue);
      15             : 
      16             : InputParameters
      17       14562 : AverageNodalVariableValue::validParams()
      18             : {
      19       14562 :   InputParameters params = NodalVariablePostprocessor::validParams();
      20             : 
      21       14562 :   params.addClassDescription("Computes the average value of a field by sampling all nodal "
      22             :                              "solutions on the domain or within a subdomain");
      23       14562 :   return params;
      24           0 : }
      25             : 
      26         154 : AverageNodalVariableValue::AverageNodalVariableValue(const InputParameters & parameters)
      27         154 :   : NodalVariablePostprocessor(parameters), _sum(0), _n(0)
      28             : {
      29         154 : }
      30             : 
      31             : // doco-init-start
      32             : void
      33         931 : AverageNodalVariableValue::initialize()
      34             : {
      35         931 :   _sum = 0;
      36         931 :   _n = 0;
      37         931 : }
      38             : // doco-init-end
      39             : 
      40             : // doco-execute-get-start
      41             : void
      42        9826 : AverageNodalVariableValue::execute()
      43             : {
      44        9826 :   _sum += _u[_qp];
      45        9826 :   _n++;
      46        9826 : }
      47             : 
      48             : Real
      49         860 : AverageNodalVariableValue::getValue() const
      50             : {
      51         860 :   return _sum / _n;
      52             : }
      53             : // doco-execute-get-end
      54             : 
      55             : // doco-final-start
      56             : void
      57         860 : AverageNodalVariableValue::finalize()
      58             : {
      59         860 :   gatherSum(_sum);
      60         860 :   gatherSum(_n);
      61         860 : }
      62             : // doco-final-end
      63             : 
      64             : // doco-thread-start
      65             : void
      66          71 : AverageNodalVariableValue::threadJoin(const UserObject & y)
      67             : {
      68          71 :   const auto & pps = static_cast<const AverageNodalVariableValue &>(y);
      69          71 :   _sum += pps._sum;
      70          71 :   _n += pps._n;
      71          71 : }
      72             : // doco-thread-end

Generated by: LCOV version 1.14