11 #include "libmesh/parallel_algebra.h" 19 params.
addParam<PositionsName>(
"initial_positions",
20 "Positions at the beginning of the simulation");
25 "Wether Positions should be broadcasted across all ranks");
29 params.
addRequiredParam<
bool>(
"auto_sort",
"Whether Positions should be sorted by coordinates");
42 _initial_positions(isParamValid(
"initial_positions")
43 ? &getReporterValueByName<
std::vector<Point>>(
44 getParam<PositionsName>(
"initial_positions") +
"/positions_1d")
49 _need_broadcast(getParam<bool>(
"auto_broadcast")),
50 _need_sort(getParam<bool>(
"auto_sort")),
61 mooseAssert(
initialized(initial),
"Positions vector has not been initialized.");
64 mooseError(
"Initial positions is not sized or initialized appropriately");
70 mooseError(
"Initial positions and current positions array length do not match");
72 mooseError(
"Positions retrieved with an out-of-bound index: '",
74 "' when there are only ",
84 mooseError(
"Positions vector has not been initialized.");
90 mooseAssert(
initialized(initial),
"Positions vector has not been initialized.");
98 mooseAssert(
initialized(initial),
"Positions vector has not been initialized.");
99 std::vector<std::size_t> return_index(1);
112 return return_index[0];
115 const std::vector<Point> &
123 mooseError(
"Positions vector has not been initialized.");
126 const std::vector<std::vector<Point>> &
132 mooseError(
"2D positions vectors have not been initialized.");
135 const std::vector<std::vector<std::vector<Point>>> &
141 mooseError(
"3D positions vectors have not been initialized.");
144 const std::vector<std::vector<std::vector<std::vector<Point>>>> &
150 mooseError(
"4D positions vectors have not been initialized.");
166 std::vector<Point> temp_2d_unrolled;
167 std::vector<Point> temp_3d_unrolled;
168 std::vector<Point> temp_4d_unrolled;
170 temp_2d_unrolled.insert(temp_2d_unrolled.end(), vec.begin(), vec.end());
172 for (
const auto & vec : vec_vec)
173 temp_3d_unrolled.insert(temp_3d_unrolled.end(), vec.begin(), vec.end());
175 for (
const auto & vec_vec : vec_vec_vec)
176 for (
const auto & vec : vec_vec)
177 temp_4d_unrolled.insert(temp_4d_unrolled.end(), vec.begin(), vec.end());
182 mooseError(
"Inconsistency between the 2D and 1D position vectors detected. " 183 "The 2D positions must unroll into the 1D positions");
186 if (temp_3d_unrolled.size() && temp_2d_unrolled.size() && temp_3d_unrolled != temp_3d_unrolled)
187 mooseError(
"Inconsistency between the 3D and 2D position vectors detected. " 188 "The 3D positions must unroll the same way as the 2D positions");
190 mooseError(
"Inconsistency between the 3D and 1D position vectors detected. " 191 "The 3D positions must unroll into the 1D positions");
194 if (temp_4d_unrolled.size() && temp_3d_unrolled.size() && temp_4d_unrolled != temp_3d_unrolled)
195 mooseError(
"Inconsistency between the 4D and 3D position vectors detected. " 196 "The 4D positions must unroll the same way as the 3D positions");
197 if (temp_4d_unrolled.size() && temp_2d_unrolled.size() && temp_4d_unrolled != temp_2d_unrolled)
198 mooseError(
"Inconsistency between the 4D and 2D position vectors detected. " 199 "The 4D positions must unroll the same way as the 2D positions");
201 mooseError(
"Inconsistency between the 4D and 1D position vectors detected. " 202 "The 4D positions must unroll into the 1D positions");
207 if (temp_2d_unrolled.size())
209 else if (temp_3d_unrolled.size())
211 else if (temp_4d_unrolled.size())
214 mooseError(
"Positions::unrollMultiDPositions() may only be called if there is at least one " 215 "non-empty positions vector.");
223 mooseAssert(
initialized(
false),
"Positions vector has not been initialized.");
238 mooseAssert(
comm().verify(
_positions),
"Positions should be the same across all MPI processes.");
244 mooseAssert(
initialized(
false),
"Positions vector has not been initialized.");
249 for (
auto i2 = i1 + 1; i2 <
_positions.size(); i2++)
257 mooseAssert(
initialized(
false),
"Positions vector has not been initialized.");
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
A MultiMooseEnum object to hold "execute_on" flags.
const Point & getNearestPosition(const Point &target, bool initial) const
Find the nearest Position for a given point.
static InputParameters validParams()
std::unique_ptr< KDTree > _initial_positions_kd_tree
KDTree to be able to find the nearest position to a point in a fast and scalable manner.
This context is specific for vector types of reporters, mainly for declaring a vector of the type fro...
Reporter object that has a single execution of the "execute" method for for each execute flag...
void clearPositions()
Clear all positions vectors.
const ExecFlagType EXEC_NONE
const Parallel::Communicator & comm() const
static InputParameters validParams()
const Point & getPosition(unsigned int index, bool initial) const
Getter for a single position at a known index.
const Parallel::Communicator & _communicator
Positions(const InputParameters ¶meters)
void unrollMultiDPositions()
Unrolls the multi-dimensional position vectors.
const Positions & getPositionsObject(const std::string &name) const
Get the Positions object by its name.
auto max(const L &left, const R &right)
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
std::vector< std::vector< Point > > _positions_2d
2D storage for all the positions
unsigned int getNearestPositionIndex(const Point &target, bool initial) const
Find the nearest Position index for a given point.
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
bool initialized(bool initial) const
Whether the positions object has been initialized.
std::vector< std::vector< std::vector< Point > > > _positions_3d
3D storage for all the positions
bool isCoPlanar(const std::vector< Point > vec_pts, const Point plane_nvec, const Point fixed_pt)
Decides whether all the Points of a vector of Points are in a plane that is defined by a normal vecto...
const std::vector< Point > & getPositions(bool initial) const
{ Getters for the positions vector for the desired dimension 1D will be the only one guaranteed to su...
bool _need_broadcast
Whether generation of positions is distributed or not (and therefore needs a broadcast) ...
const std::vector< std::vector< std::vector< Point > > > & getPositionsVector3D() const
std::unique_ptr< KDTree > _positions_kd_tree
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
const bool _need_sort
Whether positions should be sorted.
virtual void finalize() override
In charge of reduction across all ranks & sorting for consistent output.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
const std::vector< Point > *const _initial_positions
For initialization of the positions, another position reporter may be used.
const ReporterMode REPORTER_MODE_REPLICATED
bool arePositionsCoplanar() const
Report if the positions are co-planar or not.
Real getMinDistanceBetweenPositions() const
Find the minimum distance between positions.
const std::vector< std::vector< std::vector< std::vector< Point > > > > & getPositionsVector4D() const
auto min(const L &left, const R &right)
const std::vector< std::vector< Point > > & getPositionsVector2D() const
std::vector< std::vector< std::vector< std::vector< Point > > > > _positions_4d
4D storage for all the positions : space & time
auto index_range(const T &sizable)