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 "NormalizationAux.h" 11 : 12 : registerMooseObject("MooseApp", NormalizationAux); 13 : 14 : InputParameters 15 14672 : NormalizationAux::validParams() 16 : { 17 14672 : InputParameters params = AuxKernel::validParams(); 18 14672 : params.addClassDescription("Normalizes a variable based on a Postprocessor value."); 19 14672 : params.addRequiredCoupledVar("source_variable", "The variable to be normalized"); 20 14672 : params.addParam<PostprocessorName>("normalization", "The postprocessor on the source"); 21 14672 : params.addParam<PostprocessorName>("shift", "The postprocessor to shift the source"); 22 14672 : params.addParam<Real>("normal_factor", 1.0, "The normalization factor"); 23 14672 : return params; 24 0 : } 25 : 26 213 : NormalizationAux::NormalizationAux(const InputParameters & parameters) 27 : : AuxKernel(parameters), 28 213 : _src(coupledValue("source_variable")), 29 213 : _pp_on_source(isParamValid("normalization") ? &getPostprocessorValue("normalization") : NULL), 30 213 : _shift(isParamValid("shift") ? &getPostprocessorValue("shift") : NULL), 31 426 : _normal_factor(getParam<Real>("normal_factor")) 32 : { 33 213 : } 34 : 35 : Real 36 308996 : NormalizationAux::computeValue() 37 : { 38 308996 : Real denominator = _pp_on_source ? *_pp_on_source : 1.0; 39 : mooseAssert(denominator != 0., "postprocessor value is zero"); 40 308996 : Real shift = _shift ? *_shift : 0.0; 41 308996 : return _src[_qp] * _normal_factor / denominator - shift; 42 : }