diff --git a/postprocessing/Makefile b/postprocessing/Makefile index 37f6241..93f5363 100644 --- a/postprocessing/Makefile +++ b/postprocessing/Makefile @@ -1,71 +1,77 @@ IDIR =./include CXX=g++ CPPFLAGS=-g -I$(IDIR) -I/home/samarth/codes/voronoi/include -std=c++11 -O3 -w -Wall LDFLAGS=-I$(IDIR) -std=c++11 -O3 -w -Wall POSTFIX=-L/home/samarth/codes/voronoi/lib/ -lvoro++ SRC_DIR = ./src OBJ_DIR = ./obj SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp) OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) BIN_SRC_DIR = ./bin_src BIN_DIR = ./bin -all: unfold radius_of_gyration sq_vs_q pair_correlation percolation load_bearing_paths lr_iq +all: unfold radius_of_gyration sq_vs_q pair_correlation percolation load_bearing_paths lr_iq lbp_brute_force #all: psd_test density_correlation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o density_correlation.o target/density_correlation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ density_correlation.o unfold: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o unfold.o target/unfold.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ unfold.o radius_of_gyration: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o radius_of_gyration.o target/radius_of_gyration.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ radius_of_gyration.o sq_vs_q: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o sq_vs_q.o target/sq_vs_q.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ sq_vs_q.o pair_correlation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o pair_correlation.o target/pair_correlation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ pair_correlation.o psd_test: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o psd_test.o target/psd_test.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ psd_test.o percolation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o percolation.o target/percolation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ percolation.o load_bearing_paths: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o load_bearing_paths.o target/load_bearing_paths.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ load_bearing_paths.o +lbp_brute_force: $(OBJ_FILES) | $(BIN_DIR) + $(CXX) $(CPPFLAGS) -c -o lbp_brute_force.o target/lbp_brute_force.cpp + $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lbp_brute_force.o + + + lr_iq: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lr_iq.o target/lr_iq.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lr_iq.o $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) $(CXX) $(CPPFLAGS) -c -o $@ $< $(BIN_DIR): mkdir $(BIN_DIR) $(OBJ_DIR): mkdir $(OBJ_DIR) clean: rm *.o rm -rf $(BIN_DIR) rm -rf $(OBJ_DIR) diff --git a/postprocessing/include/post.h b/postprocessing/include/post.h index fa36298..d052034 100644 --- a/postprocessing/include/post.h +++ b/postprocessing/include/post.h @@ -1,227 +1,239 @@ #include <iostream> #include <cmath> #include <cstdlib> #include <cstring> #include <sys/types.h> #include <sys/stat.h> #include <vector> #include <sstream> #include <fstream> #include <random> //#include <voro++/voro++.hh> #include <map> #include <algorithm> +#include <bits/stdc++.h> #ifndef POSTPROCESSING_H #define POSTPROCESSING_H namespace post_p{ class postprocessing { public: postprocessing(char *config_filename); ~postprocessing(); void read_params(); void read_config(); void memory_allocation_function(); std::vector<std::string> split_string_by_delimiter(const std::string& s, char delimiter); void read_params_parser(char *config_filename); void read_config_parser(char *config_filename); int dim() const; int numParticles() const; int maxAttachments() const; int totalClusters() const; double lo_hi(const int axis, const int limit) const; double& lo_hi(const int axis, const int limit); double L(const int axis) const; double& L(const int axis); double halfL(const int axis) const; double& halfL(const int axis); int periodic(const int axis) const; int& periodic(const int axis); double posDiff(const int axis) const; double& posDiff(const int axis); double pos(const int i, const int axis) const; double& pos(const int i, const int axis); int numAttachments(const int i) const; int& numAttachments(const int i); int original_seed(const int i) const; int& original_seed(const int i); int current_seed(const int i) const; int& current_seed(const int i); double diameter(const int i) const; double& diameter(const int i); double radius(const int i) const; double& radius(const int i); int unfoldedAttachments(const int i) const; int& unfoldedAttachments(const int i); int attachment(const int i, const int j) const; int& attachment(const int i, const int j); bool is_placed(const int i) const; bool& is_placed(const int i); double unfolded_coords(const int i, const int axis) const; double& unfolded_coords(const int i, const int axis); double delta_coords(const int i, const int axis) const; double& delta_coords(const int i, const int axis); int delta_hist(const int i) const; int& delta_hist(const int i); int cluster_percolation(const int i, const int axis) const; int& cluster_percolation(const int i, const int axis); int load_bearing_paths(const int i, const int axis) const; int& load_bearing_paths(const int i, const int axis); double get_periodic_image(double x, const int axis); void print_positions(); void calc_rij(); void dump_rij_file(); void dump_rij_file(char *filename); void dump_rij_hist_file(double bin_size); void dump_rij_hist_file(double bin_size, char *filename); void calc_rij_hist(double bin_size); void dump_unfolded_file(); void dump_unfolded_file(char *filename); void dump_density_correlation(double bin_size); void dump_density_correlation(double bin_size, char *filename); void dump_percolation_file(); void dump_percolation_file(char *filename); void dump_load_bearing_paths_file(char *filename); //void dump_load_bearing_paths_file(int origin, char *filename); void dump_load_bearing_paths_file(); void dump_rog(); void dump_rog(char *filename); void init_unfolding(); void init_unfolding_for_lbp(); void unfold(const int prev, const int next); void unfold_for_lbp(const int prev, const int next, bool build_pb); void calc_unfolded_rij(); void dump_unfolded_hist_file(double bin_size); void calc_unfolded_hist(double bin_size); void dump_scattering_function(double q_min, double q_max, int num_q); void dump_scattering_function(double q_min, double q_max, int num_q, char *filename); //void dump_lr_scattering_function(double q_min, double q_max, int num_q, double bin_size); void dump_lr_scattering_function(double q_min, double q_max, int num_q, double bin_size, char *filename); void calc_scattering_function(double q_min, double q_max, int num_q); void calc_density_correlation(double bin_size); void save_config(); void save_unfolded_config(); void save_unfolded_config(char *filename); void get_headers(); bool check_percolation(); double calc_rog(); void psd(int total_iters); void save_radius_distribution(); void save_radius_distribution(char *filename); void init_unfolding_without_recursion(); void place_attachments(int i); void build_bond_map(); void percolation_detection(); void reset_unfolding_params(); void switch_off_bonds(std::pair<int,int> bond); void switch_on_bonds(std::pair<int,int> bond); void create_subsystem(); void erase_subsystem(); void print_lbp(); void postprocess_lbp(); void switch_off_alt_lbp(int i); void reset_bond_map(bool status); void activate_path(std::vector<std::pair<int,int>> bonds, bool status); + void shred_path(int i); + void isolation_routine(); + void martin_test(); + void lbp_brute_force(); + void makeCombiUtil(int n, int left, int k); + void makeCombi(int n, int k); + private: std::mt19937 generator; std::uniform_real_distribution<double> dis; int headers_; int N_; int D_; int max_attachments_; int folded_; int lattice_; int iters_; int columns_; double seed_mass_; double alpha_; double phi_; double *lo_hi_; double *L_; double *halfL_; double *diameter_; double *radius_; int *periodic_; double *posDiff_; int *posDiff_int_; double *pos_; int *num_attachments_; int *attachment_; int *original_seed_; int *current_seed_; double *r_ij_; double *r_ij_hist_; int *rho_hist_; bool *is_placed_; double *unfolded_coords_; int temp_next; double *delta_coords_; double q_min; double q_max; double dq; int num_q; double *sq_; double *lr_sq_; int *unfolded_num_attachments_; int *delta_hist_; int max_delta_; int *cluster_percolation_; int *load_bearing_paths_; int *temp_lbp_; int totalClusters_; int N_pairs_; int r_ij_hist_bins_; bool lattice_flag_ = false; bool N_flag_ = false; bool D_flag_ = false; bool max_attachments_flag_ = false; bool L_flag_ = false; bool periodic_flag_ = false; bool folded_flag_ = false; bool iters_flag_ = false; bool seed_mass_flag_ = false; bool alpha_flag_ = false; bool phi_flag_ = false; bool columns_flag_ = false; double *radius_dis; double *centres; int *type_dis; int max_psd_iters; int total_lbp; std::map<std::pair<int,int>, int> bond_map_status; std::vector<std::pair<int,int>> percolating_bonds; std::pair<int,int> temp_pair; int *divisors; int *bond_bit_repr; std::vector<int> path_components; std::vector<std::pair<int,int>> current_path; bool path_percolation; std::vector<std::vector<std::pair<int,int>>> final_percolating_bonds; std::vector<std::vector<std::pair<int,int>>> weak_links; + std::vector<bool> pb_status; + + std::vector<std::vector<int> > ans; + std::vector<int> tmp; }; } #endif diff --git a/postprocessing/src/percolation_algo.cpp b/postprocessing/src/percolation_algo.cpp index 6bc8177..b92bca0 100644 --- a/postprocessing/src/percolation_algo.cpp +++ b/postprocessing/src/percolation_algo.cpp @@ -1,647 +1,859 @@ #include <post.h> namespace post_p { +void postprocessing::makeCombiUtil(int n, int left, int k) +{ + // Pushing this vector to a vector of vector + if (k == 0) { + ans.push_back(tmp); + return; + } + + // i iterates from left to n. First time + // left will be 1 + for (int i = left; i < n; ++i) + { + tmp.push_back(i); + makeCombiUtil(n, i + 1, k - 1); + + // Popping out last inserted element + // from the vector + tmp.pop_back(); + } +} + +// Prints all combinations of size k of numbers +// from 1 to n. +void postprocessing::makeCombi(int n, int k) +{ + makeCombiUtil(n, 0, k); +} + + void postprocessing::build_bond_map() { for (int i = 0; i < numParticles(); i++){ for (int j = 0; j < numAttachments(i); j++) bond_map_status.insert({{i,attachment(i,j)}, 1}); } } void postprocessing::switch_off_bonds(std::pair<int,int> bond) { bond_map_status[bond] = 0; temp_pair.first = bond.second; temp_pair.second = bond.first; bond_map_status[temp_pair] = 0; } void postprocessing::switch_on_bonds(std::pair<int,int> bond) { bond_map_status[bond] = 1; temp_pair.first = bond.second; temp_pair.second = bond.first; bond_map_status[temp_pair] = 1; } void postprocessing::activate_path(std::vector<std::pair<int,int>> bonds, bool status) { for (int i = 0; i < bonds.size(); i++){ if (status) switch_on_bonds(bonds[i]); else switch_off_bonds(bonds[i]); } } void postprocessing::reset_bond_map(bool status) { if (status) { for (int i = 0; i < numParticles(); i++){ for (int j = 0; j < numAttachments(i); j++) { switch_on_bonds({i, attachment(i,j)}); } } } else { for (int i = 0; i < numParticles(); i++){ for (int j = 0; j < numAttachments(i); j++) { switch_off_bonds({i, attachment(i,j)}); } } } } void postprocessing::create_subsystem() { reset_bond_map(false); for (int i = 0; i < current_path.size(); i++) switch_on_bonds(current_path[i]); } void postprocessing::erase_subsystem() { reset_bond_map(true); for (int i = 0; i < final_percolating_bonds.size(); i++){ - for (int j = 0; j < final_percolating_bonds[i].size(); j++) { - switch_off_bonds(final_percolating_bonds[i][j]); + if (pb_status[i]) { + + for (int j = 0; j < final_percolating_bonds[i].size(); j++) { + + switch_off_bonds(final_percolating_bonds[i][j]); + + } } } } void postprocessing::switch_off_alt_lbp(int index) { for (int i = 0; i < final_percolating_bonds.size(); i++){ - if (i != index){ + if ((i != index) && (pb_status[i])) { + //if (i != index) { for (int j = 0; j < final_percolating_bonds[i].size(); j++) switch_off_bonds(final_percolating_bonds[i][j]); } } } void postprocessing::reset_unfolding_params() { for (int j = 0; j < numParticles(); j++){ is_placed(j) = false; for (int axis = 0; axis < dim(); axis++) unfolded_coords(j,axis) = 0.; } for (int axis = 0; axis < dim(); axis++) temp_lbp_[axis] = 0; } void postprocessing::print_lbp() { /*for (int i = 0; i < final_percolating_bonds.size(); i++){ std::cout<<"lbp "<<i<<" = \t"; for (int j = 0; j < final_percolating_bonds[i].size(); j++) { std::cout<<final_percolating_bonds[i][j].first<<"-"<<final_percolating_bonds[i][j].second<<"\t"; } std::cout<<"\n"; }*/ for (int i = 0; i < weak_links.size(); i++){ std::cout<<"lbp "<<i<<" = \t"; for (int j = 0; j < weak_links[i].size(); j++) { std::cout<<weak_links[i][j].first<<"-"<<weak_links[i][j].second<<"\t"; } std::cout<<"\n"; } } +void postprocessing::isolation_routine() +{ + + reset_unfolding_params(); + + for (int i = 0; i < numParticles(); i++){ + + if (is_placed(i) == false){ + path_percolation = false; + path_components.clear(); + current_path.clear(); + unfold_for_lbp(i,i,true); + + if (path_percolation == true){ + create_subsystem(); + percolation_detection(); + path_percolation = true; + total_lbp++; + erase_subsystem(); + break; + } + + } + + + } + +} void postprocessing::init_unfolding_for_lbp() { build_bond_map(); + martin_test(); - bool build_pb = false; + /*bool build_pb = false; int ref_axis = 0; total_lbp = 0; for (int i = 0; i < numParticles(); i++){ for (int axis = 0; axis < dim(); axis++){ cluster_percolation(i,axis) = 0; } } do { - reset_unfolding_params(); - - for (int i = 0; i < numParticles(); i++){ - - if (is_placed(i) == false){ - - path_percolation = false; - path_components.clear(); - current_path.clear(); - unfold_for_lbp(i,i,true); - - if (path_percolation == true){ - create_subsystem(); - percolation_detection(); - path_percolation = true; - - /*for (int axis = 0; axis < dim(); axis++){ - std::cout<<"temp_lbp_"<<axis<<"="<<temp_lbp_[axis]<<std::endl; - cluster_percolation(total_lbp, axis) = temp_lbp_[axis]; - }*/ - - - total_lbp++; - erase_subsystem(); - break; - } - - } - - - } + isolation_routine(); } while (path_percolation); - postprocess_lbp(); + postprocess_lbp();*/ //print_lbp(); } void postprocessing::percolation_detection() { percolating_bonds.clear(); + int size; for (int index = 0; index < current_path.size(); index++){ reset_unfolding_params(); switch_off_bonds(current_path[index]); path_percolation = false; for (int i = 0; i < path_components.size(); i++){ if (is_placed(path_components[i]) == false){ unfold_for_lbp(path_components[i],path_components[i],false); if (path_percolation == true) break; } } if (path_percolation == false) percolating_bonds.push_back(current_path[index]); switch_on_bonds(current_path[index]); } + //pb_status[final_percolating_bonds.size()] = 1; + //std::cout<<"size = "<<final_percolating_bonds.size()<<std::endl; final_percolating_bonds.push_back(percolating_bonds); + pb_status.push_back(true); + + +} + +void postprocessing::shred_path(int index) +{ + + reset_bond_map(true); + switch_off_alt_lbp(index); + switch_off_bonds(final_percolating_bonds[index][0]); + isolation_routine(); + + for (int i = 0; i < final_percolating_bonds[index].size(); i++) + std::cout<<final_percolating_bonds[index][i].first<<"-"<<final_percolating_bonds[index][i].second<<","; + + std::cout<<"\n"; + + index = final_percolating_bonds.size() - 1; + + for (int i = 0; i < final_percolating_bonds[index].size(); i++) + std::cout<<final_percolating_bonds[index][i].first<<"-"<<final_percolating_bonds[index][i].second<<","; + + std::cout<<"\n"; + + do { + + isolation_routine(); + + } while (path_percolation); + } void postprocessing::postprocess_lbp() { + bool active_flag; + for (int i = 0; i < final_percolating_bonds.size(); i++){ + //std::cout<<"size = "<<final_percolating_bonds.size()<<std::endl; + reset_bond_map(true); percolating_bonds.clear(); switch_off_alt_lbp(i); + active_flag = true; for (int j = 0; j < final_percolating_bonds[i].size(); j++) { switch_off_bonds(final_percolating_bonds[i][j]); reset_unfolding_params(); path_percolation = false; for (int k = 0; k < numParticles(); k++){ if (is_placed(k) == false){ unfold_for_lbp(k,k,false); if (path_percolation == true) break; } } - if (path_percolation == false) + if (path_percolation == false) { percolating_bonds.push_back(final_percolating_bonds[i][j]); + active_flag = false; + } switch_on_bonds(final_percolating_bonds[i][j]); } - weak_links.push_back(percolating_bonds); + if (active_flag) { + pb_status[i] = false; + shred_path(i); + } + + else { + weak_links.push_back(percolating_bonds); + } } } void postprocessing::unfold_for_lbp(const int prev, const int next, bool build_pb) { for (int axis = 0; axis < dim(); axis++) posDiff(axis) = get_periodic_image(pos(next,axis) - pos(prev,axis), axis); for (int axis = 0; axis < dim(); axis++){ if (prev == next) unfolded_coords(next,axis) = pos(prev,axis) + posDiff(axis); else unfolded_coords(next,axis) = unfolded_coords(prev,axis) + posDiff(axis); } is_placed(next) = true; if (build_pb) path_components.push_back(next); for (int att = 0; att < numAttachments(next); att++) { - if (path_percolation) - break; + //if (path_percolation) + //break; temp_next = attachment(next, att); if (bond_map_status[{next, temp_next}] == 1){ if ((build_pb == true)) { if(std::find(current_path.begin(), current_path.end(), std::make_pair(temp_next, next)) == current_path.end()) { current_path.push_back({next, temp_next}); } } if (is_placed(temp_next) == false){ unfoldedAttachments(next) = unfoldedAttachments(next) + 1; unfoldedAttachments(temp_next) = unfoldedAttachments(temp_next) + 1; unfold_for_lbp(next, temp_next, build_pb); } else { for (int axis = 0; axis < dim(); axis++) { posDiff(axis) = unfolded_coords(temp_next, axis) - unfolded_coords(next, axis); if ((posDiff(axis) > halfL(axis)) || (posDiff(axis) < -halfL(axis))){ cluster_percolation(total_lbp,axis) = 1; temp_lbp_[axis]++; path_percolation = true; } } } } } } +void postprocessing::martin_test() +{ + + reset_bond_map(true); + + std::vector<std::pair<int,int>> test_bonds; + + test_bonds.push_back({170,3101}); + test_bonds.push_back({483,736}); + test_bonds.push_back({1477,1905}); + test_bonds.push_back({683,1700}); + //test_bonds.push_back({1965,2576}); + + for (int i = 0; i < test_bonds.size(); i++) + switch_off_bonds(test_bonds[i]); + + path_percolation = false; + reset_unfolding_params(); + + + for (int i = 0; i < numParticles(); i++){ + + if (is_placed(i) == false){ + std::cout<<"i="<<i<<std::endl; + unfold_for_lbp(i, i, false); + } + + if (path_percolation) + std::cout<<"still percolating"<<std::endl; + + } + + if (!path_percolation) + std::cout<<"no percolation at all"<<std::endl; + + +} + +void postprocessing::lbp_brute_force() +{ + + reset_bond_map(true); + std::vector<std::pair<int,int>> unique_bonds; + + int num_bonds = 0; + int bond_sum = 0; + + for (int i = 0; i < numParticles(); i++){ + for (int j = 0; j < numAttachments(i); j++){ + + if (std::find(unique_bonds.begin(), unique_bonds.end(), std::make_pair(attachment(i,j),i)) == unique_bonds.end()) { + + unique_bonds.push_back({i, attachment(i,j)}); + num_bonds++; + + } + + } + } + + /*for (int i = 1; i <= 2; i++){ + std::cout<<"i = "<<i<<std::endl; + + tmp.clear(); + ans.clear(); + + makeCombi(num_bonds, i); + + for (int j = 0; j < ans.size(); j++){ + for (int k = 0; k < ans[i].size(); k++){ + std::cout<<ans[j][k]<<"\t"; + } + std::cout<<"\n"; + } + + }*/ + + + for (int i = 1; i < num_bonds; i++) { + + tmp.clear(); + ans.clear(); + + makeCombi(num_bonds, i); + + for (int j = 0; j < ans.size(); j++){ + + reset_bond_map(true); + + for (int k = 0; k < ans[j].size(); k++){ + + switch_off_bonds(unique_bonds[ans[j][k]]); + + } + + path_percolation = false; + reset_unfolding_params(); + + for (int index = 0; index < numParticles(); index++){ + + if (is_placed(index) == false){ + unfold_for_lbp(index, index, false); + } + + } + + //std::cout<<"pp = "<<path_percolation<<std::endl; + + if (!path_percolation){ + + for (int k = 0; k < ans[j].size(); k++) + std::cout<<unique_bonds[ans[j][k]].first<<"-"<<unique_bonds[ans[j][k]].second<<"\n"; + + break; + + } + + } + + if (!path_percolation){ + break; + } + + + } + + + +} + +} /*void postprocessing::percolation_detection() { int lbp_min; int i_min; int bond_sum; for (int axis = 0; axis < dim(); axis++){ lbp_min = load_bearing_paths(10,axis); i_min=10; /*for (int i = 0; i < numParticles(); i++){ if (load_bearing_paths(i,axis) < lbp_min){ lbp_min = load_bearing_paths(i,axis); i_min = i; } } if (lbp_min > 0) { for (int j = 0; j < numParticles(); j++){ is_placed(j) = false; unfoldedAttachments(j) = 0; for (int axis_2 = 0; axis_2 < dim(); axis_2++) unfolded_coords(j,axis_2) = 0.; } for (int axis_2 = 0; axis_2 < dim(); axis_2++) temp_lbp_[axis_2] = 0; percolating_bonds.clear(); unfold_for_lbp(i_min,i_min, true, axis); lbp_min = percolating_bonds.size(); std::cout<<"lbp_min = "<<lbp_min<<std::endl; divisors = (int*)malloc(sizeof(int) * lbp_min); bond_bit_repr = (int*)malloc(sizeof(int) * lbp_min); for (int i = 0; i < lbp_min; i++) divisors[i] = std::pow(2, (lbp_min-1-i)); //while (temp_lbp_[axis] != 0){ for (int i = (std::pow(2,lbp_min)-1); i >= 0; i--) { for (int j = 0; j < lbp_min; j++) bond_bit_repr[j] = (i/divisors[j])%2; /*std::cout<<"i = "<<i<<"\t"; for (int j = 0; j < lbp_min; j++) std::cout<<bond_bit_repr[j]; std::cout<<"\n"; for (int j = 0; j < lbp_min; j++) { bond_map_status[{percolating_bonds[j].first, percolating_bonds[j].second}] = bond_bit_repr[j]; bond_map_status[{percolating_bonds[j].second, percolating_bonds[j].first}] = bond_bit_repr[j]; } for (int j = 0; j < numParticles(); j++){ is_placed(j) = false; unfoldedAttachments(j) = 0; for (int axis_2 = 0; axis_2 < dim(); axis_2++) unfolded_coords(j,axis_2) = 0.; } for (int axis_2 = 0; axis_2 < dim(); axis_2++) temp_lbp_[axis_2] = 0; unfold_for_lbp(i_min, i_min, false, axis); /*for (int j = 0; j < numParticles(); j++){ if (is_placed(j) == false) std::cout<<"problem here"<<std::endl; } if (temp_lbp_[axis] == 0){ bond_sum = 0; for (int j = 0; j < lbp_min; j++) bond_sum += bond_bit_repr[j]; std::cout<<"lbp = "<<(lbp_min-bond_sum)<<std::endl; for (int j = 0; j < lbp_min; j++) { bond_map_status[{percolating_bonds[j].first, percolating_bonds[j].second}] = 1; bond_map_status[{percolating_bonds[j].second, percolating_bonds[j].first}] = 1; } for (int j = 0; j < percolating_bonds.size(); j++) std::cout<<"p = "<<percolating_bonds[j].first<<"\t"<<percolating_bonds[j].second<<std::endl; break; } for (int j = 0; j < lbp_min; j++) { bond_map_status[{percolating_bonds[j].first, percolating_bonds[j].second}] = 1; bond_map_status[{percolating_bonds[j].second, percolating_bonds[j].first}] = 1; } /*std::cout<<"i = "<<i<<"\t"; for (int j = 0; j < lbp_min; j++) std::cout<<bond_bit_repr[j]; std::cout<<"\t axis = "<<axis<<"\t lbp = "<<temp_lbp_[axis]<<std::endl; } } } } void postprocessing::percolation_detection() { int lbp_min = 0; int i_min; int bond_sum; int lbp_min_axis; percolating_bonds.clear(); for (int axis = 0; axis < dim(); axis++){ lbp_min = load_bearing_paths(0,axis); i_min=0; for (int i = 0; i < numParticles(); i++){ if (load_bearing_paths(i,axis) < lbp_min){ lbp_min = load_bearing_paths(i,axis); i_min = i; } } for (int j = 0; j < numParticles(); j++){ is_placed(j) = false; unfoldedAttachments(j) = 0; for (int axis_2 = 0; axis_2 < dim(); axis_2++) unfolded_coords(j,axis_2) = 0.; } for (int axis_2 = 0; axis_2 < dim(); axis_2++) temp_lbp_[axis_2] = 0; unfold_for_lbp(i_min,i_min, true, axis); } lbp_min = percolating_bonds.size(); //std::cout<<"lbp_min="<<lbp_min<<std::endl; if (lbp_min > 0) { divisors = (int*)malloc(sizeof(int) * lbp_min); bond_bit_repr = (int*)malloc(sizeof(int) * lbp_min); for (int i = 0; i < lbp_min; i++) divisors[i] = std::pow(2, (lbp_min-1-i)); //while (temp_lbp_[axis] != 0){ for (int i = (std::pow(2,lbp_min)-1); i >= 0; i--) { for (int j = 0; j < lbp_min; j++) bond_bit_repr[j] = (i/divisors[j])%2; /*std::cout<<"i = "<<i<<"\t"; for (int j = 0; j < lbp_min; j++) std::cout<<bond_bit_repr[j]; std::cout<<"\n"; for (int j = 0; j < lbp_min; j++) { bond_map_status[{percolating_bonds[j].first, percolating_bonds[j].second}] = bond_bit_repr[j]; bond_map_status[{percolating_bonds[j].second, percolating_bonds[j].first}] = bond_bit_repr[j]; } for (int j = 0; j < numParticles(); j++){ is_placed(j) = false; unfoldedAttachments(j) = 0; for (int axis_2 = 0; axis_2 < dim(); axis_2++) unfolded_coords(j,axis_2) = 0.; } for (int axis_2 = 0; axis_2 < dim(); axis_2++) temp_lbp_[axis_2] = 0; unfold_for_lbp(i_min, i_min, false, 0); for (int j = 0; j < numParticles(); j++){ if (is_placed(j) == false) std::cout<<"problem here"<<std::endl; } lbp_min_axis = 0; for (int axis = 0; axis < dim(); axis++) lbp_min_axis += temp_lbp_[axis]; if (lbp_min_axis == 0){ bond_sum = 0; for (int j = 0; j < lbp_min; j++) bond_sum += bond_bit_repr[j]; std::cout<<"lbp = "<<(lbp_min-bond_sum)<<std::endl; for (int j = 0; j < lbp_min; j++) { bond_map_status[{percolating_bonds[j].first, percolating_bonds[j].second}] = 1; bond_map_status[{percolating_bonds[j].second, percolating_bonds[j].first}] = 1; } break; } } } }*/ -} \ No newline at end of file diff --git a/postprocessing/target/lbp_brute_force.cpp b/postprocessing/target/lbp_brute_force.cpp new file mode 100644 index 0000000..fb0fe36 --- /dev/null +++ b/postprocessing/target/lbp_brute_force.cpp @@ -0,0 +1,12 @@ +#include <post.h> + +int main(int argc, char *argv[]) +{ + //post_p::postprocessing test(argv[1]); + + post_p::postprocessing *test = new post_p::postprocessing(argv[1]); + + test->lbp_brute_force(); + + return 0; +} \ No newline at end of file