40 m_cluster_identities.clear();
49 auto const box_geo_handle = get_box_geo();
50 auto const &box_geo = *box_geo_handle;
53 this->add_pair(p1, p2);
60 auto const box_geo_handle = get_box_geo();
61 auto const &box_geo = *box_geo_handle;
63 for (
const auto &p : partCfg) {
64 for (
auto const bond : p.bonds()) {
65 if (bond.partner_ids().size() == 1) {
83 if (!m_pair_criterion) {
88 if (m_pair_criterion->decide(p1, p2)) {
93 const int cid = get_next_free_cluster_id();
115 m_cluster_identities[cid1] = cid2;
116 }
else if (cid1 < cid2) {
117 m_cluster_identities[cid2] = cid1;
127void ClusterStructure::merge_clusters() {
133 std::vector<std::pair<int, int>> pending_changes;
137 auto const merged_cid = find_id_for(cid);
140 pending_changes.emplace_back(pid, merged_cid);
142 if (not
clusters.contains(merged_cid)) {
143 clusters[merged_cid] = std::make_shared<Cluster>(m_box_geo);
148 for (
auto &[pid, merged_cid] : pending_changes) {
156 clusters[cid]->particles.emplace_back(pid);
160 for (
auto const &cluster :
clusters |
std::views::values) {
161 std::ranges::sort(cluster->particles);
165int ClusterStructure::find_id_for(
int x)
const {
167 while (m_cluster_identities.contains(cid)) {
168 cid = m_cluster_identities.at(cid);
173int ClusterStructure::get_next_free_cluster_id() {
176 max_id = *std::ranges::max_element(
cluster_id | std::views::values);
std::map< int, int > cluster_id
Map between particle ids and corresponding cluster ids.
void clear()
Clear data structures.
void run_for_bonded_particles()
Run cluster analysis, consider pairs of particles connected by a bonded interaction.
void run_for_all_pairs()
Run cluster analysis, consider all particle pairs.
bool part_of_cluster(Particle const &p) const
Is particle p part of a cluster.
std::map< int, std::shared_ptr< Cluster > > clusters
Map holding the individual clusters.
Particle cache on the head node.
This file contains the errorhandling code for severe errors, like a broken bond or illegal parameter ...
#define runtimeErrorMsg()
void for_each_pair(ForwardIterator first, ForwardIterator last, BinaryOp op)
Execute op for each pair of elements in [first, last) once.
const Particle & get_particle_data(int p_id)
Get particle data.
Particles creation and deletion.
Struct holding all information for one particle.