https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementVectorL2Error.C
Go to the documentation of this file.
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
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
66Real
71
72Real
74{
75 RealVectorValue func_val = _has_vector_function
77 : RealVectorValue(_funcx.value(_t, _q_point[_qp]),
80
81 RealVectorValue sol_val =
82 _has_vector_variable ? _u[_qp] : RealVectorValue(_ux[_qp], _uy[_qp], _uz[_qp]);
83
84 return (sol_val - func_val).norm_sq(); // dot product of difference vector
85}
registerMooseObject("MooseApp", ElementVectorL2Error)
This postprocessor computes a volume integral of the specified variable.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
const MooseArray< Point > & _q_point
This postprocessor will print out the L2-seminorm of the difference between the computed solution and...
const VariableValue & _uy
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual Real computeQpIntegral() override
const VariableValue & _uz
ElementVectorL2Error(const InputParameters &parameters)
const Function & _func
vector or component-wise analytical solution to compare against
const VariableValue & _ux
const VectorVariableValue & _u
vector or component-wise variable values
const bool _has_vector_function
whether the user chose to use a vector or component-wise solution/variable
static InputParameters validParams()
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:30
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:82
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
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 addCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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 ...
Definition MooseBase.h:457