www.mooseframework.org
ScalarVariable.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 "ScalarVariable.h"
16 
17 // MOOSE includes
18 #include "MooseVariableScalar.h"
19 #include "SubProblem.h"
20 
21 #include "libmesh/dof_map.h"
22 
23 template <>
26 {
28  params.addRequiredParam<VariableName>("variable", "Name of the variable");
29  params.addParam<unsigned int>("component", 0, "Component to output for this variable");
30  return params;
31 }
32 
34  : GeneralPostprocessor(parameters),
35  _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
36  _idx(getParam<unsigned int>("component"))
37 {
38 }
39 
40 void
42 {
43 }
44 
45 void
47 {
48 }
49 
50 Real
52 {
53  _var.reinit();
54 
55  Real returnval = std::numeric_limits<Real>::max();
56  const DofMap & dof_map = _var.dofMap();
57  const dof_id_type dof = _var.dofIndices()[_idx];
58  if (dof >= dof_map.first_dof() && dof < dof_map.end_dof())
59  returnval = _var.sln()[_idx];
60 
61  gatherMin(returnval);
62 
63  return returnval;
64 }
VariableValue & sln()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
void gatherMin(T &value)
Definition: UserObject.h:131
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
virtual void execute() override
Execute method.
unsigned int _idx
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...
const DofMap & dofMap() const
The DofMap associated with the system this variable is in.
MooseVariableScalar & _var
DofMap & dof_map
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
InputParameters validParams< ScalarVariable >()
std::vector< dof_id_type > & dofIndices()
ScalarVariable(const InputParameters &parameters)
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...