https://mooseframework.inl.gov
CopyValueAux.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 
10 #include "CopyValueAux.h"
11 #include "SystemBase.h"
12 
14 
17 {
19  params.addClassDescription("Returns the specified variable as an auxiliary variable with a "
20  "simple copy of the variable values.");
21  params.addRequiredCoupledVar("source", "Variable to take the value of.");
22  MooseEnum stateEnum("CURRENT=0 OLD=1 OLDER=2", "CURRENT");
23  params.addParam<MooseEnum>(
24  "state",
25  stateEnum,
26  "This parameter specifies the state being copied. CURRENT=0 OLD=1 OLDER=2. Copying an older "
27  "state allows access to previous solution information if necessary.");
28  return params;
29 }
30 
32  : AuxKernel(parameters),
33  _state(getParam<MooseEnum>("state")),
34  _v(_state == 0 ? coupledValue("source")
35  : _state == 1 ? coupledValueOld("source")
36  : coupledValueOlder("source")),
37  _source_variable(*getVar("source", 0))
38 {
40  paramError("variable",
41  "Source (" + Moose::stringify(_source_variable.feType().family) + ") and target (" +
43  ") variable have different families. You may use a ProjectionAux "
44  "instead of the CopyValueAux");
46  paramError("variable",
47  "Source (" + Moose::stringify(_source_variable.feType().order) + ") and target (" +
49  ") variable are of different orders. You may use a ProjectionAux "
50  "instead of the CopyValueAux");
51 }
52 
53 Real
55 {
56  return _v[_qp];
57 }
CopyValueAux(const InputParameters &parameters)
Definition: CopyValueAux.C:31
const libMesh::FEType & feType() const
Get the type of finite element object.
virtual Real computeValue() override
Compute and return the value of the aux variable.
Definition: CopyValueAux.C:54
const VariableValue & _v
The variable to project from.
Definition: CopyValueAux.h:31
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MooseVariable & _source_variable
A reference to the variable to project from.
Definition: CopyValueAux.h:34
OrderWrapper order
registerMooseObject("MooseApp", CopyValueAux)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
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 ...
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:174
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Copies one variable onto an auxiliary variable.
Definition: CopyValueAux.h:17
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 optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
Definition: AuxKernel.C:27
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
Definition: AuxKernel.h:36
static InputParameters validParams()
Definition: CopyValueAux.C:16