https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Positions.h
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#pragma once
11
12// Moose includes
13#include "GeneralReporter.h"
14#include "KDTree.h"
15
21{
22public:
25 virtual ~Positions() = default;
26
30 const std::vector<Point> & getPositions(bool initial) const;
31 const std::vector<std::vector<Point>> & getPositionsVector2D() const;
32 const std::vector<std::vector<std::vector<Point>>> & getPositionsVector3D() const;
33 const std::vector<std::vector<std::vector<std::vector<Point>>>> & getPositionsVector4D() const;
35
37 unsigned int getNumPositions(bool initial = false) const
38 {
39 mooseAssert(initialized(initial), "Position should be initialized");
40 return (initial && _initial_positions) ? _initial_positions->size() : _positions.size();
41 }
42
44 const Point & getPosition(unsigned int index, bool initial) const;
45
47 const Point & getNearestPosition(const Point & target, bool initial) const;
48
50 unsigned int getNearestPositionIndex(const Point & target, bool initial) const;
51
54
56 bool arePositionsCoplanar() const;
57
59 bool initialized(bool initial) const;
60
61protected:
63 virtual void initialize() override = 0;
64
66 virtual void execute() override { initialize(); }
67
69 virtual void finalize() override;
70
72 virtual void meshChanged() override { initialSetup(); }
73
75 virtual void timestepSetup() override {}
76 virtual void residualSetup() override {}
77 virtual void jacobianSetup() override {}
78
80 void clearPositions();
81
84
86 const std::vector<Point> * const _initial_positions;
87
92 std::vector<Point> & _positions;
93
95 std::vector<std::vector<Point>> _positions_2d;
96
98 std::vector<std::vector<std::vector<Point>>> _positions_3d;
99
101 std::vector<std::vector<std::vector<std::vector<Point>>>> _positions_4d;
102
104 std::unique_ptr<KDTree> _initial_positions_kd_tree;
105 std::unique_ptr<KDTree> _positions_kd_tree;
106
109
113 const bool _need_sort;
114
117};
Reporter object that has a single execution of the "execute" method for each execute flag.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
Positions objects are under the hood Reporters.
Definition Positions.h:21
bool initialized(bool initial) const
Whether the positions object has been initialized.
Definition Positions.C:262
virtual ~Positions()=default
const Point & getPosition(unsigned int index, bool initial) const
Getter for a single position at a known index.
Definition Positions.C:59
std::unique_ptr< KDTree > _positions_kd_tree
Definition Positions.h:105
const bool _need_sort
Whether positions should be sorted.
Definition Positions.h:113
const std::vector< Point > *const _initial_positions
For initialization of the positions, another position reporter may be used.
Definition Positions.h:86
bool arePositionsCoplanar() const
Report if the positions are co-planar or not.
Definition Positions.C:255
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.
Definition Positions.h:104
unsigned int getNearestPositionIndex(const Point &target, bool initial) const
Find the nearest Position index for a given point.
Definition Positions.C:96
virtual void residualSetup() override
Gets called just before the residual is computed and before this object is asked to do its job.
Definition Positions.h:76
virtual void meshChanged() override
By default, Positions will call initial setup on mesh changed.
Definition Positions.h:72
unsigned int getNumPositions(bool initial=false) const
}
Definition Positions.h:37
Real getMinDistanceBetweenPositions() const
Find the minimum distance between positions.
Definition Positions.C:242
bool _need_broadcast
Whether generation of positions is distributed or not (and therefore needs a broadcast)
Definition Positions.h:108
const std::vector< std::vector< std::vector< Point > > > & getPositionsVector3D() const
Definition Positions.C:136
std::vector< std::vector< std::vector< std::vector< Point > > > > _positions_4d
4D storage for all the positions : space & time
Definition Positions.h:101
std::vector< std::vector< Point > > _positions_2d
2D storage for all the positions
Definition Positions.h:95
virtual void jacobianSetup() override
Gets called just before the Jacobian is computed and before this object is asked to do its job.
Definition Positions.h:77
void clearPositions()
Clear all positions vectors.
Definition Positions.C:154
const std::vector< std::vector< std::vector< std::vector< Point > > > > & getPositionsVector4D() const
Definition Positions.C:145
const std::vector< std::vector< Point > > & getPositionsVector2D() const
Definition Positions.C:127
virtual void initialize() override=0
In charge of computing / loading the positions.
virtual void timestepSetup() override
By default, Positions will not be modified very regularly.
Definition Positions.h:75
const Point & getNearestPosition(const Point &target, bool initial) const
Find the nearest Position for a given point.
Definition Positions.C:88
std::vector< Point > & _positions
For now, only the 1D vector will be shared across all ranks.
Definition Positions.h:92
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...
Definition Positions.C:116
void unrollMultiDPositions()
Unrolls the multi-dimensional position vectors.
Definition Positions.C:163
static InputParameters validParams()
Definition Positions.C:15
std::vector< std::vector< std::vector< Point > > > _positions_3d
3D storage for all the positions
Definition Positions.h:98
virtual void execute() override
By default, we wont execute often but "executing" will mean loading the positions.
Definition Positions.h:66
virtual void finalize() override
In charge of reduction across all ranks & sorting for consistent output.
Definition Positions.C:220
bool _initialized
Whether the positions object has been initialized. This must be set by derived objects.
Definition Positions.h:116
virtual void initialSetup()
Gets called at the beginning of the simulation before this object is asked to do its job.