AutoPas  3.0.0
Loading...
Searching...
No Matches
Functions
TwoCellsInteractionHitrateGenerator.h File Reference
#include <algorithm>
#include <array>
#include <cmath>
#include <random>
#include <vector>
#include "autopas/particles/OwnershipState.h"
#include "autopas/utils/ExceptionHandler.h"
Include dependency graph for TwoCellsInteractionHitrateGenerator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<class Container_T , class Particle_T >
void autopasTools::generators::TwoCellsInteractionHitrateGenerator::fillWithParticles (Container_T &cell1, Container_T &cell2, const std::array< double, 3 > &boxMin1, const std::array< double, 3 > &boxMax1, const std::array< double, 3 > &boxMin2, const std::array< double, 3 > &boxMax2, std::size_t n, double hitrate, double cutoff, const Particle_T &defaultParticle=Particle_T{}, unsigned int seed=42)
 Fills two cells adjacent in x with n particles each such that exactly round(n * hitrate) particles per cell have a guaranteed in-range partner in the other cell (3D distance < cutoff), and the remaining particles are placed far enough that no cross-cell interaction is possible.
 

Detailed Description

Date
26.06.2026
Author
hmeyran

Function Documentation

◆ fillWithParticles()

template<class Container_T , class Particle_T >
void autopasTools::generators::TwoCellsInteractionHitrateGenerator::fillWithParticles ( Container_T &  cell1,
Container_T &  cell2,
const std::array< double, 3 > &  boxMin1,
const std::array< double, 3 > &  boxMax1,
const std::array< double, 3 > &  boxMin2,
const std::array< double, 3 > &  boxMax2,
std::size_t  n,
double  hitrate,
double  cutoff,
const Particle_T &  defaultParticle = Particle_T{},
unsigned int  seed = 42 
)

Fills two cells adjacent in x with n particles each such that exactly round(n * hitrate) particles per cell have a guaranteed in-range partner in the other cell (3D distance < cutoff), and the remaining particles are placed far enough that no cross-cell interaction is possible.

Preconditions (checked via ExceptionHandler):

  • boxMax1[0] == boxMin2[0] — shared boundary
  • (boxMax1[0] - boxMin1[0]) > 1.2 * cutoff — cell1 x-extent sufficient for far zone (factor is arbitrary)
  • (boxMax2[0] - boxMin2[0]) > 1.2 * cutoff — cell2 x-extent sufficient for far zone (factor is arbitrary)
  • hitrate in [0.0, 1.0]

Particle IDs are assigned sequentially starting from defaultParticle.getID(): cell1 particles: [id0, id0 + n) cell2 particles: [id0 + n, id0 + 2n)

Interaction guarantees:

  • The first k = round(n * hitrate) particles of cell1 are each within cutoff of the corresponding particle (same index) in cell2 (3D distance = 2·dx < cutoff).
  • The remaining n-k far particles have an x-distance >= cutoff to every particle in the other cell, so they produce no cross-cell interactions.
Template Parameters
Container_TAny container supporting addParticle().
Particle_TParticle type; must support setR(), setID(), setOwnershipState(), and getID().
Parameters
cell1First cell (x < boundary).
cell2Second cell (x >= boundary).
boxMin1Minimum coordinates of cell1.
boxMax1Maximum coordinates of cell1. boxMax1[0] must equal boxMin2[0].
boxMin2Minimum coordinates of cell2. boxMin2[0] must equal boxMax1[0].
boxMax2Maximum coordinates of cell2.
nNumber of particles per cell.
hitrateFraction of particles per cell with a guaranteed in-range cross-cell partner. Must be in [0, 1].
cutoffInteraction cutoff radius.
defaultParticleTemplate particle; IDs are assigned sequentially starting from defaultParticle.getID().
seedRandom seed for reproducibility.