www.mooseframework.org
PointValue.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 "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 
22 template <>
25 {
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  return params;
32 }
33 
35  : GeneralPostprocessor(parameters),
36  _var_number(_subproblem
37  .getVariable(_tid,
38  parameters.get<VariableName>("variable"),
41  .number()),
42  _system(_subproblem.getSystem(getParam<VariableName>("variable"))),
43  _point(getParam<Point>("point")),
44  _value(0)
45 {
46 }
47 
48 void
50 {
51  _value = _system.point_value(_var_number, _point, false);
52 
58  {
59  auto pl = _subproblem.mesh().getPointLocator();
60  pl->enable_out_of_mesh_mode();
61 
62  auto * elem = (*pl)(_point);
63  auto elem_id = elem ? elem->id() : DofObject::invalid_id;
64  gatherMin(elem_id);
65 
66  if (elem_id == DofObject::invalid_id)
67  mooseError("No element located at ", _point, " in PointValue Postprocessor named: ", name());
68  }
69 }
70 
71 Real
73 {
74  return _value;
75 }
virtual MooseMesh & mesh()=0
VarFieldType
Definition: MooseTypes.h:488
InputParameters validParams< PointValue >()
Definition: PointValue.C:24
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:231
PointValue(const InputParameters &parameters)
Definition: PointValue.C:34
Compute the value of a variable at a specified location.
Definition: PointValue.h:26
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:44
InputParameters validParams< GeneralPostprocessor >()
void gatherMin(T &value)
Definition: UserObject.h:115
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
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...
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:138
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: PointValue.C:72
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:481
const unsigned int _var_number
The variable number of the variable we are operating on.
Definition: PointValue.h:38
const System & _system
A reference to the system containing the variable.
Definition: PointValue.h:41
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
Definition: Moose.h:112
registerMooseObject("MooseApp", PointValue)
virtual void execute() override
Execute method.
Definition: PointValue.C:49
Real _value
The value of the variable at the desired location.
Definition: PointValue.h:47
virtual std::unique_ptr< PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
Definition: MooseMesh.C:2730