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 "NodalL2Norm.h" 11 : 12 : registerMooseObject("MooseApp", NodalL2Norm); 13 : 14 : InputParameters 15 14401 : NodalL2Norm::validParams() 16 : { 17 14401 : InputParameters params = NodalVariablePostprocessor::validParams(); 18 14401 : params.addClassDescription( 19 : "Computes the nodal L2-norm of the coupled variable, which is defined by summing the square " 20 : "of its value at every node and taking the square root."); 21 14401 : params.set<bool>("unique_node_execute") = true; 22 14401 : return params; 23 0 : } 24 : 25 72 : NodalL2Norm::NodalL2Norm(const InputParameters & parameters) 26 72 : : NodalVariablePostprocessor(parameters), _sum_of_squares(0.0) 27 : { 28 72 : } 29 : 30 : void 31 1564 : NodalL2Norm::initialize() 32 : { 33 1564 : _sum_of_squares = 0.0; 34 1564 : } 35 : 36 : void 37 35640 : NodalL2Norm::execute() 38 : { 39 35640 : Real val = _u[_qp]; 40 35640 : _sum_of_squares += val * val; 41 35640 : } 42 : 43 : Real 44 1454 : NodalL2Norm::getValue() const 45 : { 46 1454 : return std::sqrt(_sum_of_squares); 47 : } 48 : 49 : void 50 110 : NodalL2Norm::threadJoin(const UserObject & y) 51 : { 52 110 : const auto & pps = static_cast<const NodalL2Norm &>(y); 53 110 : _sum_of_squares += pps._sum_of_squares; 54 110 : } 55 : 56 : void 57 1454 : NodalL2Norm::finalize() 58 : { 59 1454 : gatherSum(_sum_of_squares); 60 1454 : }