29template <
class Container>
30void fillWithParticles(Container &container,
const std::array<double, 3> &boxMin,
const std::array<double, 3> &boxMax,
33 const double spacing = 1.) {
35 const double spacingRow = spacing * sqrt(3. / 4.);
37 const double spacingLayer = spacing * sqrt(2. / 3.);
39 const double xOffset = spacing * 1. / 2.;
41 const double yOffset = spacing * sqrt(1. / 12.);
44 bool evenLayer =
true;
46 size_t id = defaultParticle.getID();
47 for (
double z = boxMin[2]; z < boxMax[2]; z += spacingLayer) {
48 double starty = evenLayer ? boxMin[1] : boxMin[1] + yOffset;
49 bool evenRow = evenLayer;
50 for (
double y = starty; y < boxMax[1]; y += spacingRow) {
51 double startx = evenRow ? boxMin[0] : boxMin[0] + xOffset;
52 for (
double x = startx; x < boxMax[0]; x += spacing) {
53 auto p = defaultParticle;
56 container.addParticle(p);
58 evenRow = not evenRow;
60 evenLayer = not evenLayer;
typename Container::ParticleType value
The Particle Type.
Definition: ParticleTypeTrait.h:24