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 "ElementL2Error.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", ElementL2Error); 14 : 15 : InputParameters 16 23965 : ElementL2Error::validParams() 17 : { 18 23965 : InputParameters params = ElementIntegralVariablePostprocessor::validParams(); 19 23965 : params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against"); 20 23965 : params.addClassDescription( 21 : "Computes L2 error between a field variable and an analytical function"); 22 23965 : return params; 23 0 : } 24 : 25 4964 : ElementL2Error::ElementL2Error(const InputParameters & parameters) 26 4964 : : ElementIntegralVariablePostprocessor(parameters), _func(getFunction("function")) 27 : { 28 4964 : } 29 : 30 : Real 31 19220 : ElementL2Error::getValue() const 32 : { 33 19220 : return std::sqrt(ElementIntegralPostprocessor::getValue()); 34 : } 35 : 36 : Real 37 9147269 : ElementL2Error::computeQpIntegral() 38 : { 39 9147269 : Real diff = _u[_qp] - _func.value(_t, _q_point[_qp]); 40 9147269 : return diff * diff; 41 : }