www.mooseframework.org
BoundsAux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "BoundsAux.h"
16 #include "SystemBase.h"
17 
18 template <>
21 {
23  params.addParam<Real>("upper", "The upper bound for the variable");
24  params.addParam<Real>("lower", "The lower bound for the variable");
25  params.addRequiredCoupledVar("bounded_variable", "The variable to be bounded");
26  return params;
27 }
28 
30  : AuxKernel(parameters),
31  _upper_vector(_nl_sys.getVector("upper_bound")),
32  _lower_vector(_nl_sys.getVector("lower_bound")),
33  _bounded_variable_id(coupled("bounded_variable"))
34 {
35  if (!isNodal())
36  mooseError("BoundsAux must be used on a nodal auxiliary variable!");
37  _upper_valid = parameters.isParamValid("upper");
38  if (_upper_valid)
39  _upper = getParam<Real>("upper");
40  _lower_valid = parameters.isParamValid("lower");
41  if (_lower_valid)
42  _lower = getParam<Real>("lower");
43 }
44 
45 Real
47 {
49  {
50  // The zero is for the component, this will only work for Lagrange variables!
51  dof_id_type dof = _current_node->dof_number(_nl_sys.number(), _bounded_variable_id, 0);
52  if (_upper_valid)
53  _upper_vector.set(dof, _upper);
54  if (_lower_valid)
55  _lower_vector.set(dof, _lower);
56  }
57 
58  return 0.0;
59 }
InputParameters validParams< BoundsAux >()
Definition: BoundsAux.C:20
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real computeValue() override
Definition: BoundsAux.C:46
Real _lower
Definition: BoundsAux.h:51
BoundsAux(const InputParameters &parameters)
Factory constructor.
Definition: BoundsAux.C:29
SystemBase & _nl_sys
Definition: AuxKernel.h:141
bool _lower_valid
Definition: BoundsAux.h:49
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.
InputParameters validParams< AuxKernel >()
Definition: AuxKernel.C:30
const Node *& _current_node
Current node (valid only for nodal kernels)
Definition: AuxKernel.h:186
bool isNodal()
Nodal or elemental kernel?
Definition: AuxKernel.h:89
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:51
NumericVector< Number > & _lower_vector
Definition: BoundsAux.h:46
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
virtual unsigned int number()
Gets the number of this system.
Definition: SystemBase.C:604
bool _upper_valid
Definition: BoundsAux.h:48
Real _upper
Definition: BoundsAux.h:50
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
unsigned int _bounded_variable_id
Definition: BoundsAux.h:47
NumericVector< Number > & _upper_vector
Definition: BoundsAux.h:45