tychoGUI  1.0
 All Data Structures Namespaces Files Functions Variables
load_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 
16 {
17  QString txtfile = QFileDialog::getOpenFileName(this, tr("Open TYCHO Parameterfile"), QString::null);
18 
19  ui->filename->setText(txtfile);
20 
21  QList<QString> data;
22  QString tmp_data;
23 
24  QFile file(txtfile);
25  if (file.open(QIODevice::ReadOnly | QIODevice::Text)){
26 
27  QTextStream in(&file);
28  while (!in.atEnd()) {
29  tmp_data = in.readLine(0);
30 
31  if ((tmp_data.contains("#"))||(tmp_data.mid(0,1) == "")) {
32  tmp_data.clear();
33  }
34  else {
35  data.append(tmp_data);
36  tmp_data.clear();
37  }
38  }
39  }
40 
41  //to debug
42  //std::cout << "LĂ„NGE" << data.size() << "\n";
43 
44  if (data.size() > 0 ) set_parameters(data);
45 
46  data.clear();
47 
48  file.close();
49 }
50 
51 
55 void MainWindow::set_parameters(QList<QString> data)
56 {
57  //to debug
58 
59  /*
60  QString tmp;
61 
62  for (int i=0; i<data.size(); ++i){
63  tmp = data[i];
64  std::cout << tmp.toUtf8().constData() << " index:" << i << "\n";
65  tmp.clear();
66  }
67  */
68 
69 
70  //set fileformat
71  ui->filetype->setCurrentIndex(data[0].toInt());
72  //set IC generator
73  ui->initial_conditions->setCurrentIndex(data[1].toInt());
74  //set IC files
75  ic_density_file = data[2];
76  //if file given, make the loading buttons active
77  if (data[2]!="dummy") ui->ic_density->setEnabled(true);
78  ic_temperature_file = data[3];
79  //if file given, make the loading buttons active
80  if (data[3]!="dummy") ui->ic_temperatur->setEnabled(true);
81  ic_velocity_file = data[4];
82  //if file given, make the loading buttons active
83  if (data[4]!="dummy") ui->ic_velocity->setEnabled(true);
84  ic_windemitter_file = data[5];
85  //if file given, make the loading buttons active
86  if (data[5]!="dummy") ui->ic_wind->setEnabled(true);
87  ic_obstacle_file = data[6];
88  //if file given, make the loading buttons active
89  if (data[6]!="dummy") ui->ic_obstacle->setEnabled(true);
90  ic_soundemitter_file = data[7];
91  //if file given, make the loading buttons active
92  if (data[7]!="dummy") ui->ic_soundemitter->setEnabled(true);
93  ic_marker_file = data[8];
94  //if file given, make the loading buttons active
95  if (data[8]!="dummy") ui->ic_marker->setEnabled(true);
96  //set initial velocities
97  ui->initial_velocities->setCurrentIndex(data[9].toInt());
98  //output_directory
99  output_directory = data[10];
101  //stratified atmosphere
102  if (data[11]=="1"){
103  ui->startified_atmos_on->setChecked(true);
104  ui->startified_atmos_off->setChecked(false);
105  }
106  if (data[11]=="0"){
107  ui->startified_atmos_on->setChecked(false);
108  ui->startified_atmos_off->setChecked(true);
109  }
110  //set Resolution
111  ui->res_x->setValue(data[12].toInt());
112  ui->res_y->setValue(data[13].toInt());
113  ui->res_z->setValue(data[14].toInt());
114  //set Dimension
115  ui->dimension->setCurrentIndex(data[15].toInt()-1);
116  //set physical extend
117  ui->extend_x->setText(data[16]);
118  ui->extend_y->setText(data[17]);
119  ui->extend_z->setText(data[18]);
120  //set boundary conditions
121  ui->bound_down->setCurrentIndex(data[19].toInt());
122  ui->bound_up->setCurrentIndex(data[20].toInt());
123  ui->bound_left->setCurrentIndex(data[21].toInt());
124  ui->bound_right->setCurrentIndex(data[22].toInt());
125  ui->bound_front->setCurrentIndex(data[23].toInt());
126  ui->bound_back->setCurrentIndex(data[24].toInt());
127  //set inflow conditions
128  ui->inflow_velocity->setText(data[25]);
129  ui->inflow_density->setText(data[27]);
130  ui->inflow_temperature->setText(data[28]);
131  if (data[28]=="1"){
132  ui->wind_boundary_1 ->setChecked(true);
133  ui->wind_boundary_0 ->setChecked(false);
134  }
135  if (data[28]=="2"){
136  ui->wind_boundary_1->setChecked(false);
137  ui->wind_boundary_0->setChecked(true);
138  }
139  //Timing
140  ui->end_time->setText(data[29]);
141  ui->output_frequency->setText(data[30]);
142  ui->restart_frequency->setText(data[31]);
143  //CFL
144  ui->cfl->setText(data[32]);
145  //Gravity
146  if (data[33]=="1"){
147  ui->gravity_on->setChecked(true);
148  ui->gravity_off->setChecked(false);
149  }
150  if (data[33]=="0"){
151  ui->gravity_off->setChecked(true);
152  ui->gravity_on->setChecked(false);
153  }
154  //Gasconstant
155  ui->gasconstant->setText(data[34]);
156  //Gammafactor
157  ui->gamma->setText(data[35]);
158  //Windemitters
159  if (data[36]=="1"){
160  ui->wind_emitter_on->setChecked(true);
161  ui->wind_emitter_off->setChecked(false);
162  ui->wind_speed->setEnabled(true);
163  }
164  if (data[36]=="0"){
165  ui->wind_emitter_on->setChecked(false);
166  ui->wind_emitter_off->setChecked(true);
167  }
168  //wind-speed
169  ui->wind_speed->setText(data[37]);
170  //OpenMP Threads
171  ui->openmp->setText(data[38]);
172  //obstacles
173  if (data[39]=="1"){
174  ui->obstacle_on->setChecked(true);
175  ui->obstacle_off->setChecked(false);
176  }
177  if (data[39]=="0"){
178  ui->obstacle_on->setChecked(false);
179  ui->obstacle_off->setChecked(true);
180  }
181  //obstacle dens
182  ui->obstacle_density->setText(data[40]);
183  //obstacle temperature
184  ui->obstacle_temp->setText(data[41]);
185  //obstacle diffusion
186  ui->obstacle_diff->setText(data[42]);
187  //specific heat capacity gas
188  ui->specific_heat_capacity_gas->setText(data[43]);
189  //specific_heat capacity obstacle
190  ui->specific_heat_capacity_obstacle->setText(data[44]);
191  //Markerfield
192  if (data[45]=="1"){
193  ui->marker_field_on->setChecked(true);
194  ui->marker_field_off->setChecked(false);
195  }
196  if (data[45]=="0"){
197  ui->marker_field_on->setChecked(false);
198  ui->marker_field_off->setChecked(true);
199  }
200  //markerfield density
201  ui->marker_density->setText(data[45]);
202  //gas viscosity
203  if (data[47]=="1"){
204  ui->viscosity_on->setChecked(true);
205  ui->viscosity_off->setChecked(false);
206  }
207  if (data[47]=="0"){
208  ui->viscosity_on->setChecked(false);
209  ui->viscosity_off->setChecked(true);
210  }
211  //sound emitter
212  if (data[48]=="1"){
213  ui->Soundemitter_on->setChecked(true);
214  ui->Soundemitter_off->setChecked(false);
215  }
216  if (data[48]=="0"){
217  ui->Soundemitter_on->setChecked(false);
218  ui->Soundemitter_off->setChecked(true);
219  }
220 
221  //soundPressureLevel
222  ui->soundPressureLevel->setText(data[49]);
223 
224  //sound emitter
225  if (data[50]=="1"){
226  ui->one_pulse_on->setChecked(true);
227  ui->one_pulse_off->setChecked(false);
228  }
229  if (data[50]=="0"){
230  ui->one_pulse_on->setChecked(false);
231  ui->one_pulse_off->setChecked(true);
232  }
233 
234  ui->soundEmitterFrequency->setText(data[51]);
235 
236  ui->soundReflexionCoefficient->setText(data[52]);
237 
238  ui->obstacleSoundAbsoption->setText(data[53]);
239 
242 
243 }
244