AutoPas  3.0.0
Loading...
Searching...
No Matches
VerletListsCellsHelpers.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <array>
10#include <cstddef>
11#include <unordered_map>
12#include <utility>
13#include <vector>
14
26template <class Particle_T>
27using AllCellsNeighborListsType = std::vector<std::vector<std::pair<Particle_T *, std::vector<Particle_T *>>>>;
28
36template <class Particle_T>
38 std::vector<std::vector<std::vector<std::pair<Particle_T *, std::vector<Particle_T *>>>>>;
39
44enum class VLCBuildType {
45 aosBuild,
46 soaBuild,
47};
48
65
71 bool operator==(const BaseStepOffsets &rhs) const;
72
78 bool operator!=(const BaseStepOffsets &rhs) const;
79};
80
96std::vector<BaseStepOffsets> buildC08BaseStep(const std::array<int, 3> &cellsPerDim);
97
108size_t estimateListLength(size_t numParticles, const std::array<double, 3> &boxSize, double interactionLength,
109 double correctionFactor);
110
121template <class Cells>
122size_t estimateNumLists(size_t baseCellIndex, bool useNewton3, const Cells &cells,
123 const std::vector<BaseStepOffsets> &offsetsC08) {
124 // First for every cell, find its biggest factor.
125 // Meaning, find out what is the closest interaction type this cell is involved in.
126 std::unordered_map<int, double> offsetFactors{};
127 std::unordered_map<int, double> offsetFactorsNoN3{};
128 for (const auto [offsetA, offsetB, factor] : offsetsC08) {
129 offsetFactors[offsetA] = std::max(offsetFactors[offsetA], factor);
130 offsetFactorsNoN3[offsetB] = std::max(offsetFactors[offsetB], factor);
131 }
132 // The estimate is constructed by summing the involved cells' sizes weighted by their factors.
133 size_t estimate = 0;
134 for (const auto &[offset, factor] : offsetFactors) {
135 estimate += cells[baseCellIndex + offset].size() * factor;
136 }
137 // For the non Newton3 case, lists have to be created for particles that otherwise would already be covered.
138 if (not useNewton3) {
139 for (const auto &[offset, factor] : offsetFactorsNoN3) {
140 estimate += cells[baseCellIndex + offset].size() * factor;
141 }
142 }
143 return estimate;
144};
145} // namespace autopas::VerletListsCellsHelpers
Helper functions and type aliases for verlet lists cells.
Definition: VerletListsCellsHelpers.cpp:14
size_t estimateNumLists(size_t baseCellIndex, bool useNewton3, const Cells &cells, const std::vector< BaseStepOffsets > &offsetsC08)
Function to estimate the number of neighbor lists for one base step.
Definition: VerletListsCellsHelpers.h:122
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< BaseStepOffsets > buildC08BaseStep(const std::array< int, 3 > &cellsPerDim)
Builds the list of offsets from the base cell for the c08 base step.
Definition: VerletListsCellsHelpers.cpp:26
VLCBuildType
Indicates which build functor should be used for the generation of the neighbor list.
Definition: VerletListsCellsHelpers.h:44
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
size_t estimateListLength(size_t numParticles, const std::array< double, 3 > &boxSize, double interactionLength, double correctionFactor)
Simple heuristic to calculate the average number of particles per verlet list assuming particles are ...
Definition: VerletListsCellsHelpers.cpp:16
Helper Struct to bundle all information about base step offsets.
Definition: VerletListsCellsHelpers.h:52
bool operator!=(const BaseStepOffsets &rhs) const
Inequality operator.
Definition: VerletListsCellsHelpers.cpp:93
int offset1
Offset from the base cell for cell 1.
Definition: VerletListsCellsHelpers.h:56
int offset2
Offset from the base cell for cell 2.
Definition: VerletListsCellsHelpers.h:60
double listSizeEstimateFactor
Estimation factor on the fraction of particles that will end up needing a neighbor list in the base c...
Definition: VerletListsCellsHelpers.h:64
bool operator==(const BaseStepOffsets &rhs) const
Equality operator.
Definition: VerletListsCellsHelpers.cpp:89