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 14481 : AverageNodalVariableValue::validParams() 18 : { 19 14481 : InputParameters params = NodalVariablePostprocessor::validParams(); 20 : 21 14481 : params.addClassDescription("Computes the average value of a field by sampling all nodal " 22 : "solutions on the domain or within a subdomain"); 23 14481 : return params; 24 0 : } 25 : 26 112 : AverageNodalVariableValue::AverageNodalVariableValue(const InputParameters & parameters) 27 112 : : NodalVariablePostprocessor(parameters), _sum(0), _n(0) 28 : { 29 112 : } 30 : 31 : // doco-init-start 32 : void 33 722 : AverageNodalVariableValue::initialize() 34 : { 35 722 : _sum = 0; 36 722 : _n = 0; 37 722 : } 38 : // doco-init-end 39 : 40 : // doco-execute-get-start 41 : void 42 7394 : AverageNodalVariableValue::execute() 43 : { 44 7394 : _sum += _u[_qp]; 45 7394 : _n++; 46 7394 : } 47 : 48 : Real 49 667 : AverageNodalVariableValue::getValue() const 50 : { 51 667 : return _sum / _n; 52 : } 53 : // doco-execute-get-end 54 : 55 : // doco-final-start 56 : void 57 667 : AverageNodalVariableValue::finalize() 58 : { 59 667 : gatherSum(_sum); 60 667 : gatherSum(_n); 61 667 : } 62 : // doco-final-end 63 : 64 : // doco-thread-start 65 : void 66 55 : AverageNodalVariableValue::threadJoin(const UserObject & y) 67 : { 68 55 : const auto & pps = static_cast<const AverageNodalVariableValue &>(y); 69 55 : _sum += pps._sum; 70 55 : _n += pps._n; 71 55 : } 72 : // doco-thread-end