www.mooseframework.org
ScalarVariable.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 "ScalarVariable.h"
11 
12 // MOOSE includes
13 #include "MooseVariableScalar.h"
14 #include "SubProblem.h"
15 
16 #include "libmesh/dof_map.h"
17 
19 
20 template <>
23 {
25  params.addRequiredParam<VariableName>("variable", "Name of the variable");
26  params.addParam<unsigned int>("component", 0, "Component to output for this variable");
27  return params;
28 }
29 
31  : GeneralPostprocessor(parameters),
32  _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
33  _idx(getParam<unsigned int>("component"))
34 {
35 }
36 
37 void
39 {
40 }
41 
42 void
44 {
45 }
46 
47 Real
49 {
50  _var.reinit();
51 
52  Real returnval = std::numeric_limits<Real>::max();
53  const DofMap & dof_map = _var.dofMap();
54  const dof_id_type dof = _var.dofIndices()[_idx];
55  if (dof >= dof_map.first_dof() && dof < dof_map.end_dof())
56  returnval = _var.sln()[_idx];
57 
58  gatherMin(returnval);
59 
60  return returnval;
61 }
registerMooseObject("MooseApp", ScalarVariable)
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:115
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...
MooseVariableScalar & _var
DofMap & dof_map
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
const DofMap & dofMap() const
The DofMap associated with the system this variable is in.
InputParameters validParams< ScalarVariable >()
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...