www.mooseframework.org
ElementVectorL2Error.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "ElementVectorL2Error.h"
16 #include "Function.h"
17 
18 template <>
21 {
23  params.addRequiredParam<FunctionName>("function_x", "The analytic solution to compare against");
24  params.addParam<FunctionName>("function_y", 0, "The analytic solution to compare against");
25  params.addParam<FunctionName>("function_z", 0, "The analytic solution to compare against");
26  params.addRequiredCoupledVar("var_x", "The FE solution in x direction");
27  params.addCoupledVar("var_y", 0, "The FE solution in y direction");
28  params.addCoupledVar("var_z", 0, "The FE solution in z direction");
29  return params;
30 }
31 
33  : ElementIntegralPostprocessor(parameters),
34  _funcx(getFunction("function_x")),
35  _funcy(getFunction("function_y")),
36  _funcz(getFunction("function_z")),
37  _u(coupledValue("var_x")),
38  _v(coupledValue("var_y")),
39  _w(coupledValue("var_z"))
40 {
41 }
42 
43 Real
45 {
46  return std::sqrt(ElementIntegralPostprocessor::getValue());
47 }
48 
49 Real
51 {
52  RealVectorValue sol_val(0.0, 0.0, 0.0);
53  RealVectorValue func_val(0.0, 0.0, 0.0);
54 
55  sol_val(0) = _u[_qp]; // required variable
56  func_val(0) = _funcx.value(_t, _q_point[_qp]); // required function
57 
58  sol_val(1) = _v[_qp];
59  sol_val(2) = _w[_qp];
60 
61  func_val(1) = _funcy.value(_t, _q_point[_qp]);
62  func_val(2) = _funcz.value(_t, _q_point[_qp]);
63 
64  return (sol_val - func_val).norm_sq(); // dot product of difference vector
65 }
This postprocessor computes a volume integral of the specified variable.
const VariableValue & _u
virtual Real value(Real t, const Point &p)
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:43
const MooseArray< Point > & _q_point
VectorValue< Real > RealVectorValue
Definition: Assembly.h:40
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< ElementVectorL2Error >()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
const VariableValue & _w
virtual Real computeQpIntegral() override
ElementVectorL2Error(const InputParameters &parameters)
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
const VariableValue & _v
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
InputParameters validParams< ElementIntegralPostprocessor >()
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.