22inline constexpr std::array<std::array<double, 3>, 4>
fccBasis = {{
37inline size_t getNumberOfParticles(
const std::array<double, 3> &boxMin,
const std::array<double, 3> &boxMax,
38 const double spacing = 1.0,
const bool centeredAlignment =
false) {
43 const double latticeConstant = std::sqrt(2.0) * spacing;
44 std::array<double, 3> offset = {0.0, 0.0, 0.0};
45 if (centeredAlignment) {
46 offset = {latticeConstant / 4.0, latticeConstant / 4.0, latticeConstant / 4.0};
49 auto countIndices = [&](
const double bMin,
const double bMax,
const double offsetVal,
50 const double basisVal) ->
size_t {
51 const double startPos = bMin + offsetVal + basisVal * latticeConstant;
52 if (startPos >= bMax) {
55 const double remaining = bMax - startPos;
56 const auto count =
static_cast<size_t>(std::ceil(remaining / latticeConstant));
60 size_t totalCount = 0;
62 size_t basisCount = 1;
63 for (
size_t d = 0; d < 3; ++d) {
64 basisCount *= countIndices(boxMin[d], boxMax[d], offset[d], basis[d]);
66 totalCount += basisCount;
82template <
class Container>
83void fillWithParticles(Container &container,
const std::array<double, 3> &boxMin,
const std::array<double, 3> &boxMax,
86 const double spacing = 1.0,
const bool centeredAlignment =
false) {
87 const double latticeConstant = std::sqrt(2.0) * spacing;
89 std::array<double, 3> offset = {0.0, 0.0, 0.0};
90 if (centeredAlignment) {
91 offset = {latticeConstant / 4.0, latticeConstant / 4.0, latticeConstant / 4.0};
94 const size_t numCellsX = std::max<size_t>(1, std::ceil((boxMax[0] - boxMin[0]) / latticeConstant));
95 const size_t numCellsY = std::max<size_t>(1, std::ceil((boxMax[1] - boxMin[1]) / latticeConstant));
96 const size_t numCellsZ = std::max<size_t>(1, std::ceil((boxMax[2] - boxMin[2]) / latticeConstant));
98 size_t id = defaultParticle.getID();
99 for (
size_t z = 0; z < numCellsZ; ++z) {
100 for (
size_t y = 0; y < numCellsY; ++y) {
101 for (
size_t x = 0; x < numCellsX; ++x) {
102 const std::array<double, 3> cellOrigin = {
103 boxMin[0] +
static_cast<double>(x) * latticeConstant + offset[0],
104 boxMin[1] +
static_cast<double>(y) * latticeConstant + offset[1],
105 boxMin[2] +
static_cast<double>(z) * latticeConstant + offset[2],
107 for (
const auto &basis :
fccBasis) {
108 const std::array<double, 3> pos = {
109 cellOrigin[0] + basis[0] * latticeConstant,
110 cellOrigin[1] + basis[1] * latticeConstant,
111 cellOrigin[2] + basis[2] * latticeConstant,
113 if (pos[0] >= boxMin[0] and pos[0] < boxMax[0] and pos[1] >= boxMin[1] and pos[1] < boxMax[1] and
114 pos[2] >= boxMin[2] and pos[2] < boxMax[2]) {
115 auto p = defaultParticle;
118 container.addParticle(p);
Generator for an face-centered cubic (FCC) particle grid.
Definition: FCCGenerator.h:17
void fillWithParticles(Container &container, const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const typename autopas::utils::ParticleTypeTrait< Container >::value &defaultParticle=typename autopas::utils::ParticleTypeTrait< Container >::value(), const double spacing=1.0, const bool centeredAlignment=false)
Fills any container with particles arranged in a conventional Face-Centered Cubic (FCC) lattice.
Definition: FCCGenerator.h:83
size_t getNumberOfParticles(const std::array< double, 3 > &boxMin, const std::array< double, 3 > &boxMax, const double spacing=1.0, const bool centeredAlignment=false)
Calculates the number of particles generated in an FCC lattice within [boxMin, boxMax) in O(1) time.
Definition: FCCGenerator.h:37
constexpr std::array< std::array< double, 3 >, 4 > fccBasis
Basis coordinates for conventional cubic FCC unit cell normalized by lattice constant a.
Definition: FCCGenerator.h:22
typename Container::ParticleType value
The Particle Type.
Definition: ParticleTypeTrait.h:24