https://mooseframework.inl.gov
ScalarVariable.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 "ScalarVariable.h"
11 
12 // MOOSE includes
13 #include "MooseVariableScalar.h"
14 #include "SubProblem.h"
15 
16 #include "libmesh/dof_map.h"
17 
19 
22 {
24  params.addClassDescription("Returns the value of a scalar variable as a postprocessor value.");
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  _value(0)
35 {
36 }
37 
38 void
40 {
41 }
42 
43 void
45 {
46  _var.reinit();
48  const DofMap & dof_map = _var.dofMap();
49  const dof_id_type dof = _var.dofIndices()[_idx];
50  if (dof >= dof_map.first_dof() && dof < dof_map.end_dof())
51  _value = _var.sln()[_idx];
52 }
53 
54 Real
56 {
57  return _value;
58 }
59 
60 void
62 {
64 }
registerMooseObject("MooseApp", ScalarVariable)
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
const libMesh::DofMap & dofMap() const
The DofMap associated with the system this variable is in.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void gatherMin(T &value)
Gather the parallel min of the variable passed in.
Definition: UserObject.h:150
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...
static InputParameters validParams()
auto max(const L &left, const R &right)
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
static InputParameters validParams()
MooseVariableScalar & _var
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.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
ScalarVariable(const InputParameters &parameters)
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...
const VariableValue & sln() const
void ErrorVector unsigned int
uint8_t dof_id_type