www.mooseframework.org
MaterialStdVectorAux.C
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
9 
10 #include "MaterialStdVectorAux.h"
11 
13 
14 template <>
17 {
18  InputParameters params = validParams<MaterialStdVectorAuxBase<>>();
19  params.addClassDescription("Extracts a component of a material type std::vector<Real> to an aux "
20  "variable. If the std::vector is not of sufficient size then zero is "
21  "returned");
22  params.addParam<unsigned int>(
23  "selected_qp",
24  "Evaluate the std::vector<Real> at this quadpoint. This only needs to be "
25  "used if you are interested in a particular quadpoint in each element: "
26  "otherwise do not include this parameter in your input file");
27  params.addParamNamesToGroup("selected_qp", "Advanced");
28  return params;
29 }
30 
32  : MaterialStdVectorAuxBase<Real>(parameters),
33  _has_selected_qp(isParamValid("selected_qp")),
34  _selected_qp(_has_selected_qp ? getParam<unsigned int>("selected_qp") : 0)
35 {
36 }
37 
38 Real
40 {
41  if (_has_selected_qp)
42  {
43  if (_selected_qp >= _q_point.size())
44  {
45  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
46  mooseError("MaterialStdVectorAux. selected_qp specified as ",
48  " but there are only ",
49  _q_point.size(),
50  " quadpoints in the element");
51  }
52 
53  return _prop[_selected_qp][_index];
54  }
55  return _prop[_qp][_index];
56 }
MaterialStdVectorAux(const InputParameters &parameters)
Class constructor.
registerMooseObject("MooseApp", MaterialStdVectorAux)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
const unsigned int _selected_qp
The std::vector will be evaluated at this quadpoint only.
InputParameters validParams< MaterialStdVectorAux >()
const MaterialProperty< std::vector< Real > > & _prop
Reference to the material property for this AuxKernel.
unsigned int _index
index of the vecor element
unsigned int size() const
The number of elements that can currently be stored in the array.
Definition: MooseArray.h:259
const bool _has_selected_qp
whether or not selected_qp has been set
virtual Real getRealValue() override
Returns material property values at quadrature points.
AuxKernel for outputting a std::vector material-property component to an AuxVariable.
unsigned int _qp
Quadrature point index.
Definition: AuxKernel.h:219
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 option parameter and a documentation string to the InputParameters object...
const MooseArray< Point > & _q_point
Dimension of the problem being solved.
Definition: AuxKernel.h:195
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
A base class for the various Material related AuxKernal objects.