-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCLI.cpp
More file actions
131 lines (104 loc) · 2.85 KB
/
CLI.cpp
File metadata and controls
131 lines (104 loc) · 2.85 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* Author : Jaeuk Kim
* Email : phy000.kim@gmail.com
* Date : April. 2022 */
/** \file GenerateConfigs.cpp
* \brief Implementations of functions declared in GenerateConfigs and derived classes. */
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <string>
#include <vector>
#include <fstream>
#include <GeometryVector.h>
#include <PeriodicCellList.h>
#include <etc.h>
#include "GenerateConfigs.h"
//#ifdef RSA_gen
#include "RSA/RSA_Gen.h"
//#endif
#include "HSF/HSF_Gen.h"
size_t Verbosity = 2;
int main(int argc, char ** argv){
/* An extern variable defined in ${core}/etc.h */
std::vector<std::string> models {"Poisson"};
models.push_back("RSA");
models.push_back("HSF");
char tempstring[1000];
std::istream & ifile=std::cin;
std::ostream & ofile=std::cout;
ConfigGen * model;
if (argc > 1){
if (strcmp(argv[1], "-h")==0){
/* output available models */
ofile << "Available models\n";
for(auto iter = models.begin(); iter != models.end(); ++iter){
ofile << *iter << "\t";
}
ofile << "\n";
return 0;
}
else if(strcmp(argv[1], "models")==0){
ofile << "Model name = ";
ifile >> tempstring;
if (std::find(models.begin(), models.end(), std::string(tempstring)) != models.end() ){
/* Input */
if (strcmp(tempstring, "RSA") == 0){
model = new RSA_gen(ifile, ofile);
}
else if (strcmp(tempstring, "HSF") == 0){
model = new HSF_Gen(ifile, ofile);
}
}
else{
ofile << tempstring << " is not in the available model list.\n";
}
/* Output ... */
size_t Nc;
std::string output_name, output_type;
ofile << "Number of configurations = ";
Echo(ifile, ofile, Nc);
ofile << "output prefix = ";
Echo(ifile, ofile, output_name);
ofile << "output type (ConfigPack/SpherePacking[.txt]) = ";
Echo(ifile, ofile, output_type);
if (strcmp(output_type.c_str(), "ConfigPack") == 0){
ConfigurationPack save(output_name);
{
/* check the particle radius */
SpherePacking c;
model->GenerateP(c);
ofile << "Particle radius = " << c.GetMaxRadius() <<"\n";
save.AddConfig(Configuration(c, "a"));
}
ofile << "output file = "<< output_name << ".ConfigPakc\n";
ofile << "Generating Configurations ... \n";
progress_display pd(Nc);
pd ++ ;
for(int i = 1; i < Nc; i++){
Configuration c;
model->GenerateC(c);
save.AddConfig(c);
pd++;
}
}
else if (strcmp(output_type.c_str(), "SpherePacking") == 0){
output_name += std::string("__%05d");
ofile << "output file = "<< output_name <<"\n";
progress_display pd(Nc);
for(int i = 0; i < Nc; i++){
sprintf(tempstring, output_name.c_str(), i);
SpherePacking c;
model->GenerateP(c);
WriteConfiguration(c, tempstring);
pd++;
}
}
ofile << "\n Done!\n";
return 0;
}
else{
}
}
}