HILA
Loading...
Searching...
No Matches
clusters.h File Reference

provides cluster finding tools More...

#include "hila.h"
#include <algorithm>
#include "gpucub.h"
Include dependency graph for clusters.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  hila
 Implement hila::swap for gauge fields.
 

Detailed Description

provides cluster finding tools

clusters are grown with the help of auxiliary Field variable of type Field<uint8_t>. Elements of this accept values 0 .. 254, allowing for 255 cluster classes. Special value hila::clusters::background indicates neutral, background sites.

Example:

#include "clusters.h"

Field<uint8_t> cltype; // initialize field cltype to values 0, 1 or background onsites(ALL) { if (<some condition 1>) cltype[X] = 0; else if (condition 2>) cltype[X] = 1; else cltype[X] = hila::clusters::background; }

// create connected clusters of sites with cltype values 0 and 1 hila::clusters cl(cltype);

// above is equivalent to "hila::clusters cl; cl.find(cltype);"

if (hila::myrank() == 0) { hila::out << "Got " << cl.number() << " clusters\n"; for (int i = 0; i < cl.number(); i++) { hila::out << "Cluster " << i << " type " << cl.type(i) << " size " << cl.size(i) << '
'; }

}

Functions:

Constructor: initialize with constructor hila::clusters(const Field<uint8_t> & clustertype) Example: hila::clusters cluster(cltype); // initialize var cluster

where cltype is of type Field<uint8_t>. This constructor builds connected clusters of the sites with the same cltype value. Special value of hila::clusters::background are ignored.

Above is equivalent with hila::clusters cluster; cluster.find(cltype);

Note: initalization is a relatively expensive operation

size_t hila::clusters::number() - return the total number of clusters. Example: hila::out0 << "Found " << cluster.number() << " clusters\n";

int64_t hila::clusters::size(size_t cl_number) - return the size of cluster number cl_number Example: hila::out0 << "Size of cluster 0 is " << cluster.size(0) << '
';

uint8_t hila::clusters::type(size_t cl_number) - return the cluster type hila::out0 << "Type of cluster 0 is " << cluster.size(0) << '
';

std::vector<SiteIndex> hila::clusters::sites(size_t cl_number) - return the sites of cluster cl_number Example: print the coordinates of cluster number 0: auto clsites = cluster.sites(0); for (auto & r : clsites) { hila::out0 << r.coordinates() << '
; } Note: .sites() must be called by all MPI ranks, otherwise deadlock occurs

int64_t hila::clusters::area(size_t cl_number) - return the area of the cluster Area is defined by the number of links where one end belongs to the cluster, another does not. Note: .area() must be called by all MPI ranks

Definition in file clusters.h.