www.mooseframework.org
PointValue.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "PointValue.h"
16 
17 // MOOSE includes
18 #include "Function.h"
19 #include "MooseMesh.h"
20 #include "MooseVariable.h"
21 #include "SubProblem.h"
22 
23 #include "libmesh/system.h"
24 
25 template <>
28 {
30  params.addRequiredParam<VariableName>(
31  "variable", "The name of the variable that this postprocessor operates on.");
32  params.addRequiredParam<Point>("point",
33  "The physical point where the solution will be evaluated.");
34  return params;
35 }
36 
38  : GeneralPostprocessor(parameters),
39  _var_number(_subproblem.getVariable(_tid, parameters.get<VariableName>("variable")).number()),
40  _system(_subproblem.getSystem(getParam<VariableName>("variable"))),
41  _point(getParam<Point>("point")),
42  _value(0)
43 {
44 }
45 
46 void
48 {
49  _value = _system.point_value(_var_number, _point, false);
50 
56  {
57  auto pl = _subproblem.mesh().getPointLocator();
58  pl->enable_out_of_mesh_mode();
59 
60  auto * elem = (*pl)(_point);
61  auto elem_id = elem ? elem->id() : DofObject::invalid_id;
62  gatherMin(elem_id);
63 
64  if (elem_id == DofObject::invalid_id)
65  mooseError("No element located at ", _point, " in PointValue Postprocessor named: ", name());
66  }
67 }
68 
69 Real
71 {
72  return _value;
73 }
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
virtual MooseMesh & mesh()=0
InputParameters validParams< PointValue >()
Definition: PointValue.C:27
PointValue(const InputParameters &parameters)
Definition: PointValue.C:37
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:50
InputParameters validParams< GeneralPostprocessor >()
void gatherMin(T &value)
Definition: UserObject.h:131
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:146
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: PointValue.C:70
const unsigned int _var_number
The variable number of the variable we are operating on.
Definition: PointValue.h:44
virtual std::unique_ptr< PointLocatorBase > getPointLocator() const
Proxy function to get a (sub)PointLocator from either the underlying libMesh mesh (default)...
Definition: MooseMesh.C:2540
const System & _system
A reference to the system containing the variable.
Definition: PointValue.h:47
bool absoluteFuzzyEqual(const libMesh::Real &var1, const libMesh::Real &var2, const libMesh::Real &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual void execute() override
Execute method.
Definition: PointValue.C:47
Real _value
The value of the variable at the desired location.
Definition: PointValue.h:53