ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/cluster_analysis/ClusterStructure.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include "
BoxGeometry.hpp
"
23
#include "pair_criteria/PairCriterion.hpp"
24
25
#include "
Cluster.hpp
"
26
#include "
Particle.hpp
"
27
28
#include <map>
29
#include <memory>
30
31
namespace
ClusterAnalysis
{
32
33
/** @brief Holds the result and parameters of a cluster analysis */
34
class
ClusterStructure
{
35
public
:
36
ClusterStructure
();
37
/** @brief Map holding the individual clusters. The key is an integer cluster
38
* id */
39
std::map<int, std::shared_ptr<Cluster>>
clusters
;
40
/** @brief Map between particle ids and corresponding cluster ids */
41
std::map<int, int>
cluster_id
;
42
/** @brief Clear data structures */
43
void
clear
();
44
/** @brief Run cluster analysis, consider all particle pairs */
45
void
run_for_all_pairs
();
46
/** @brief Run cluster analysis, consider pairs of particles connected by a
47
* bonded interaction */
48
void
run_for_bonded_particles
();
49
/** Is particle p part of a cluster */
50
bool
part_of_cluster
(
const
Particle
&p);
51
/** Sets the pair criterion which decides if two particles are neighbors */
52
void
53
set_pair_criterion
(std::shared_ptr<PairCriteria::PairCriterion>
const
&c) {
54
m_pair_criterion = c;
55
}
56
57
PairCriteria::PairCriterion
const
&
pair_criterion
()
const
{
58
return
*m_pair_criterion;
59
}
60
61
void
attach
(std::weak_ptr<BoxGeometry const>
const
&box_geo) {
62
m_box_geo = box_geo;
63
}
64
65
private
:
66
/** @brief Clusters that turn out to be the same during the analysis process
67
* (i.e., if two particles are neighbors that already belong to different
68
* clusters
69
*/
70
std::map<int, int> m_cluster_identities;
71
72
/** @brief pair criterion which decides whether two particles are neighbors */
73
std::shared_ptr<PairCriteria::PairCriterion> m_pair_criterion;
74
75
/** @brief Consider an individual pair of particles during cluster analysis */
76
void
add_pair(
const
Particle
&p1,
const
Particle
&p2);
77
/** Merge clusters and populate their structures */
78
void
merge_clusters();
79
/** @brief Follow a chain of cluster identities during analysis */
80
inline
int
find_id_for(
int
x);
81
/** @brief Get next free cluster id */
82
inline
int
get_next_free_cluster_id();
83
void
sanity_checks()
const
;
84
auto
get_box_geo()
const
{
85
auto
ptr = m_box_geo.lock();
86
assert(ptr);
87
return
ptr;
88
}
89
mutable
std::weak_ptr<BoxGeometry const> m_box_geo;
90
};
91
92
}
// namespace ClusterAnalysis
BoxGeometry.hpp
Particle.hpp
ClusterAnalysis::ClusterStructure
Holds the result and parameters of a cluster analysis.
Definition
core/cluster_analysis/ClusterStructure.hpp:34
ClusterAnalysis::ClusterStructure::cluster_id
std::map< int, int > cluster_id
Map between particle ids and corresponding cluster ids.
Definition
core/cluster_analysis/ClusterStructure.hpp:41
ClusterAnalysis::ClusterStructure::ClusterStructure
ClusterStructure()
Definition
ClusterStructure.cpp:37
ClusterAnalysis::ClusterStructure::clear
void clear()
Clear data structures.
Definition
ClusterStructure.cpp:39
ClusterAnalysis::ClusterStructure::part_of_cluster
bool part_of_cluster(const Particle &p)
Is particle p part of a cluster.
Definition
ClusterStructure.cpp:45
ClusterAnalysis::ClusterStructure::run_for_bonded_particles
void run_for_bonded_particles()
Run cluster analysis, consider pairs of particles connected by a bonded interaction.
Definition
ClusterStructure.cpp:66
ClusterAnalysis::ClusterStructure::pair_criterion
PairCriteria::PairCriterion const & pair_criterion() const
Definition
core/cluster_analysis/ClusterStructure.hpp:57
ClusterAnalysis::ClusterStructure::run_for_all_pairs
void run_for_all_pairs()
Run cluster analysis, consider all particle pairs.
Definition
ClusterStructure.cpp:50
ClusterAnalysis::ClusterStructure::clusters
std::map< int, std::shared_ptr< Cluster > > clusters
Map holding the individual clusters.
Definition
core/cluster_analysis/ClusterStructure.hpp:39
ClusterAnalysis::ClusterStructure::attach
void attach(std::weak_ptr< BoxGeometry const > const &box_geo)
Definition
core/cluster_analysis/ClusterStructure.hpp:61
ClusterAnalysis::ClusterStructure::set_pair_criterion
void set_pair_criterion(std::shared_ptr< PairCriteria::PairCriterion > const &c)
Sets the pair criterion which decides if two particles are neighbors.
Definition
core/cluster_analysis/ClusterStructure.hpp:53
PairCriteria::PairCriterion
Criterion which returns a true/false value for a pair of particles.
Definition
core/pair_criteria/PairCriterion.hpp:29
ClusterAnalysis
Definition
Cluster.cpp:43
Cluster.hpp
Particle
Struct holding all information for one particle.
Definition
Particle.hpp:395
src
core
cluster_analysis
ClusterStructure.hpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8