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 "ElementL2Difference.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", ElementL2Difference); 14 : 15 : InputParameters 16 21849 : ElementL2Difference::validParams() 17 : { 18 21849 : InputParameters params = ElementIntegralVariablePostprocessor::validParams(); 19 21849 : params.addRequiredCoupledVar("other_variable", "The variable to compare to"); 20 : 21 21849 : params.addClassDescription("Computes the element-wise L2 difference between the current variable " 22 : "and a coupled variable."); 23 21849 : return params; 24 0 : } 25 : 26 3944 : ElementL2Difference::ElementL2Difference(const InputParameters & parameters) 27 3944 : : ElementIntegralVariablePostprocessor(parameters), _other_var(coupledValue("other_variable")) 28 : { 29 3944 : } 30 : 31 : Real 32 3336 : ElementL2Difference::getValue() const 33 : { 34 3336 : return std::sqrt(ElementIntegralPostprocessor::getValue()); 35 : } 36 : 37 : Real 38 4606208 : ElementL2Difference::computeQpIntegral() 39 : { 40 4606208 : Real diff = _u[_qp] - _other_var[_qp]; 41 4606208 : return diff * diff; 42 : }