https://mooseframework.inl.gov
PointValue.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 "PointValue.h"
11 
12 // MOOSE includes
13 #include "Function.h"
14 #include "MooseMesh.h"
15 #include "MooseVariable.h"
16 #include "SubProblem.h"
17 
18 #include "libmesh/system.h"
19 
20 registerMooseObject("MooseApp", PointValue);
21 
24 {
26  params.addClassDescription("Compute the value of a variable at a specified location.");
27  params.addRequiredParam<VariableName>(
28  "variable", "The name of the variable that this postprocessor operates on.");
29  params.addRequiredParam<Point>("point",
30  "The physical point where the solution will be evaluated.");
31  params.addClassDescription("Compute the value of a variable at a specified location");
32  return params;
33 }
34 
36  : GeneralPostprocessor(parameters),
37  _var_number(_subproblem
38  .getVariable(_tid,
39  parameters.get<VariableName>("variable"),
42  .number()),
43  _system(_subproblem.getSystem(getParam<VariableName>("variable"))),
44  _point(getParam<Point>("point")),
45  _value(0)
46 {
47 }
48 
49 void
51 {
53 
59  {
60  auto pl = _subproblem.mesh().getPointLocator();
61  pl->enable_out_of_mesh_mode();
62 
63  auto * elem = (*pl)(_point);
64  auto elem_id = elem ? elem->id() : libMesh::DofObject::invalid_id;
65  gatherMin(elem_id);
66 
67  if (elem_id == libMesh::DofObject::invalid_id)
68  mooseError("No element located at ", _point, " in PointValue Postprocessor named: ", name());
69  }
70 }
71 
72 Real
74 {
75  return _value;
76 }
virtual MooseMesh & mesh()=0
VarFieldType
Definition: MooseTypes.h:721
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
Definition: MooseUtils.h:380
PointValue(const InputParameters &parameters)
Definition: PointValue.C:35
static InputParameters validParams()
Definition: PointValue.C:23
Compute the value of a variable at a specified location.
Definition: PointValue.h:20
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Point & _point
The point to locate.
Definition: PointValue.h:40
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 const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
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...
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: PointValue.C:73
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:208
static InputParameters validParams()
const libMesh::System & _system
A reference to the system containing the variable.
Definition: PointValue.h:37
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:714
static const dof_id_type invalid_id
const unsigned int _var_number
The variable number of the variable we are operating on.
Definition: PointValue.h:34
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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 std::unique_ptr< libMesh::PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
Definition: MooseMesh.C:3728
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
registerMooseObject("MooseApp", PointValue)
virtual void execute() override
Execute method.
Definition: PointValue.C:50
Real _value
The value of the variable at the desired location.
Definition: PointValue.h:43