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