13namespace autopasTools::generators {
17namespace GridGenerator {
30template <
class ParticleCell>
32 std::vector<ParticleCell> &cells,
const std::array<size_t, 3> &cellsPerDimension,
33 const std::array<size_t, 3> &particlesPerDim,
34 const typename ParticleCell::ParticleType &defaultParticle =
typename ParticleCell::ParticleType(),
35 const std::array<double, 3> &spacing = std::array<double, 3>{1, 1, 1},
36 const std::array<double, 3> &offset = std::array<double, 3>{.5, .5, .5},
37 const std::array<double, 3> &cellSize = {1., 1., 1.});
49template <
class Container>
50void fillWithParticles(Container &container,
const std::array<size_t, 3> &particlesPerDim,
53 const std::array<double, 3> &spacing = std::array<double, 3>{1., 1., 1.},
54 const std::array<double, 3> &offset = std::array<double, 3>{.5, .5, .5});
57template <
class ParticleCell>
59 const std::array<size_t, 3> &particlesPerDim,
60 const typename ParticleCell::ParticleType &defaultParticle,
61 const std::array<double, 3> &spacing,
const std::array<double, 3> &offset,
62 const std::array<double, 3> &cellSize) {
63 size_t id = defaultParticle.getID();
64 for (
unsigned long z = 0; z < particlesPerDim[2]; ++z) {
65 for (
unsigned long y = 0; y < particlesPerDim[1]; ++y) {
66 for (
unsigned long x = 0; x < particlesPerDim[0]; ++x) {
67 auto p = defaultParticle;
68 std::array<double, 3> pos{
static_cast<double>(x) * spacing[0] + offset[0],
69 static_cast<double>(y) * spacing[1] + offset[1],
70 static_cast<double>(z) * spacing[2] + offset[2]};
71 std::array<unsigned long, 3> cellIndex3D{
static_cast<unsigned long>(pos[0] / cellSize[0]),
72 static_cast<unsigned long>(pos[1] / cellSize[1]),
73 static_cast<unsigned long>(pos[2] / cellSize[2])};
84 cells[cellIndex].addParticle(p);
90template <
class Container>
92 Container &container,
const std::array<size_t, 3> &particlesPerDim,
94 const std::array<double, 3> &spacing,
const std::array<double, 3> &offset) {
95 size_t id = defaultParticle.getID();
96 for (
unsigned int z = 0; z < particlesPerDim[2]; ++z) {
97 for (
unsigned int y = 0; y < particlesPerDim[1]; ++y) {
98 for (
unsigned int x = 0; x < particlesPerDim[0]; ++x) {
99 auto p = defaultParticle;
100 p.setR({x * spacing[0] + offset[0], y * spacing[1] + offset[1], z * spacing[2] + offset[2]});
102 container.addParticle(p);
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
@ dummy
Dummy or deleted state, a particle with this state is not an actual particle!
@ halo
Halo state, a particle with this state is an actual particle, but not owned by the current AutoPas ob...
typename Container::ParticleType value
The Particle Type.
Definition: ParticleTypeTrait.h:24