-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Step 1: everything passes the testsuite
- Loading branch information
1 parent
8c90c3d
commit 2eea0c0
Showing
6 changed files
with
202 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
#pragma once | ||
|
||
#include <config/config.hpp> | ||
|
||
#ifdef COLLISION_DETECTION | ||
|
||
#include "nonbonded_interactions/nonbonded_interaction_data.hpp" | ||
#include "bonded_interactions/bonded_interaction_data.hpp" | ||
|
||
|
||
struct CollisionPair; | ||
|
||
namespace Collision{ | ||
enum class CollisionModeType : int { | ||
/** @brief Deactivate collision detection. */ | ||
OFF = 0, | ||
/** @brief Create bond between centers of colliding particles. */ | ||
BIND_CENTERS = 1, | ||
/** | ||
* @brief Create a bond between the centers of the colliding particles, | ||
* plus two virtual sites at the point of collision and bind them | ||
* together. This prevents the particles from sliding against each | ||
* other. Requires VIRTUAL_SITES_RELATIVE. | ||
*/ | ||
BIND_VS = 2, | ||
/** @brief Glue a particle to a specific spot on another particle. */ | ||
GLUE_TO_SURF = 3, | ||
}; | ||
|
||
class MergedProtocol { | ||
public: | ||
MergedProtocol() | ||
: mode(CollisionModeType::OFF), distance(0.), distance_sq(0.), | ||
bond_centers(-1), bond_vs(-1) {} | ||
|
||
/// collision protocol | ||
CollisionModeType mode; | ||
/// distance at which particles are bound | ||
double distance; | ||
// Square of distance at which particle are bound | ||
double distance_sq; | ||
|
||
/// bond type used between centers of colliding particles | ||
int bond_centers; | ||
/// bond type used between virtual sites | ||
int bond_vs; | ||
/// particle type for virtual sites created on collision | ||
int vs_particle_type; | ||
|
||
/// For mode "glue to surface": The distance from the particle which is to be | ||
/// glued to the new virtual site | ||
double dist_glued_part_to_vs; | ||
/// For mode "glue to surface": The particle type being glued | ||
int part_type_to_be_glued; | ||
/// For mode "glue to surface": The particle type to which the virtual site is | ||
/// attached | ||
int part_type_to_attach_vs_to; | ||
/// Particle type to which the newly glued particle is converted | ||
int part_type_after_glueing; | ||
/** Placement of virtual sites for MODE_VS. | ||
* 0=on same particle as related to, | ||
* 1=on collision partner, | ||
* 0.5=in the middle between | ||
*/ | ||
double vs_placement; | ||
/** @brief Validates parameters and creates particle types if needed. */ | ||
void initialize(BondedInteractionsMap &bonded_ias, InteractionsNonBonded &nonbonded_ias); | ||
|
||
auto cutoff() const { | ||
if (mode != CollisionModeType::OFF) { | ||
return distance; | ||
} | ||
return INACTIVE_CUTOFF; | ||
} | ||
|
||
/// Handle queued collisions | ||
bool handle_collisions(CellStructure &cell_structure, BoxGeometry const &box_geo, double min_global_cut, BondedInteractionsMap const &bonded_ias, std::vector<CollisionPair> &local_collision_queue); | ||
|
||
/** @brief Detect (and queue) a collision between the given particles. */ | ||
bool detect_collision(Particle const &p1, Particle const &p2, | ||
double const dist_sq) { | ||
if (dist_sq > distance_sq) | ||
return false; | ||
|
||
// If we are in the glue to surface mode, check that the particles | ||
// are of the right type | ||
if (mode == CollisionModeType::GLUE_TO_SURF) | ||
if (!glue_to_surface_criterion(p1, p2)) | ||
return false; | ||
|
||
// Ignore virtual particles | ||
if (p1.is_virtual() or p2.is_virtual()) | ||
return false; | ||
|
||
// Check, if there's already a bond between the particles | ||
if (pair_bond_exists_on(p1.bonds(), p2.id(), bond_centers)) | ||
return false; | ||
|
||
if (pair_bond_exists_on(p2.bonds(), p1.id(), bond_centers)) | ||
return false; | ||
|
||
/* If we're still here, there is no previous bond between the particles, | ||
we have a new collision */ | ||
|
||
// do not create bond between ghost particles | ||
if (p1.is_ghost() and p2.is_ghost()) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
/** @brief Check additional criteria for the glue_to_surface collision mode */ | ||
bool glue_to_surface_criterion(Particle const &p1, Particle const &p2) const { | ||
return (((p1.type() == part_type_to_be_glued) and | ||
(p2.type() == part_type_to_attach_vs_to)) or | ||
((p2.type() == part_type_to_be_glued) and | ||
(p1.type() == part_type_to_attach_vs_to))); | ||
} | ||
|
||
}; | ||
} | ||
|
||
#endif // COLLISION_DETECTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.