https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
38void
42
43void
45{
46 _var.reinit();
47 _value = std::numeric_limits<Real>::max();
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
54Real
56{
57 return _value;
58}
59
60void
registerMooseObject("MooseApp", ScalarVariable)
void ErrorVector unsigned int
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
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.
virtual const std::vector< dof_id_type > & dofIndices() const
Get local DoF indices.
const libMesh::DofMap & dofMap() const
The DofMap associated with the system this variable is in.
const VariableValue & sln() const
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
static InputParameters validParams()
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
MooseVariableScalar & _var
ScalarVariable(const InputParameters &parameters)
unsigned int _idx
virtual void execute() override
Execute method.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
void gatherMin(T &value)
Gather the parallel min of the variable passed in.