https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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"),
40 Moose::VarKindType::VAR_ANY,
41 Moose::VarFieldType::VAR_FIELD_STANDARD)
42 .number()),
43 _system(_subproblem.getSystem(getParam<VariableName>("variable"))),
44 _point(getParam<Point>("point")),
45 _value(0)
46{
47}
48
49void
51{
53
58 if (MooseUtils::absoluteFuzzyEqual(_value, 0.0))
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
72Real
74{
75 return _value;
76}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", PointValue)
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 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
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:3838
Compute the value of a variable at a specified location.
Definition PointValue.h:21
const Point & _point
The point to locate.
Definition PointValue.h:40
Real _value
The value of the variable at the desired location.
Definition PointValue.h:43
PointValue(const InputParameters &parameters)
Definition PointValue.C:35
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition PointValue.C:73
const unsigned int _var_number
The variable number of the variable we are operating on.
Definition PointValue.h:34
virtual void execute() override
Execute method.
Definition PointValue.C:50
const libMesh::System & _system
A reference to the system containing the variable.
Definition PointValue.h:37
static InputParameters validParams()
Definition PointValue.C:23
virtual MooseMesh & mesh()=0
SubProblem & _subproblem
Reference to the Subproblem for this user object.
void gatherMin(T &value)
Gather the parallel min of the variable passed in.
static constexpr dof_id_type invalid_id
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...