28 template <
typename UserObjectType,
typename BaseType>
38 virtual void execute()
override;
57 virtual const std::vector<Point>
spatialPoints()
const override;
85 using BaseType::_communicator;
86 using BaseType::_current_elem;
87 using BaseType::isParamValid;
88 using BaseType::processor_id;
92 template <
typename UserObjectType,
typename BaseType>
98 params.
addParam<std::vector<Point>>(
"points",
99 "Computations will be lumped into values at these points.");
100 params.
addParam<FileName>(
"points_file",
101 "A filename that should be looked in for points. Each " 102 "set of 3 values in that file will represent a Point. " 103 "This and 'points' cannot be both supplied.");
105 MooseEnum distnorm(
"point=0 radius=1",
"point");
107 "dist_norm", distnorm,
"To specify whether the distance is defined based on point or radius");
109 params.
addParam<
MooseEnum>(
"axis", axis,
"The axis around which the radius is determined");
111 params.
addParamNamesToGroup(
"points points_file dist_norm axis",
"Points and distance to points");
119 template <
typename UserObjectType,
typename BaseType>
121 : BaseType(parameters),
122 _dist_norm(this->template getParam<
MooseEnum>(
"dist_norm")),
123 _axis(this->template getParam<
MooseEnum>(
"axis"))
125 if (this->
template getParam<MooseEnum>(
"dist_norm") !=
"radius" &&
127 this->
template paramError(
"axis",
128 "'axis' should only be set if 'dist_norm' is set to 'radius'");
138 sub_params += parameters;
139 sub_params.
set<std::string>(
"_object_name") = name() +
"_sub" + std::to_string(i);
146 template <
typename UserObjectType,
typename BaseType>
151 template <
typename UserObjectType,
typename BaseType>
155 if (isParamValid(
"points") && isParamValid(
"points_file"))
156 mooseError(
name(),
": Both 'points' and 'points_file' cannot be specified simultaneously.");
158 if (isParamValid(
"points"))
160 _points = this->
template getParam<std::vector<Point>>(
"points");
162 else if (isParamValid(
"points_file"))
164 const FileName & points_file = this->
template getParam<FileName>(
"points_file");
169 _points = file.getDataAsPoints();
172 mooseError(
name(),
": You need to supply either 'points' or 'points_file' parameter.");
175 template <
typename UserObjectType,
typename BaseType>
179 for (
auto & user_object : _user_objects)
180 user_object->initialize();
183 template <
typename UserObjectType,
typename BaseType>
187 nearestUserObject(_current_elem->vertex_average())->execute();
190 template <
typename UserObjectType,
typename BaseType>
194 for (
auto & user_object : _user_objects)
195 user_object->finalize();
198 template <
typename UserObjectType,
typename BaseType>
204 for (MooseIndex(_user_objects) i = 0; i < _user_objects.size(); ++i)
205 _user_objects[i]->threadJoin(*npla._user_objects[i]);
208 template <
typename UserObjectType,
typename BaseType>
212 return nearestUserObject(p)->spatialValue(p);
215 template <
typename UserObjectType,
typename BaseType>
216 std::shared_ptr<UserObjectType>
219 unsigned int closest = 0;
224 const auto & current_point = it.value();
226 Real current_distance;
229 current_distance = (p - current_point).
norm();
245 std::sqrt(current_point(i) * current_point(i) + current_point(j) * current_point(j)));
248 if (current_distance < closest_distance)
250 closest_distance = current_distance;
251 closest = it.index();
255 return _user_objects[closest];
258 template <
typename UserObjectType,
typename BaseType>
259 const std::vector<Point>
262 std::vector<Point> points;
264 for (MooseIndex(_points) i = 0; i < _points.size(); ++i)
266 std::shared_ptr<LayeredBase> layered_base =
271 auto direction = layered_base->direction();
273 for (
const auto & l : layers)
275 Point pt = _points[i];
277 points.push_back(pt);
std::string name(const ElemQuality q)
virtual void finalize() override
std::vector< std::shared_ptr< UserObjectType > > _user_objects
std::shared_ptr< UserObjectType > nearestUserObject(const Point &p) const
Get the UserObject that is closest to the point.
virtual Real spatialValue(const Point &p) const override
Given a Point return the integral value associated with the layer that point falls in for the layered...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
This UserObject computes averages of a variable storing partial sums for the specified number of inte...
Utility class for reading delimited data (e.g., CSV data).
NearestPointBase(const InputParameters ¶meters)
_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...
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
virtual const std::vector< Point > spatialPoints() const override
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
std::list< InputParameters > _sub_params
virtual const std::string & name() const
Get the name of the class.
InputParameters validParams()
void fillPoints()
Fills in the _points variable from either 'points' or 'points_file' parameter.
virtual const std::vector< Point > & getPoints() const
Get the points at which the nearest operation is performed.
auto max(const L &left, const R &right)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
virtual void threadJoin(const UserObject &y) override
virtual void execute() override
const std::vector< Real > & getLayerCenters() const
Get the center coordinates for the layers (along given direction)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This base class computes volume integrals of a variable storing partial sums for the specified number...
const unsigned int _dist_norm
std::vector< Point > _points
virtual void initialize() override
Base class for user-specific data.