Example #1
0
  void 
  Scheduler::addInteractionEventInit(const Particle& part, 
				      const size_t& id) const
  {
    if (part.getID() == id) return;

    //We'll be smart about memory and try to add events evenly on
    //initialisation to all particles
    //
    //This is achieved by only allowing one particle to store the
    //event. But we can't just use sorting (e.g., part.getID() < id) to
    //discriminate which particle gets the event as, on regular
    //lattices, particle 0 will get all of the events for all the
    //particles in its neighborhood!
    //
    //We can mix this up a little, by also testing for odd and evenness
    //and using this to switch which particles are chosen

    size_t val = (part.getID() % 2) + 2 * (id % 2);
    switch (val)//part-id
      {
      case 0: //even-even (accept half)
	if (part.getID() > id) return;      
	break;
      case 1: //odd-even (accept)
	break;
      case 2: //even-odd (reject)
	return;
      case 3: //odd-odd (accept half)
	if (part.getID() < id) return;      
      }

    addInteractionEvent(part, id);
  }
Example #2
0
  void 
  Scheduler::addEvents(Particle& part)
  {  
    Sim->dynamics->updateParticle(part);

    //Add the global events
    for (const shared_ptr<Global>& glob : Sim->globals)
      if (glob->isInteraction(part))
	sorter->push(glob->getEvent(part));
  
    //Add the local cell events
    std::unique_ptr<IDRange> ids(getParticleLocals(part));
    
    for (const size_t id2 : *ids)
      addLocalEvent(part, id2);

    //Now add the interaction events
    ids = getParticleNeighbours(part);
    for (const size_t id2 : *ids)
      addInteractionEvent(part, id2);
  }