28 template <
typename UserObjectType,
typename BaseType>
38 virtual void execute()
override;
57 virtual const std::vector<Point>
spatialPoints()
const override;
82 using BaseType::_communicator;
83 using BaseType::_current_elem;
84 using BaseType::isParamValid;
85 using BaseType::processor_id;
89 template <
typename UserObjectType,
typename BaseType>
95 params.
addParam<std::vector<Point>>(
"points",
96 "Computations will be lumped into values at these points.");
97 params.
addParam<FileName>(
"points_file",
98 "A filename that should be looked in for points. Each " 99 "set of 3 values in that file will represent a Point. " 100 "This and 'points' cannot be both supplied.");
102 MooseEnum distnorm(
"point=0 radius=1",
"point");
104 "dist_norm", distnorm,
"To specify whether the distance is defined based on point or radius");
106 params.
addParam<
MooseEnum>(
"axis", axis,
"The axis around which the radius is determined");
108 params.
addParamNamesToGroup(
"points points_file dist_norm axis",
"Points and distance to points");
116 template <
typename UserObjectType,
typename BaseType>
118 : BaseType(parameters),
119 _dist_norm(this->template getParam<
MooseEnum>(
"dist_norm")),
120 _axis(this->template getParam<
MooseEnum>(
"axis"))
122 if (this->
template getParam<MooseEnum>(
"dist_norm") !=
"radius" &&
124 this->
template paramError(
"axis",
125 "'axis' should only be set if 'dist_norm' is set to 'radius'");
136 const auto uo_type = MooseUtils::prettyCppType<UserObjectType>();
137 auto sub_params = this->_app.getFactory().getValidParams(uo_type);
138 sub_params.applyParameters(parameters, {},
true);
140 const auto sub_name = name() +
"_sub" + std::to_string(i);
141 auto uo = this->_app.getFactory().template createUnique<UserObjectType>(
142 uo_type, sub_name, sub_params, this->_tid);
147 template <
typename UserObjectType,
typename BaseType>
152 template <
typename UserObjectType,
typename BaseType>
156 if (isParamValid(
"points") && isParamValid(
"points_file"))
157 mooseError(
name(),
": Both 'points' and 'points_file' cannot be specified simultaneously.");
159 if (isParamValid(
"points"))
161 _points = this->
template getParam<std::vector<Point>>(
"points");
163 else if (isParamValid(
"points_file"))
165 const FileName & points_file = this->
template getParam<FileName>(
"points_file");
170 _points = file.getDataAsPoints();
173 mooseError(
name(),
": You need to supply either 'points' or 'points_file' parameter.");
176 template <
typename UserObjectType,
typename BaseType>
180 for (
auto & user_object : _user_objects)
181 user_object->initialize();
184 template <
typename UserObjectType,
typename BaseType>
188 nearestUserObject(_current_elem->vertex_average()).execute();
191 template <
typename UserObjectType,
typename BaseType>
195 for (
auto & user_object : _user_objects)
196 user_object->finalize();
199 template <
typename UserObjectType,
typename BaseType>
205 for (MooseIndex(_user_objects) i = 0; i < _user_objects.size(); ++i)
206 _user_objects[i]->threadJoin(*npla._user_objects[i]);
209 template <
typename UserObjectType,
typename BaseType>
213 return nearestUserObject(p).spatialValue(p);
216 template <
typename UserObjectType,
typename BaseType>
220 unsigned int closest = 0;
225 const auto & current_point = it.value();
227 Real current_distance;
230 current_distance = (p - current_point).
norm();
246 std::sqrt(current_point(i) * current_point(i) + current_point(j) * current_point(j)));
249 if (current_distance < closest_distance)
251 closest_distance = current_distance;
252 closest = it.index();
256 return *_user_objects[closest];
259 template <
typename UserObjectType,
typename BaseType>
260 const std::vector<Point>
263 std::vector<Point> points;
265 for (MooseIndex(_points) i = 0; i < _points.size(); ++i)
267 auto layered_base =
dynamic_cast<LayeredBase *
>(_user_objects[i].get());
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
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...
virtual const std::vector< Point > spatialPoints() const override
std::vector< std::unique_ptr< UserObjectType > > _user_objects
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
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 > &)
UserObjectType & nearestUserObject(const Point &p) const
Get the UserObject that is closest to the point.
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.