www.mooseframework.org
ElementVectorL2Error.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "ElementVectorL2Error.h"
11 #include "Function.h"
12 
14 
17 {
19  params.addClassDescription("Returns the L2-norm of the difference between a pair of computed "
20  "and analytical vector-valued solutions.");
21  params.addParam<FunctionName>("function", 0, "The vector analytical solution to compare against");
22  params.addParam<FunctionName>(
23  "function_x", 0, "The analytical solution to compare against in the x direction");
24  params.addParam<FunctionName>(
25  "function_y", 0, "The analytical solution to compare against in the y direction");
26  params.addParam<FunctionName>(
27  "function_z", 0, "The analytical solution to compare against in the z direction");
28  params.addCoupledVar("variable", {0, 0, 0}, "The vector FE solution");
29  params.addCoupledVar("var_x", 0, "The FE solution in the x direction");
30  params.addCoupledVar("var_y", 0, "The FE solution in the y direction");
31  params.addCoupledVar("var_z", 0, "The FE solution in the z direction");
32  return params;
33 }
34 
36  : ElementIntegralPostprocessor(parameters),
37  _func(getFunction("function")),
38  _funcx(getFunction("function_x")),
39  _funcy(getFunction("function_y")),
40  _funcz(getFunction("function_z")),
41  _u(coupledVectorValue("variable")),
42  _ux(coupledValue("var_x")),
43  _uy(coupledValue("var_y")),
44  _uz(coupledValue("var_z")),
45  _has_vector_function(isParamSetByUser("function")),
46  _has_scalar_function(isParamSetByUser("function_x") || isParamSetByUser("function_y") ||
47  isParamSetByUser("function_z")),
48  _has_vector_variable(isParamSetByUser("variable")),
49  _has_scalar_variable(isParamSetByUser("var_x") || isParamSetByUser("var_y") ||
50  isParamSetByUser("var_z"))
51 {
53  paramError("function",
54  "The 'function' and 'function_{x,y,z}' parameters cannot both be unset.");
55 
57  paramError("function", "The 'function' and 'function_{x,y,z}' parameters cannot both be set.");
58 
60  paramError("variable", "The 'variable' and 'var_{x,y,z}' parameters cannot both be unset.");
61 
63  paramError("variable", "The 'variable' and 'var_{x,y,z}' parameters cannot both be set.");
64 }
65 
66 Real
68 {
70 }
71 
72 Real
74 {
80 
81  RealVectorValue sol_val =
83 
84  return (sol_val - func_val).norm_sq(); // dot product of difference vector
85 }
This postprocessor computes a volume integral of the specified variable.
const VectorVariableValue & _u
vector or component-wise variable values
const MooseArray< Point > & _q_point
This postprocessor will print out the L2-seminorm of the difference between the computed solution and...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
const VariableValue & _ux
registerMooseObject("MooseApp", ElementVectorL2Error)
const VariableValue & _uy
virtual Real computeQpIntegral() override
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
ElementVectorL2Error(const InputParameters &parameters)
const bool _has_vector_function
whether the user chose to use a vector or component-wise solution/variable
void addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const VariableValue & _uz
virtual RealVectorValue vectorValue(Real t, const Point &p) const
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
Definition: Function.C:87
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
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...
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:41
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
const Function & _func
vector or component-wise analytical solution to compare against