tychoGUI  1.0
 All Data Structures Namespaces Files Functions Variables
save_parameterfile.cpp
Go to the documentation of this file.
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 #include <QFileDialog>
4 #include <QFile>
5 #include <QTextStream>
6 #include <QString>
7 #include <iostream>
8 #include <QDebug>
9 
10 
15 {
16  QString txtfile = QFileDialog::getSaveFileName(this, tr("Save TYCHO Parameterfile"), ":", tr("Parameterfile (*.txt)"));
17 
18  ui->filename->setText(txtfile);
19 
20  QList<QString> data;
21 
22  QFile file(txtfile);
23  if (file.open(QFile::WriteOnly | QFile::Truncate)) {
24  QTextStream out(&file);
25 
26  out << "#-------WELCOME TO TYCHOS PARAMETER FILE--------------" << "\n";
27  out << "#COMMENTS HAVE TO START WITH #" << "\n";
28  out << "#THE ORDER OF PARAMETERS HERE IS MANDATORY" << "\n";
29  out << "#IF YOU WISH TO INCLUDE MORE PARAMETERS HERE" << "\n";
30  out << "#MAKE SURE TO EDIT START_FILE_READER.C" << "\n";
31  out << "#HAVE FUN" << "\n";
32  out << "#-----------------------------------------------------" << "\n";
33 
34  data.clear();
35 
36  out << "\n#TYCHO Files[0], VTK RECTILINEAR_GRID BINARY Files [1], AMIRA MESH [2]";
37  out << "\n#or IFRIT uniform scalar data files [3]\n";
38  data.append(ui->filetype->currentText());
39  out << filetype_selector(data[0]) << "\n";
40 
41  out<< "\n#Make ICs by editing the source file make_ic.c yes [0]";
42  out << "\n#Read in initial conditions [1]";
43  out << "\n#Only the obstacle distribution is read in [2]";
44  out << "\n#A Sod Shock Tube is generated with [3]";
45  out << "\n#Kelvin Helmholtz instabilities in 2D [4]";
46  out << "\n#Your initial conditions have to be in TYCHO file format!\n";
47  data.append(ui->initial_conditions->currentText());
48  //std::cout << data[1].toUtf8().constData() << "\n";
49  //std::cout << ic_selector(data[1]).toUtf8().constData() << "\n";
50  out << ic_selector(data[1]) << "\n";
51 
52  out << "\n#Initial Conditions in TYCHO file format";
53  out << "\n#Initial density\n";
54  data.append(ic_density_file);
55  out << data[2] << "\n";
56  out << "#Initial temperature\n";
57  data.append(ic_temperature_file);
58  out << data[3] << "\n";
59  out << "#Initial velocity\n";
60  data.append(ic_velocity_file);
61  out << data[4] << "\n";
62  out << "#Initial wind\n";
63  data.append(ic_windemitter_file);
64  out << data[5] << "\n";
65  out << "#Initial obstacle\n";
66  data.append(ic_obstacle_file);
67  out << data[6] << "\n";
68  out << "#Initial soundemitter\n";
69  data.append(ic_soundemitter_file);
70  out << data[7] << "\n";
71  out << "#Initial marker\n";
72  data.append(ic_marker_file);
73  out << data[8] << "\n";
74 
75 
76  out << "\n#Initial velocity field file present [1] or not [0]\n";
77  data.append(ui->initial_velocities->currentText());
78  if (data[9]=="Initial velocity file exists") out << "1\n";
79  if (data[9]=="No initial velocity file") out << "0\n";
80 
81  out << "\n#Output directory\n";
82  data.append(output_directory);
83  out << data[10] << "\n";
84 
85 
86  out << "\n#Stratified Atmosphere [1] or constant Atmosphere [0]\n";
87  if (ui->startified_atmos_on->isChecked()){
88  data.append("1");
89  }
90  if (ui->startified_atmos_off->isChecked()){
91  data.append("0");
92  }
93  out << data[11] <<"\n";
94 
95  out << "\n#Basic properties\n#Resolution\n#x y z\n";
96  data.append(ui->res_x->text());
97  out << data[12] << "\n";
98  data.append(ui->res_y->text());
99  out << data[13] << "\n";
100  data.append(ui->res_z->text());
101  out << data[14] << "\n";
102 
103  out << "\n#Dimension\n" ;
104  data.append(ui->dimension->currentText());
105  out << data[15] << "\n";
106 
107  out << "\n#Length scale\n#meter in x,y,z\n";
108  data.append(ui->extend_x->text());
109  out << data[16] << "\n";
110  data.append(ui->extend_y->text());
111  out << data[17] << "\n";
112  data.append(ui->extend_z->text());
113  out << data[18] << "\n";
114 
115  out << "\n#Boundary conditions";
116  out << "\n#Boundary conditions";
117  out << "\n#0.....zero gradient";
118  out << "\n#1.....reflecting";
119  out << "\n#2.....small padding";
120  out << "\n#3.....outflow boundaries";
121  out << "\n#4.....inflow boundaries";
122  out << "\n#5.....periodic boundaries";
123  out << "\n#Bound.down, bound.up, bound.left, bound.right, bound.front, bound.back";
124  out << "\n#Bound.down is set automatically to reflecting in case gravity is";
125  out << "\n#switched on\n";
126  data.append(ui->bound_down->currentText());
127  out << boundary_selector(data[19]) << "\n";
128  data.append(ui->bound_up->currentText());
129  out << boundary_selector(data[20]) << "\n";
130  data.append(ui->bound_left->currentText());
131  out << boundary_selector(data[21]) << "\n";
132  data.append(ui->bound_right->currentText());
133  out << boundary_selector(data[22]) << "\n";
134  data.append(ui->bound_front->currentText());
135  out << boundary_selector(data[23]) << "\n";
136  data.append(ui->bound_back->currentText());
137  out << boundary_selector(data[24]) << "\n";
138 
139  out << "\n#if inflow boundaries the inflow velocities and density";
140  out << "\n#inflow_velocity [m/s], inflow density [kg/m^3] and inflow temperature [K]";
141  out << "\n#if you want to start with the constant velocity and direction over the whole";
142  out << "\n#computational domain you have to set the last parameter in this section to";
143  out << "\n#[1] for everywhere. If you want only inflow from boundaries from the starting";
144  out << "\n#you have to set this parameter to [2].\n";
145  data.append(ui->inflow_velocity->text());
146  out << data[25] << "\n";
147  data.append(ui->inflow_density->text());
148  out << data[26] << "\n";
149  data.append(ui->inflow_temperature->text());
150  out << data[27] << "\n";
151  if (ui->wind_boundary_0->isChecked()){
152  data.append("2");
153  }
154  if (ui->wind_boundary_1->isChecked()){
155  data.append("1");
156  }
157  out << data[28] << "\n";
158 
159  out << "\n#Simulation end-time in minutes\n";
160  data.append(ui->end_time->text());
161  out << data[29] << "\n";
162  out << "#Output frequency in seconds\n";
163  data.append(ui->output_frequency->text());
164  out << data[30] << "\n";
165  out << "#Restart frequency in seconds\n";
166  data.append(ui->restart_frequency->text());
167  out << data[31] << "\n";
168 
169  out << "\n#CFL Number\n";
170  data.append(ui->cfl->text());
171  out << data[32] << "\n";
172 
173  out << "\n#Gravity [on--1] / [off--0]\n";
174  if (ui->gravity_off->isChecked()){
175  data.append("0");
176  }
177  if (ui->gravity_on->isChecked()){
178  data.append("1");
179  }
180  out << data[33] <<"\n";
181 
182  out << "\n#Gas constant\n";
183  data.append(ui->gasconstant->text());
184  out << data[34] << "\n";
185 
186  out << "\n#Gamma factor\n";
187  data.append(ui->gamma->text());
188  out << data[35] << "\n";
189 
190  out << "\n#Wind-emitters\n";
191  if (ui->wind_emitter_on->isChecked()){
192  data.append("1");
193  }
194  if (ui->wind_emitter_off->isChecked()){
195  data.append("0");
196  }
197  out << data[36] << "\n";
198 
199  out << "\n#Wind speed [m/s]\n";
200  data.append(ui->wind_speed->text());
201  out << data[37] << "\n";
202 
203  out << "\n#Number of Threads for OpenMP]\n";
204  data.append(ui->openmp->text());
205  out << data[38] << "\n";
206 
207  out << "\n#With obstacle [0--off]/[1--on]\n";
208  if (ui->obstacle_off->isChecked()){
209  data.append("0");
210  }
211  if (ui->obstacle_on->isChecked()){
212  data.append("1");
213  }
214  out << data[39] << "\n";
215 
216  out << "\n#Obstacle density [kg/m^3]\n";
217  data.append(ui->obstacle_density->text());
218  out << data[40] << "\n";
219 
220  out << "\n#Obstacle temperature [K]\n";
221  data.append(ui->obstacle_temp->text());
222  out << data[41] << "\n";
223 
224  out << "\n#Obstacle Thermal diffusivity [m^2/s]\n";
225  data.append(ui->obstacle_diff->text());
226  out << data[42] << "\n";
227 
228  out << "\n#Specific heat capacity gas [J/kgK]\n";
229  data.append(ui->specific_heat_capacity_gas->text());
230  out << data[43] << "\n";
231 
232  qDebug() << "hallo";
233 
234  out << "\n#Specific_heat capacity obstacle [J/kgK]\n";
235  data.append(ui->specific_heat_capacity_obstacle->text());
236  out << data[44] << "\n";
237 
238  out << "\n#A Marker Field is advected with the HYDRO Simulation [0--off]/[1--on]\n";
239  if (ui->marker_field_on->isChecked()){
240  data.append("1");
241  }
242  if (ui->marker_field_off->isChecked()){
243  data.append("0");
244  }
245  out << data[45] << "\n";
246 
247  out << "\n#Marker density [kg/m^3]\n";
248  data.append(ui->marker_density->text());
249  out << data[46] << "\n";
250 
251  out << "\n#Viscosity of gas [0--off]/[1--on]\n";
252  if (ui->viscosity_on->isChecked()){
253  data.append("1");
254  }
255  if (ui->viscosity_off->isChecked()){
256  data.append("0");
257  }
258  out << data[47] << "\n";
259 
260  out << "\n#With_sound_emitter [0--off]/[1--on]\n";
261  if (ui->Soundemitter_on->isChecked()){
262  data.append("1");
263  }
264  if (ui->Soundemitter_off->isChecked()){
265  data.append("0");
266  }
267  out << data[48] << "\n";
268 
269  qDebug() << "hall1";
270 
271  out << "\n#Sound Pressure Level dB\n";
272  data.append(ui->soundPressureLevel->text());
273  out << data[49] << "\n";
274 
275  out << "\n#With_one_pulse or periodic[0--off]/[1--on]\n";
276  if (ui->one_pulse_on->isChecked()){
277  data.append("1");
278  }
279  if (ui->one_pulse_off->isChecked()){
280  data.append("0");
281  }
282  out << data[50] << "\n";
283 
284  out << "\n#Sound Frequency Hz\n";
285  data.append(ui->soundEmitterFrequency->text());
286  out << data[51] << "\n";
287 
288  out << "\n#Sound Reflection on Obstacle coefficient\n";
289  data.append(ui->soundReflexionCoefficient->text());
290  out << data[52] << "\n";
291 
292  out << "\n#Obstacle Absorption Coefficient\n";
293  data.append(ui->obstacleSoundAbsoption->text());
294  out << data[53] << "\n";
295 
296  out << "\n";
297 
298 
299 
300  out << "#--------END OF PARAMETERFILE-----------------\n";
301 
302  }
303 
304  file.close();
305 }