A class that represents Cartesian 3D grid.
More...
#include <uniform_grid_environment.h>
|
| UniformGridEnvironment (Adjacency adjacency=kHigh) |
|
| UniformGridEnvironment (UniformGridEnvironment const &)=delete |
|
void | operator= (UniformGridEnvironment const &)=delete |
|
| ~UniformGridEnvironment () override=default |
|
void | Clear () override |
| Clears the grid. More...
|
|
void | SetBoxLength (int32_t bl) |
|
void | SetDetermineSimSize (bool value) |
|
int32_t | GetBoxLength () const |
|
real_t | SquaredEuclideanDistance (const Real3 &pos1, const Real3 &pos2) const |
| Calculates the squared euclidean distance between two points in 3D. More...
|
|
bool | WithinSquaredEuclideanDistance (real_t squared_radius, const Real3 &pos1, const Real3 &pos2) const |
|
LoadBalanceInfo * | GetLoadBalanceInfo () override |
|
size_t | GetBoxIndex (const Real3 &position) const |
| Return the box index in the one dimensional array of the box that contains the position. More...
|
|
std::array< int32_t, 6 > | GetDimensions () const override |
|
bool | ContainedInGrid (const Real3 &point) const |
|
std::array< int32_t, 2 > | GetDimensionThresholds () const override |
|
void | GetNumBoxesAxis (uint32_t *nba) |
|
uint64_t | GetNumBoxes () const |
|
std::array< uint64_t, 3 > | GetBoxCoordinates (size_t box_idx) const |
|
void | ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Agent &query, real_t squared_radius) override |
| Applies the given lambda to each neighbor of the specified agent is within the squared radius. More...
|
|
void | ForEachNeighbor (Functor< void, Agent *, real_t > &lambda, const Real3 &query_position, real_t squared_radius, const Agent *query_agent=nullptr) override |
| Applies the given lambda to each neighbor of the specified position within the squared radius. More...
|
|
void | ForEachNeighbor (Functor< void, Agent * > &functor, const Agent &query, void *criteria) override |
| Applies the given functor to each neighbor of the specified agent that is within the same box as the query agent or in the 26 surrounding boxes. More...
|
|
NeighborMutexBuilder * | GetNeighborMutexBuilder () override |
|
virtual | ~Environment ()=default |
|
void | MarkAsOutOfSync () |
|
void | Update () |
|
void | ForcedUpdate () |
| Updates the environment. Prefer Update() for implementations. More...
|
|
real_t | GetLargestAgentSize () const |
| Return the size of the largest agent. More...
|
|
real_t | GetLargestAgentSizeSquared () const |
|
bool | HasGrown () const |
|
A class that represents Cartesian 3D grid.
Definition at line 58 of file uniform_grid_environment.h.
◆ Adjacency
Enum that determines the degree of adjacency in search neighbor boxes.
Enumerator |
---|
kLow | The closest 8 neighboring boxes
|
kMedium | The closest 18 neighboring boxes
|
kHigh | The closest 26 neighboring boxes
|
Definition at line 228 of file uniform_grid_environment.h.
◆ UniformGridEnvironment() [1/2]
bdm::UniformGridEnvironment::UniformGridEnvironment |
( |
Adjacency |
adjacency = kHigh | ) |
|
|
inlineexplicit |
◆ UniformGridEnvironment() [2/2]
◆ ~UniformGridEnvironment()
bdm::UniformGridEnvironment::~UniformGridEnvironment |
( |
| ) |
|
|
overridedefault |
◆ CheckGridGrowth()
void bdm::UniformGridEnvironment::CheckGridGrowth |
( |
| ) |
|
|
inlineprivate |
◆ Clear()
void bdm::UniformGridEnvironment::Clear |
( |
| ) |
|
|
inlineoverridevirtual |
◆ ContainedInGrid()
bool bdm::UniformGridEnvironment::ContainedInGrid |
( |
const Real3 & |
point | ) |
const |
|
inline |
Returns true if the provided point is inside the simulation domain. Compares the points coordinates against grid_dimensions_ (without bounding boxes).
Definition at line 356 of file uniform_grid_environment.h.
◆ ForEachNeighbor() [1/3]
void bdm::UniformGridEnvironment::ForEachNeighbor |
( |
Functor< void, Agent * > & |
functor, |
|
|
const Agent & |
query, |
|
|
void * |
criteria |
|
) |
| |
|
overridevirtual |
Applies the given functor to each neighbor of the specified agent that is within the same box as the query agent or in the 26 surrounding boxes.
In simulation code do not use this function directly. Use the same function from the execution context (e.g. InPlaceExecutionContext
)
- Parameters
-
[in] | functor | The operation as a functor |
[in] | query | The query object |
[in] | criteria | This parameter is ignored. Pass a nullptr. |
Implements bdm::Environment.
Definition at line 307 of file uniform_grid_environment.cc.
◆ ForEachNeighbor() [2/3]
Applies the given lambda to each neighbor of the specified agent is within the squared radius.
In simulation code do not use this function directly. Use the same function from the execution context (e.g. InPlaceExecutionContext
)
- Parameters
-
[in] | lambda | The operation as a lambda |
| query | The query object |
| squared_radius | The squared search radius (type: real_t*) |
Implements bdm::Environment.
Definition at line 406 of file uniform_grid_environment.h.
◆ ForEachNeighbor() [3/3]
void bdm::UniformGridEnvironment::ForEachNeighbor |
( |
Functor< void, Agent *, real_t > & |
lambda, |
|
|
const Real3 & |
query_position, |
|
|
real_t |
squared_radius, |
|
|
const Agent * |
query_agent = nullptr |
|
) |
| |
|
inlineoverridevirtual |
Applies the given lambda to each neighbor of the specified position within the squared radius.
In simulation code do not use this function directly. Use the same function from the execution context (e.g. InPlaceExecutionContext
)
- Parameters
-
[in] | lambda | The operation as a lambda |
| query_position | The query position |
| squared_radius | The squared search radius (type: real_t*) |
Implements bdm::Environment.
Definition at line 421 of file uniform_grid_environment.h.
◆ GetBoxCoordinates()
std::array<uint64_t, 3> bdm::UniformGridEnvironment::GetBoxCoordinates |
( |
size_t |
box_idx | ) |
const |
|
inline |
◆ GetBoxIndex() [1/2]
size_t bdm::UniformGridEnvironment::GetBoxIndex |
( |
const Real3 & |
position | ) |
const |
|
inline |
Return the box index in the one dimensional array of the box that contains the position.
- Parameters
-
[in] | position | The position of the object |
- Returns
- The box index.
Definition at line 330 of file uniform_grid_environment.h.
◆ GetBoxIndex() [2/2]
size_t bdm::UniformGridEnvironment::GetBoxIndex |
( |
const std::array< uint64_t, 3 > & |
box_coord | ) |
const |
|
inlineprivate |
Returns the box index in the one dimensional array based on box coordinates in space
- Parameters
-
box_coord | box coordinates in space (x, y, z) |
- Returns
- The box index.
Definition at line 946 of file uniform_grid_environment.h.
◆ GetBoxLength()
int32_t bdm::UniformGridEnvironment::GetBoxLength |
( |
| ) |
const |
|
inline |
◆ GetBoxPointer() [1/2]
Box* bdm::UniformGridEnvironment::GetBoxPointer |
( |
size_t |
index | ) |
|
|
inlineprivate |
Gets the pointer to the box with the given index.
- Parameters
-
[in] | index | The index of the box |
- Returns
- The pointer to the box
Definition at line 934 of file uniform_grid_environment.h.
◆ GetBoxPointer() [2/2]
const Box* bdm::UniformGridEnvironment::GetBoxPointer |
( |
size_t |
index | ) |
const |
|
inlineprivate |
Gets the pointer to the box with the given index.
- Parameters
-
[in] | index | The index of the box |
- Returns
- The pointer to the box
Definition at line 923 of file uniform_grid_environment.h.
◆ GetDimensions()
std::array<int32_t, 6> bdm::UniformGridEnvironment::GetDimensions |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ GetDimensionThresholds()
std::array<int32_t, 2> bdm::UniformGridEnvironment::GetDimensionThresholds |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ GetHalfMooreBoxIndices()
void bdm::UniformGridEnvironment::GetHalfMooreBoxIndices |
( |
FixedSizeVector< size_t, 14 > * |
neighbor_boxes, |
|
|
size_t |
box_idx |
|
) |
| const |
|
inlineprivate |
Determines current box based on parameter box_idx and adds it together with half of the surrounding boxes to the vector. Legend: C = center, N = north, E = east, S = south, W = west, F = front, B = back For each box pair which is centro-symmetric only one box is taken – e.g. E-W: E, or BNW-FSE: BNW
(x-axis to the right \ y-axis up)
z=1
+-----+----+-----+
| BNW | BN | BNE |
+-----+----+-----+
| NW | N | NE |
+-----+----+-----+
| FNW | FN | FNE |
+-----+----+-----+
z = 0
+-----+----+-----+
| BW | B | BE |
+-----+----+-----+
| W | C | E |
+-----+----+-----+
| FW | F | FE |
+-----+----+-----+
z = -1
+-----+----+-----+
| BSW | BS | BSE |
+-----+----+-----+
| SW | S | SE |
+-----+----+-----+
| FSW | FS | FSE |
+-----+----+-----+
Definition at line 885 of file uniform_grid_environment.h.
◆ GetLoadBalanceInfo()
◆ GetMooreBoxes()
void bdm::UniformGridEnvironment::GetMooreBoxes |
( |
FixedSizeVector< const Box *, 27 > * |
neighbor_boxes, |
|
|
size_t |
box_idx |
|
) |
| const |
|
inlineprivate |
Gets the Moore (i.e adjacent) boxes of the query boxAlso adds the query box.
- Parameters
-
[out] | neighbor_boxes | The neighbor boxes |
[in] | box_idx | The query box |
Definition at line 742 of file uniform_grid_environment.h.
◆ GetMooreBoxIndices()
void bdm::UniformGridEnvironment::GetMooreBoxIndices |
( |
FixedSizeVector< uint64_t, 27 > * |
box_indices, |
|
|
size_t |
box_idx |
|
) |
| const |
|
inlineprivate |
Gets the box indices of all adjacent boxes. Also adds the query box index.
- Parameters
-
[out] | box_indices | Result containing all box indices |
[in] | box_idx | The query box |
Definition at line 807 of file uniform_grid_environment.h.
◆ GetNeighborMutexBuilder()
◆ GetNumBoxes()
uint64_t bdm::UniformGridEnvironment::GetNumBoxes |
( |
| ) |
const |
|
inline |
◆ GetNumBoxesAxis()
void bdm::UniformGridEnvironment::GetNumBoxesAxis |
( |
uint32_t * |
nba | ) |
|
|
inline |
◆ operator=()
◆ RoundOffGridDimensions()
void bdm::UniformGridEnvironment::RoundOffGridDimensions |
( |
const std::array< real_t, 6 > & |
grid_dimensions | ) |
|
|
inlineprivate |
◆ SetBoxLength()
void bdm::UniformGridEnvironment::SetBoxLength |
( |
int32_t |
bl | ) |
|
|
inline |
◆ SetDetermineSimSize()
void bdm::UniformGridEnvironment::SetDetermineSimSize |
( |
bool |
value | ) |
|
|
inline |
◆ SquaredEuclideanDistance()
real_t bdm::UniformGridEnvironment::SquaredEuclideanDistance |
( |
const Real3 & |
pos1, |
|
|
const Real3 & |
pos2 |
|
) |
| const |
|
inline |
Calculates the squared euclidean distance between two points in 3D.
- Parameters
-
[in] | pos1 | Position of the first point |
[in] | pos2 | Position of the second point |
- Returns
- The distance between the two points
Definition at line 290 of file uniform_grid_environment.h.
◆ UpdateImplementation()
void bdm::UniformGridEnvironment::UpdateImplementation |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ WithinSquaredEuclideanDistance()
bool bdm::UniformGridEnvironment::WithinSquaredEuclideanDistance |
( |
real_t |
squared_radius, |
|
|
const Real3 & |
pos1, |
|
|
const Real3 & |
pos2 |
|
) |
| const |
|
inline |
◆ ::bdm::detail::InitializeGPUData
◆ MechanicalForcesOpCuda
◆ MechanicalForcesOpOpenCL
◆ SchedulerTest
friend class SchedulerTest |
|
friend |
◆ adjacency_
Adjacency bdm::UniformGridEnvironment::adjacency_ |
|
private |
◆ box_length_
int32_t bdm::UniformGridEnvironment::box_length_ = 1 |
|
private |
◆ box_length_squared_
int32_t bdm::UniformGridEnvironment::box_length_squared_ = 1 |
|
private |
◆ boxes_
The vector containing all the boxes in the grid Using parallel resize vector to enable parallel initialization and thus better scalability.
Definition at line 655 of file uniform_grid_environment.h.
◆ determine_sim_size_
bool bdm::UniformGridEnvironment::determine_sim_size_ = true |
|
private |
◆ grid_dimensions_
std::array<int32_t, 6> bdm::UniformGridEnvironment::grid_dimensions_ |
|
private |
◆ is_custom_box_length_
bool bdm::UniformGridEnvironment::is_custom_box_length_ = false |
|
private |
◆ lbi_
◆ nb_mutex_builder_
◆ num_boxes_axis_
std::array<uint64_t, 3> bdm::UniformGridEnvironment::num_boxes_axis_ = {{0}} |
|
private |
◆ num_boxes_xy_
size_t bdm::UniformGridEnvironment::num_boxes_xy_ = 0 |
|
private |
◆ successors_
Implements linked list - array index = key, value: next element
// Usage
AgentHandle current_element = ...;
AgentHandle next_element = successors_[current_element];
Definition at line 680 of file uniform_grid_environment.h.
◆ threshold_dimensions_
std::array<int32_t, 2> bdm::UniformGridEnvironment::threshold_dimensions_ |
|
private |
Stores the min / max dimension value that need to be surpassed in order to trigger a diffusion grid change
Definition at line 688 of file uniform_grid_environment.h.
◆ timestamp_
uint32_t bdm::UniformGridEnvironment::timestamp_ = 0 |
|
private |
is incremented at each call to Update This is used to decide if boxes should be reinitialized
Definition at line 658 of file uniform_grid_environment.h.
◆ total_num_boxes_
uint64_t bdm::UniformGridEnvironment::total_num_boxes_ = 0 |
|
private |
The documentation for this class was generated from the following files: