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