AutoPas  3.0.0
Loading...
Searching...
No Matches
LoadEstimators.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <array>
11#include <vector>
12
15
20
30template <class ParticleCell>
31unsigned long squaredParticlesPerCell(const std::vector<ParticleCell> &cells,
32 const std::array<unsigned long, 3> &cellsPerDimension,
33 const std::array<unsigned long, 3> &lowerCorner,
34 const std::array<unsigned long, 3> &upperCorner) {
35 unsigned long sum = 0;
36 for (unsigned long x = lowerCorner[0]; x <= upperCorner[0]; x++) {
37 for (unsigned long y = lowerCorner[1]; y <= upperCorner[1]; y++) {
38 for (unsigned long z = lowerCorner[2]; z <= upperCorner[2]; z++) {
39 const auto load =
40 cells[autopas::utils::ThreeDimensionalMapping::threeToOneD(x, y, z, cellsPerDimension)].size();
41 sum += load * load;
42 }
43 }
44 }
45 return sum;
46}
47
55template <class Particle_T>
58 unsigned long cellIndex) {
59 unsigned long cellLoad = 0;
60 for (auto &list : neighborLists[cellIndex]) {
61 cellLoad += list.second.size();
62 }
63
64 return cellLoad;
65}
66
74template <class Particle_T>
77 unsigned long cellIndex) {
78 unsigned long cellLoad = 0;
79 for (auto &list : neighborLists[cellIndex]) {
80 for (size_t index = 0; index < list.size(); index++) {
81 cellLoad += list[index].second.size();
82 }
83 }
84
85 return cellLoad;
86}
87
97template <class Particle_T, class NeighborList>
98unsigned long neighborListLength(NeighborList &neighborLists, const std::array<unsigned long, 3> &cellsPerDimension,
99 const std::array<unsigned long, 3> &lowerCorner,
100 const std::array<unsigned long, 3> &upperCorner) {
101 auto &internalList = neighborLists.getAoSNeighborList();
102 unsigned long sum = 0;
103 for (unsigned long x = lowerCorner[0]; x <= upperCorner[0]; x++) {
104 for (unsigned long y = lowerCorner[1]; y <= upperCorner[1]; y++) {
105 for (unsigned long z = lowerCorner[2]; z <= upperCorner[2]; z++) {
106 auto cellIndex = autopas::utils::ThreeDimensionalMapping::threeToOneD(x, y, z, cellsPerDimension);
107 sum += neighborListLengthImpl<Particle_T>(internalList, cellIndex);
108 }
109 }
110 }
111 return sum;
112}
113
114} // namespace autopas::loadEstimators
std::vector< std::vector< std::pair< Particle_T *, std::vector< Particle_T * > > > > AllCellsNeighborListsType
Cell wise verlet lists for neighbors from all adjacent cells: For every cell, a vector of pairs.
Definition: VerletListsCellsHelpers.h:27
std::vector< std::vector< std::vector< std::pair< Particle_T *, std::vector< Particle_T * > > > > > PairwiseNeighborListsType
Pairwise verlet lists: For every cell a vector, for every neighboring cell a vector of particle-neigh...
Definition: VerletListsCellsHelpers.h:38
Collection of functions for estimating the load required to update a specific region within a contain...
Definition: CompatibleLoadEstimators.h:21
unsigned long neighborListLength(NeighborList &neighborLists, const std::array< unsigned long, 3 > &cellsPerDimension, const std::array< unsigned long, 3 > &lowerCorner, const std::array< unsigned long, 3 > &upperCorner)
Sums up the lengths of the verlet neighbor lists of all particles within region.
Definition: LoadEstimators.h:98
unsigned long squaredParticlesPerCell(const std::vector< ParticleCell > &cells, const std::array< unsigned long, 3 > &cellsPerDimension, const std::array< unsigned long, 3 > &lowerCorner, const std::array< unsigned long, 3 > &upperCorner)
Sums up the squared number of particles for all cells within region.
Definition: LoadEstimators.h:31
unsigned long neighborListLengthImpl(const typename autopas::VerletListsCellsHelpers::AllCellsNeighborListsType< Particle_T > &neighborLists, unsigned long cellIndex)
Helper function for calculating the neighbor list length for the Verlet lists cells neighbor list.
Definition: LoadEstimators.h:56
constexpr T threeToOneD(T x, T y, T z, const std::array< T, 3 > &dims)
Convert a 3d index to a 1d index.
Definition: ThreeDimensionalMapping.h:29