www.mooseframework.org
NormalizationAux.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 "NormalizationAux.h"
11 
13 
16 {
18  params.addClassDescription("Normalizes a variable based on a Postprocessor value.");
19  params.addRequiredCoupledVar("source_variable", "The variable to be normalized");
20  params.addParam<PostprocessorName>("normalization", "The postprocessor on the source");
21  params.addParam<PostprocessorName>("shift", "The postprocessor to shift the source");
22  params.addParam<Real>("normal_factor", 1.0, "The normalization factor");
23  return params;
24 }
25 
27  : AuxKernel(parameters),
28  _src(coupledValue("source_variable")),
29  _pp_on_source(isParamValid("normalization") ? &getPostprocessorValue("normalization") : NULL),
30  _shift(isParamValid("shift") ? &getPostprocessorValue("shift") : NULL),
31  _normal_factor(getParam<Real>("normal_factor"))
32 {
33 }
34 
35 Real
37 {
38  Real denominator = _pp_on_source ? *_pp_on_source : 1.0;
39  mooseAssert(denominator != 0., "postprocessor value is zero");
40  Real shift = _shift ? *_shift : 0.0;
41  return _src[_qp] * _normal_factor / denominator - shift;
42 }
registerMooseObject("MooseApp", NormalizationAux)
virtual Real computeValue() override
Compute and return the value of the aux variable.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VariableValue & _src
const Real *const _shift
This auxiliary kernel normalizes a variable based on a postprocessor.
void addRequiredCoupledVar(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 Real *const _pp_on_source
NormalizationAux(const InputParameters &parameters)
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:230
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...
static InputParameters validParams()
Definition: AuxKernel.C:27