https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementUOAux.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 "ElementUOAux.h"
11#include "ElementUOProvider.h"
12
14
17{
19 params.addRequiredParam<UserObjectName>("element_user_object",
20 "The ElementUOProvider where this Aux pulls values from");
21
22 params.addParam<std::string>("field_name",
23 "The field name to retrieve from the ElementUOProvider");
24
25 MooseEnum field_type("long Real", "long");
26 params.addParam<MooseEnum>("field_type", field_type, "The type of field to retrieve");
27
28 params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_BEGIN;
29 params.addClassDescription("Aux Kernel to display generic spatial (elemental) information from a "
30 "UserObject that satisfies the underlying ElementUOProvider "
31 "interface.");
32 return params;
33}
34
36 : AuxKernel(params),
37 // doco-get-user-object-begin
38 _elem_uo(getUserObject<ElementUOProvider>("element_user_object")),
39 // doco-get-user-object-end
40 _field_name(isParamValid("field_name") ? getParam<std::string>("field_name") : "default"),
41 _field_type(getParam<MooseEnum>("field_type"))
42{
43 if (isNodal())
44 mooseError("This AuxKernel only supports Elemental fields");
45}
46
47Real
49{
50 if (_field_type == "long")
51 {
53 if (value == std::numeric_limits<unsigned long>::max())
54 return -1.0;
55 else
56 return value;
57 }
58 else
60}
registerMooseObject("MooseApp", ElementUOAux)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ExecFlagType EXEC_TIMESTEP_BEGIN
Definition Moose.C:37
bool isNodal() const
Nodal or elemental kernel?
Definition AuxKernel.h:43
const Elem *const & _current_elem
Current element (valid only for elemental kernels)
Definition AuxKernel.h:133
static InputParameters validParams()
Definition AuxKernel.C:27
This AuxKernel retrieves values from a ElementUOProvider derived class and returns the reported spati...
const std::string _field_type
const ElementUOProvider & _elem_uo
ElementUOAux(const InputParameters &params)
virtual Real computeValue() override
Compute and return the value of the aux variable.
static InputParameters validParams()
const std::string _field_name
User object intermediate base class that declares an interface for providing generic fields by name.
virtual Real getElementalValueReal(dof_id_type, const std::string &) const
virtual unsigned long getElementalValueLong(dof_id_type, const std::string &) const
A MultiMooseEnum object to hold "execute_on" flags.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
virtual const OutputTools< T >::VariableValue & value()
The value of the variable this object is operating on.