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
10 #include "BoundsAux.h"
11 #include "SystemBase.h"
13 registerMooseObject("MooseApp", BoundsAux);
15 template <>
18 {
20  params.addParam<Real>("upper", "The upper bound for the variable");
21  params.addParam<Real>("lower", "The lower bound for the variable");
22  params.addRequiredCoupledVar("bounded_variable", "The variable to be bounded");
23  return params;
24 }
27  : AuxKernel(parameters),
28  _upper_vector(_nl_sys.getVector("upper_bound")),
29  _lower_vector(_nl_sys.getVector("lower_bound")),
30  _bounded_variable_id(coupled("bounded_variable"))
31 {
32  if (!isNodal())
33  mooseError("BoundsAux must be used on a nodal auxiliary variable!");
35  if (_upper_valid)
36  _upper = getParam<Real>("upper");
38  if (_lower_valid)
39  _lower = getParam<Real>("lower");
40 }
42 Real
44 {
46  {
47  // The zero is for the component, this will only work for Lagrange variables!
48  dof_id_type dof = _current_node->dof_number(_nl_sys.number(), _bounded_variable_id, 0);
49  if (_upper_valid)
50  _upper_vector.set(dof, _upper);
51  if (_lower_valid)
52  _lower_vector.set(dof, _lower);
53  }
55  return 0.0;
56 }
const Node *const & _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:213
InputParameters validParams< BoundsAux >()
Definition: BoundsAux.C:17
Fills in the "bounds vectors" to provide an upper and lower bound for the variable that is coupled in...
Definition: BoundsAux.h:28
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: BoundsAux.C:43
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Real _lower
Definition: BoundsAux.h:45
BoundsAux(const InputParameters &parameters)
Factory constructor.
Definition: BoundsAux.C:26
bool _lower_valid
Definition: BoundsAux.h:43
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:65
SystemBase & _nl_sys
Definition: AuxKernel.h:160
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:25
bool isNodal()
Nodal or elemental kernel?
Definition: AuxKernel.h:84
virtual unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:926
NumericVector< Number > & _lower_vector
Definition: BoundsAux.h:40
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
bool _upper_valid
Definition: BoundsAux.h:42
Real _upper
Definition: BoundsAux.h:44
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...
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:33
unsigned int _bounded_variable_id
Definition: BoundsAux.h:41
NumericVector< Number > & _upper_vector
Definition: BoundsAux.h:39
registerMooseObject("MooseApp", BoundsAux)
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.