SPH
Public Member Functions | List of all members
ICollisionHandler Class Referenceabstract

Abstraction of collision outcome. More...

#include <Collision.h>

Inheritance diagram for ICollisionHandler:
Polymorphic AggregateCollisionHandler ElasticBounceHandler FallbackHandler< TPrimary, TFallback > FragmentationHandler MergingCollisionHandler NullCollisionHandler

Public Member Functions

virtual void initialize (Storage &storage)=0
 
virtual CollisionResult collide (const Size i, const Size j, FlatSet< Size > &toRemove)=0
 Computes the outcome of collision between i-th and j-th particle. More...
 
- Public Member Functions inherited from Polymorphic
virtual ~Polymorphic ()
 

Detailed Description

Abstraction of collision outcome.

Collision can arbitrarily change the number of particles in the storage. It can one or both colliding particles ("merger" or "evaporation"), or it can even add more particles into the storage ("fragmentation"). It is necessary to update all pointers and array views if collision handler returns true, or keep pointers to the arrays (at a cost of double indirection).

Definition at line 29 of file Collision.h.

Member Function Documentation

◆ collide()

virtual CollisionResult ICollisionHandler::collide ( const Size  i,
const Size  j,
FlatSet< Size > &  toRemove 
)
pure virtual

Computes the outcome of collision between i-th and j-th particle.

It is guaranteed that this function is called after initialize has been called (at least once) and that the storage object passed to initialize is valid, so it is allowed (and recommended) to storage a pointer to the storage.

Parameters
i,jIndices of particles in the storage.
toRemoveIndices of particles to be removed from the storage. May already contain some indices, collision handler should only add new indices and it shall not clear the storage.
Returns
True if the collision took place, false to reject the collision.
Todo:
Needs to be generatelized for fragmentation handlers. Currently the function CANNOT change the number of particles as it would invalidate arrayviews and we would lost the track of i-th and j-th particle (which we need for decreasing movement time).

Implemented in FallbackHandler< TPrimary, TFallback >, and MergingCollisionHandler.

◆ initialize()

virtual void ICollisionHandler::initialize ( Storage storage)
pure virtual

The documentation for this class was generated from the following file: