https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NearestPointIntegralVariablePostprocessor.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// MOOSE includes
12
14
17{
20
22 "Compute element variable integrals for nearest-point based subdomains");
23
24 params.registerBase("VectorPostprocessor");
25
26 return params;
27}
28
30 const InputParameters & parameters)
32 parameters),
33 _np_post_processor_values(declareVector("np_post_processor_values"))
34{
36}
37
38Real
40{
41 unsigned int i = nearestPointIndex(point);
42
43 if (i >= _np_post_processor_values.size())
44 mooseError("The vector length of vector post processor is ",
46 " but nearestPointIndex() return ",
47 i);
48
50}
51
52Real
54{
55 if (i >= _np_post_processor_values.size())
56 mooseError("The vector length of vector post processor is ",
58 " but you pass in ",
59 i);
60
62}
63
64void
66{
67 if (_user_objects.size() != _np_post_processor_values.size())
68 mooseError("The vector length of the vector postprocessor ",
70 " is different from the number of user objects ",
71 _user_objects.size());
72
73 unsigned int i = 0;
74 for (auto & user_object : _user_objects)
75 {
76 user_object->finalize();
77 const auto & const_user_object = *user_object;
78 _np_post_processor_values[i++] = const_user_object.getValue();
79 }
80}
81
82unsigned int
84{
85 unsigned int closest = 0;
86 Real closest_distance = std::numeric_limits<Real>::max();
87
88 for (auto it : Moose::enumerate(_points))
89 {
90 const auto & current_point = it.value();
91
92 Real current_distance = (p - current_point).norm();
93
94 if (current_distance < closest_distance)
95 {
96 closest_distance = current_distance;
97 closest = it.index();
98 }
99 }
100
101 return closest;
102}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObject("MooseApp", NearestPointIntegralVariablePostprocessor)
This postprocessor computes a volume integral of the specified variable.
Base class VectorPostprocessors operating on elemental variables.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
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.
This UserObject computes averages of a variable storing partial sums for the specified number of inte...
std::vector< std::unique_ptr< ElementIntegralVariablePostprocessor > > _user_objects
Given a list of points this object computes the variable integral closest to each one of those points...
NearestPointIntegralVariablePostprocessor(const InputParameters &parameters)
virtual Real spatialValue(const Point &point) const override
Given a Point return the integral value associated with the layer that point falls in for the layered...
_enumerate_range< Iterator > enumerate(Iterator first, Iterator last, typename std::iterator_traits< Iterator >::difference_type initial)
Enumerate function for iterating over a range and obtaining both a reference to the underlying type a...
Definition Enumerate.h:52