1010ProcessedComplex PCC_StructureCharacterisation (CellsDesign &new_cells_design) {
1111 ProcessedComplex PCC_characteristics; // module output
1212// / Read simulation configuration from file :: the number of special face types and calculating parameters. Then Output of the current configuration to the screen
13- std::vector<int > charlabs_polyhedrons, charlabs_faces, charlabs_edges, charlabs_nodes;
14- std::vector<double > ConfigVector = config_reader_characterisation (source_path, charlabs_polyhedrons, charlabs_faces, charlabs_edges, charlabs_nodes, Out_logfile_stream); // vector<double> (!) from ini_readers.h library
13+ std::vector<int > charlabs_polyhedrons, charlabs_faces, charlabs_edges, charlabs_nodes, charlabs_laplacians ;
14+ std::vector<double > ConfigVector = config_reader_characterisation (source_path, charlabs_polyhedrons, charlabs_faces, charlabs_edges, charlabs_nodes, charlabs_laplacians, Out_logfile_stream); // vector<double> (!) from ini_readers.h library
1515
1616// / # 1 # Creation of the State Vectors
1717// Faces
@@ -26,49 +26,119 @@ ProcessedComplex PCC_StructureCharacterisation(CellsDesign &new_cells_design) {
2626
2727 } // end for(auto fseq...)
2828
29- for (int i = 0 ; i < 4 ; ++i) { // for all types of cells
29+ for (int i = 0 ; i < 4 ; ++i) { // / for all types of cells
30+
31+ // / # 2 # Measures: fractions and entropies
32+ if (i == 1 && charlabs_edges.size () > 0 ) { // Edges lab
33+ if (charlabs_edges.at (0 ) == 1 ) {
34+ vector<int > EdgeTypes_char (CellNumbs.at (1 + (dim - 3 )),
35+ 0 ); // vector<int> in the form [ 0 2 3 3 2 1 ...] with the TJs type ID as its values
36+ std::vector<double > j_edge_fractions (dim + 1 , 0 ), d_edge_fractions (dim,
37+ 0 ); // fractions of (1) edges of different types and (2) edges of different degrees
38+
39+ // / for each state:
40+ tuple<double , double > conf_entropy_t ;
41+ for (auto current_seq: PCC_characteristics.face_process_seq ) {
42+ EdgeTypes_char.clear ();
43+ std::fill (j_edge_fractions.begin (), j_edge_fractions.end (), 0 );
44+ std::fill (d_edge_fractions.begin (), d_edge_fractions.end (), 0 );
45+
46+ EdgeTypes_char = Edge_types_byFaces (CellNumbs, current_seq, j_edge_fractions, d_edge_fractions);
47+
48+ conf_entropy_t = Configuration_Entropy_tuple (j_edge_fractions); // conf entropy
49+
50+ PCC_characteristics.e_entropy_mean_vector .push_back (std::get<0 >(
51+ conf_entropy_t )); // std::tuple<double, double> Configuration_Entropy_tuple(std::vector<double> const &j_fractions) based on Edges fraction vector
52+ PCC_characteristics.e_entropy_skrew_vector .push_back (std::get<1 >(conf_entropy_t )); // tuple
53+ // // MUST BE IMPROVED (!) :
54+ PCC_characteristics.e_entropy_full_vector .push_back (
55+ std::get<0 >(conf_entropy_t ) + std::get<1 >(conf_entropy_t ));
56+
57+ PCC_characteristics.je_fractions_vector .push_back (j_edge_fractions);
58+ PCC_characteristics.de_fractions_vector .push_back (d_edge_fractions);
59+ } // for (auto current_seq : PCC_characteristics.face_process_seq)
60+
61+ if (charlabs_edges.at (4 ) == 1 ) { // analytical
62+ // / Measures: Analytical solutions for edge fractions and configuration entropies
63+ std::vector<tuple<double , double >> AnalyticalRandEntropies, AnalyticalCrystEntropies;
64+ PCC_characteristics.j_analytical_rand_vector = TJsAnalytics_random (CellNumbs.at (2 + (dim - 3 )),
65+ AnalyticalRandEntropies);
66+ PCC_characteristics.AnRandEntropies_vector = AnalyticalRandEntropies;
67+
68+ PCC_characteristics.j_analytical_cryst_vector = TJsAnalytics_crystallography (
69+ CellNumbs.at (2 + (dim - 3 )), AnalyticalCrystEntropies);
70+ PCC_characteristics.AnCrystEntropies_vector = AnalyticalCrystEntropies;
71+
72+ // analytical edge degree fractions
73+ PCC_characteristics.d_analytical_rand_vector = TJDsAnalytics_random (CellNumbs.at (2 + (dim - 3 )));
74+ PCC_characteristics.d_analytical_cryst_vector = TJDsAnalytics_crystallography (
75+ CellNumbs.at (2 + (dim - 3 )));
76+ } // enf if(charlabs_edges.at(4) == 1)
77+
78+ } // end of if(charlabs_edges.at(0) == 1)
79+ } // end of if(i == 1 && charlabs_edges.at(0) == 1) { // Edges lab
3080
31- // / # 2 # Measures: fractions and entropies
32- if (i == 1 && charlabs_edges.at (0 ) == 1 ) { // Edges lab
33- vector<int > EdgeTypes_char (CellNumbs.at (1 + (dim - 3 )), 0 ); // vector<int> in the form [ 0 2 3 3 2 1 ...] with the TJs type ID as its values
34- std::vector<double > j_edge_fractions (dim+1 ,0 ), d_edge_fractions (dim,0 ); // fractions of (1) edges of different types and (2) edges of different degrees
35-
36- // / for each state:
37- tuple<double ,double > conf_entropy_t ;
38- for (auto current_seq : PCC_characteristics.face_process_seq ) {
39- EdgeTypes_char.clear ();
40- std::fill (j_edge_fractions.begin (), j_edge_fractions.end (),0 );
41- std::fill (d_edge_fractions.begin (), d_edge_fractions.end (),0 );
42-
43- EdgeTypes_char = Edge_types_byFaces (CellNumbs, current_seq, j_edge_fractions, d_edge_fractions);
44-
45- conf_entropy_t = Configuration_Entropy_tuple (j_edge_fractions); // conf entropy
46-
47- PCC_characteristics.e_entropy_mean_vector .push_back (std::get<0 >(conf_entropy_t )); // std::tuple<double, double> Configuration_Entropy_tuple(std::vector<double> const &j_fractions) based on Edges fraction vector
48- PCC_characteristics.e_entropy_skrew_vector .push_back (std::get<1 >(conf_entropy_t )); // tuple
49- // // MUST BE IMPROVED (!) :
50- PCC_characteristics.e_entropy_full_vector .push_back ( std::get<0 >(conf_entropy_t ) + std::get<1 >(conf_entropy_t ));
51-
52- PCC_characteristics.je_fractions_vector .push_back (j_edge_fractions);
53- PCC_characteristics.de_fractions_vector .push_back (d_edge_fractions);
54- }
55-
56- if (charlabs_edges.at (4 ) == 1 ) { // analytical
57- // / Measures: Analytical solutions for edge fractions and configuration entropies
58- std::vector<tuple<double , double >> AnalyticalRandEntropies, AnalyticalCrystEntropies;
59- PCC_characteristics.j_analytical_rand_vector = TJsAnalytics_random (CellNumbs.at (2 + (dim - 3 )), AnalyticalRandEntropies);
60- PCC_characteristics.AnRandEntropies_vector = AnalyticalRandEntropies;
61-
62- PCC_characteristics.j_analytical_cryst_vector = TJsAnalytics_crystallography (CellNumbs.at (2 + (dim - 3 )), AnalyticalCrystEntropies);
63- PCC_characteristics.AnCrystEntropies_vector = AnalyticalCrystEntropies;
64-
65- // analytical edge degree fractions
66- PCC_characteristics.d_analytical_rand_vector = TJDsAnalytics_random (CellNumbs.at (2 + (dim - 3 )));
67- PCC_characteristics.d_analytical_cryst_vector = TJDsAnalytics_crystallography (CellNumbs.at (2 + (dim - 3 )));
68- } // enf if(charlabs_edges.at(4) == 1)
69-
70- } // if(i == 1 && charlabs_edges.at(0) == 1) { // Edges lab
7181 } // end for (int i = 0; i < 4; ++i)
7282
83+ // / # 3 # Laplacians of specail cells
84+ if (charlabs_laplacians.at (1 ) == 1 ) {
85+ // AN - Nodes (Vertices or 0-Cells) sparse adjacency matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
86+ // AE - Edges (Triple Junctions or 1-Cells) sparse adjacency matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
87+ // AF - Faces (Grain Boundaries or 2-Cells) sparse adjacency matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
88+ // AG - Grains (Volumes or 3-Cells) sparse adjacency matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
89+ // MEN - Edges - Nodes (1-Cells to 0-Cells) sparse incidence matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
90+ // MFE - Faces - Edges (2-Cells to 1-Cells) sparse incidence matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values
91+ // MGF - Grains - Faces (3-Cells to 2-Cells) sparse incidence matrix in the form of three column {i, j, value}, where i and j are the indices of elements with non-zero values // odir - source path
92+
93+ // / Adjacency sparse matrix for nodes /// Adjacency sparse matrix for edges /// Adjacency sparse matrix for faces /// Adjacency sparse matrix for grains
94+ // SpMat ANS(CellNumbs.at(0), CellNumbs.at(0)), AES(CellNumbs.at(1 + (dim - 3)), CellNumbs.at(1 + (dim - 3))), AFS(CellNumbs.at(2 + (dim - 3)), CellNumbs.at(2 + (dim - 3))), AGS(CellNumbs.at(3 + (dim - 3)), CellNumbs.at(3 + (dim - 3)));
95+ // ANS = SMatrixReader(paths.at(0), (CellNumbs.at(0)), (CellNumbs.at(0))); //all Nodes
96+ // ANS = 0.5 * (ANS + SparseMatrix<double>(ANS.transpose())); // Full matrix instead of triagonal
97+ // AES = SMatrixReader(paths.at(1 + (dim - 3)), (CellNumbs.at(1 + (dim - 3))), (CellNumbs.at(1 + (dim - 3)))); //all Edges
98+ // AES = 0.5 * (AES + SparseMatrix<double>(AES.transpose())); // Full matrix instead of triagonal
99+ // AFS = SMatrixReader(paths.at(2 + (dim - 3)), (CellNumbs.at(2 + (dim - 3))), (CellNumbs.at(2 + (dim - 3)))); //all Faces
100+ // AFS = 0.5 * (AFS + SparseMatrix<double>(AFS.transpose())); // Full matrix instead of triagonal
101+ // AGS = SMatrixReader(paths.at(3 + (dim - 3)), (CellNumbs.at(3 + (dim - 3))), (CellNumbs.at(3 + (dim - 3)))); //all Volumes
102+ // AGS = 0.5 * (AGS + SparseMatrix<double>(AGS.transpose())); // Full matrix instead of triagonal
103+
104+ // / Incidence sparse matrix for Edges and Nodes /// Incidence sparse matrix for Faces and Edges /// Incidence sparse matrix for Grains and Faces
105+ SpMat ENS (CellNumbs.at (0 ), CellNumbs.at (1 )), FES (CellNumbs.at (1 + (dim - 3 )), CellNumbs.at (2 + (dim - 3 ))), GFS (
106+ CellNumbs.at (2 + (dim - 3 )), CellNumbs.at (3 + (dim - 3 )));
107+
108+ ENS = SMatrixReader (paths.at (4 + (dim - 3 )), (CellNumbs.at (0 )), (CellNumbs.at (1 ))); // all Nodes-Edges
109+ FES = SMatrixReader (paths.at (5 + (dim - 3 )), (CellNumbs.at (1 + (dim - 3 ))),
110+ (CellNumbs.at (2 + (dim - 3 )))); // all Edges-Faces
111+ GFS = SMatrixReader (paths.at (6 + (dim - 3 )), (CellNumbs.at (2 + (dim - 3 ))),
112+ (CellNumbs.at (3 + (dim - 3 )))); // all Faces-Grains
113+
114+ double number_of_steps = (double ) charlabs_laplacians.at (0 ); // reading from Characterisation.ini file (!)
115+ unsigned int d_seq = std::floor ((double ) PCC_characteristics.face_process_seq .size () / number_of_steps);
116+ std::vector<unsigned int > new_current_seq;
117+ std::vector<double > new_Betti_numbers;
118+
119+ std::vector<unsigned int > Betti_calc_time;
120+
121+ #pragma omp parallel for // parallel execution by OpenMP
122+ for (unsigned int i = 0 ; i <= number_of_steps; ++i) {
123+ new_current_seq = PCC_characteristics.face_process_seq .at (i*d_seq);
124+ cout << " ---------------------------------------------------------------------------" << endl;
125+ cout << " [CHAR] Current special faces fraction: " << new_current_seq.size ()/ (double ) CellNumbs.at (2 + (dim - 3 )) << endl;
126+ Out_logfile_stream << " ---------------------------------------------------------------------------" << endl;
127+ Out_logfile_stream << " [CHAR] Current special faces fraction: " << new_current_seq.size ()/ (double ) CellNumbs.at (2 + (dim - 3 )) << endl;
128+ // Elapsing time for 3 Betti numbers
129+ clock_t t;
130+ Betti_calc_time.push_back (clock ());
131+
132+ new_Betti_numbers = OperatorsBetti (new_current_seq, ENS , FES , GFS );
133+ cout << " [CHAR] p & Betti numbers: " << new_current_seq.size ()/ (double ) CellNumbs.at (2 ) << " " << new_Betti_numbers.at (0 ) << " " << new_Betti_numbers.at (1 ) << " " << new_Betti_numbers.at (2 ) << endl;
134+ Out_logfile_stream << " [CHAR] p & Betti numbers: " << new_current_seq.size ()/ (double ) CellNumbs.at (2 ) << " " << new_Betti_numbers.at (0 ) << " " << new_Betti_numbers.at (1 ) << " " << new_Betti_numbers.at (2 ) << endl;
135+ //
136+ Betti_calc_time.back () = clock () - Betti_calc_time.back ();
137+ cout << " [CHAR] Calculation time [s] of the Betti numbers is equal to " << Betti_calc_time.back ()/ pow (10.0 ,6.0 )<< endl;
138+ Out_logfile_stream << " [CHAR] Calculation time [s] of the Betti numbers is equal to " << Betti_calc_time.back ()/ pow (10.0 ,6.0 )<< endl;
139+
140+ PCC_characteristics.Betti_vector .push_back ({new_current_seq.size ()/(double ) CellNumbs.at (2 ), new_Betti_numbers.at (0 ), new_Betti_numbers.at (1 ), new_Betti_numbers.at (2 )});
141+ }
142+ } // end of for (int i = 0; i < number_of_steps, ++i)
73143 return PCC_characteristics;
74144}
0 commit comments