-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cc
96 lines (81 loc) · 2.68 KB
/
main.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "master.h"
#include <chrono>
#include <fstream>
using namespace chrono;
int main(int argc, const char *argv[])
{
typedef high_resolution_clock myclock;
Params *simparams = new Params(argv[argc-1]);
// Create fresh file for output
ofstream fout;
fout.open(argv[1], ios::out | ios::trunc | ios::binary);
if (!fout.is_open()) {
cout << "Could not open file for writing!" << endl;
}
simparams->printParams();
if (simparams->cellWidth < simparams->length) {
cout << "Error. Cell width is smaller than obj length" << endl;
return 1;
}
// Write params to file
simparams->writeParams(argv[1]);
myclock::time_point start_uncross = myclock::now();
Master<Rod> master(simparams);
master.InitializeSim();
master.WriteSweep(argv[1]); // Write init map
// Uncrossing phase
int presweep = 1;
while (!master.noOverlap) {
master.MCSweep(presweep);
presweep++;
}
// Write uncrossed img if desired
if (simparams->printUncross) {
master.WriteSweep(argv[1]);
}
// Equil and processing phase
myclock::time_point start_proc = myclock::now();
auto uncross_dur = duration_cast<seconds>(start_proc - start_uncross).count();
cout << "Finished uncrossing phase (" << uncross_dur << " seconds)" << endl;
cout << "Beginning equilibrium phase (" << simparams->nEquil << " sweeps)..." << endl;
for (int i=1; i<simparams->nEquil; i++) {
master.Sweep();
}
cout << "Done." << endl << "Beginning processing phase (" << simparams->nProc
<< " sweeps)..." << endl
<< "Writing to " << argv[1] << endl;
for (int i=1; i<=simparams->nProc; i++) {
master.MCSweep(i);
if (i%simparams->sweepEval==0) {
master.WriteSweep(argv[1]);
/////////////////////
int resweep = 1;
cout << "Resetting map.." << endl;
master.ReInitializeSim();
while (!master.noOverlap) {
master.MCSweep(resweep);
resweep++;
}
cout << "Equilibriating ("<< simparams->nEquil<< " sweeps)" << endl;
for (int ii=0; ii <simparams->nEquil; ii++) master.Sweep();
/////////////////////
/*
if (!simparams->shape.compare("T") || !simparams->shape.compare("X")) {
double l = master.EvalOrder();
cout << "Lambda " << l << endl;
if (l>0.50) {
cout << "Lambda exceeded 0.4, resetting map" << endl;
master.ReInitializeSim();
while (!master.noOverlap) master.Sweep();
for (int ii=0; ii<simparams->nEquil; ii++) master.Sweep();
}
}
*/
}
}
auto proc_dur = duration_cast<seconds>(myclock::now() - start_proc).count();
auto total_dur = duration_cast<seconds>(myclock::now() - start_uncross).count();
cout << endl << "Processing time: " << proc_dur << " seconds" << endl;
cout << endl << "Total time: " << total_dur << " seconds" << endl;
return 0;
}