https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalVariableValue.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 "NodalVariableValue.h"
11
12// MOOSE includes
13#include "MooseMesh.h"
14#include "MooseVariable.h"
15#include "SubProblem.h"
16
17#include "libmesh/node.h"
18
20
23{
25 params.addRequiredParam<VariableName>("variable", "The variable to be monitored");
26 params.addRequiredParam<unsigned int>("nodeid", "The ID of the node where we monitor");
27 params.addParam<Real>("scale_factor", 1, "A scale factor to be applied to the variable");
28 params.addClassDescription("Outputs values of a nodal variable at a particular location");
29 return params;
30}
31
33 : GeneralPostprocessor(parameters),
34 _mesh(_subproblem.mesh()),
35 _var_name(parameters.get<VariableName>("variable")),
36 _node_ptr(nullptr),
37 _scale_factor(getParam<Real>("scale_factor")),
38 _value(0)
39{
40 // This class may be too dangerous to use if renumbering is enabled,
41 // as the nodeid parameter obviously depends on a particular
42 // numbering.
43 if (_mesh.getMesh().allow_renumbering())
44 mooseError("NodalVariableValue should only be used when node renumbering is disabled.");
45}
46
47void
49{
50 _node_ptr = _mesh.getMesh().query_node_ptr(getParam<unsigned int>("nodeid"));
51 bool found_node_ptr = _node_ptr;
52 _communicator.max(found_node_ptr);
53
54 if (!found_node_ptr)
55 mooseError("Node #",
56 getParam<unsigned int>("nodeid"),
57 " specified in '",
58 name(),
59 "' not found in the mesh!");
60}
61
62void
70
71Real
76
77void
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", NodalVariableValue)
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
DofValue getNodalValue(const Node &node) const
Get the value of this variable at given node.
Sums a nodal value across all processors and multiplies the result by a scale factor.
NodalVariableValue(const InputParameters &parameters)
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
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...
static InputParameters validParams()
void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name)=0
Returns the variable reference for requested MooseVariable which may be in any system.
void max(const T &r, T &o, Request &req) const
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
const THREAD_ID _tid
Thread ID of this postprocessor.
const Parallel::Communicator & _communicator
processor_id_type processor_id() const
MeshBase & mesh