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 "NodalSum.h" 11 : #include "MooseMesh.h" 12 : #include "SubProblem.h" 13 : 14 : registerMooseObject("MooseApp", NodalSum); 15 : 16 : InputParameters 17 14441 : NodalSum::validParams() 18 : { 19 14441 : InputParameters params = NodalVariablePostprocessor::validParams(); 20 14441 : params.set<bool>("unique_node_execute") = true; 21 : 22 14441 : params.addClassDescription("Computes the sum of all of the nodal values of the specified " 23 : "variable. Note: This object sets the default \"unique_node_execute\" " 24 : "flag to true to avoid double counting nodes between shared blocks."); 25 14441 : return params; 26 0 : } 27 : 28 88 : NodalSum::NodalSum(const InputParameters & parameters) 29 88 : : NodalVariablePostprocessor(parameters), _sum(0) 30 : { 31 88 : } 32 : 33 : void 34 348 : NodalSum::initialize() 35 : { 36 348 : _sum = 0; 37 348 : } 38 : 39 : void 40 1248 : NodalSum::execute() 41 : { 42 1248 : _sum += _u[_qp]; 43 1248 : } 44 : 45 : Real 46 319 : NodalSum::getValue() const 47 : { 48 319 : return _sum; 49 : } 50 : 51 : void 52 319 : NodalSum::finalize() 53 : { 54 319 : gatherSum(_sum); 55 319 : } 56 : 57 : void 58 29 : NodalSum::threadJoin(const UserObject & y) 59 : { 60 29 : const auto & pps = static_cast<const NodalSum &>(y); 61 29 : _sum += pps._sum; 62 29 : }