-
Notifications
You must be signed in to change notification settings - Fork 9
/
config.h
690 lines (651 loc) · 28.6 KB
/
config.h
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <iostream>
#include <string>
#include <limits>
// Too much similar code.
// Add some macroprogramming or templates.
// Rewrite with inheritance.
class Time_config_part{
public:
double total_time;
double time_step_size;
double time_save_step;
public:
Time_config_part(){};
Time_config_part( boost::property_tree::ptree &ptree ) :
total_time( ptree.get<double>("total_time") ),
time_step_size( ptree.get<double>("time_step_size") ),
time_save_step( ptree.get<double>("time_save_step") )
{} ;
virtual ~Time_config_part() {};
void print() {
std::cout << "Total_time = " << total_time << std::endl;
std::cout << "Time_step_size = " << time_step_size << std::endl;
std::cout << "Time_save_step = " << time_save_step << std::endl;
}
};
class Mesh_config_part{
public:
double grid_x_size;
double grid_x_step;
double grid_y_size;
double grid_y_step;
double grid_z_size;
double grid_z_step;
public:
Mesh_config_part(){};
Mesh_config_part( boost::property_tree::ptree &ptree ) :
grid_x_size( ptree.get<double>("grid_x_size") ),
grid_x_step( ptree.get<double>("grid_x_step") ),
grid_y_size( ptree.get<double>("grid_y_size") ),
grid_y_step( ptree.get<double>("grid_y_step") ),
grid_z_size( ptree.get<double>("grid_z_size") ),
grid_z_step( ptree.get<double>("grid_z_step") )
{};
virtual ~Mesh_config_part() {};
void print() {
std::cout << "grid_x_size = " << grid_x_size << std::endl;
std::cout << "grid_x_step = " << grid_x_step << std::endl;
std::cout << "grid_y_size = " << grid_y_size << std::endl;
std::cout << "grid_y_step = " << grid_y_step << std::endl;
std::cout << "grid_z_size = " << grid_z_size << std::endl;
std::cout << "grid_z_step = " << grid_z_step << std::endl;
}
};
class Particle_source_config_part{
public:
std::string name;
int initial_number_of_particles;
int particles_to_generate_each_step;
double mean_momentum_x;
double mean_momentum_y;
double mean_momentum_z;
double temperature;
double charge;
double mass;
public:
Particle_source_config_part(){};
Particle_source_config_part( std::string name, boost::property_tree::ptree &ptree ) :
name( name ),
initial_number_of_particles( ptree.get<int>("initial_number_of_particles") ),
particles_to_generate_each_step(
ptree.get<int>("particles_to_generate_each_step") ),
mean_momentum_x( ptree.get<double>("mean_momentum_x") ),
mean_momentum_y( ptree.get<double>("mean_momentum_y") ),
mean_momentum_z( ptree.get<double>("mean_momentum_z") ),
temperature( ptree.get<double>("temperature") ),
charge( ptree.get<double>("charge") ),
mass( ptree.get<double>("mass") )
{};
virtual ~Particle_source_config_part() {};
virtual void print() {
std::cout << "Particle_source: name = " << name << std::endl;
std::cout << "initial_number_of_particles = " <<
initial_number_of_particles << std::endl;
std::cout << "particles_to_generate_each_step = " <<
particles_to_generate_each_step << std::endl;
std::cout << "mean_momentum_x = " << mean_momentum_x << std::endl;
std::cout << "mean_momentum_y = " << mean_momentum_y << std::endl;
std::cout << "mean_momentum_z = " << mean_momentum_z << std::endl;
std::cout << "temperature = " << temperature << std::endl;
std::cout << "charge = " << charge << std::endl;
std::cout << "mass = " << mass << std::endl;
}
};
class Particle_source_box_config_part : public Particle_source_config_part {
public:
double box_x_left;
double box_x_right;
double box_y_bottom;
double box_y_top;
double box_z_near;
double box_z_far;
public:
Particle_source_box_config_part(){};
Particle_source_box_config_part( std::string name, boost::property_tree::ptree &ptree ) :
Particle_source_config_part( name, ptree ),
box_x_left( ptree.get<double>("box_x_left") ),
box_x_right( ptree.get<double>("box_x_right") ),
box_y_bottom( ptree.get<double>("box_y_bottom") ),
box_y_top( ptree.get<double>("box_y_top") ),
box_z_near( ptree.get<double>("box_z_near") ),
box_z_far( ptree.get<double>("box_z_far") )
{};
virtual ~Particle_source_box_config_part() {};
virtual void print() {
Particle_source_config_part::print();
std::cout << "box_x_left = " << box_x_left << std::endl;
std::cout << "box_x_right = " << box_x_right << std::endl;
std::cout << "box_y_bottom = " << box_y_bottom << std::endl;
std::cout << "box_y_top = " << box_y_top << std::endl;
std::cout << "box_z_near = " << box_z_near << std::endl;
std::cout << "box_z_far = " << box_z_far << std::endl;
}
};
class Particle_source_cylinder_config_part : public Particle_source_config_part {
public:
double cylinder_axis_start_x;
double cylinder_axis_start_y;
double cylinder_axis_start_z;
double cylinder_axis_end_x;
double cylinder_axis_end_y;
double cylinder_axis_end_z;
double cylinder_radius;
public:
Particle_source_cylinder_config_part(){};
Particle_source_cylinder_config_part( std::string name, boost::property_tree::ptree &ptree ) :
Particle_source_config_part( name, ptree ),
cylinder_axis_start_x( ptree.get<double>("cylinder_axis_start_x") ),
cylinder_axis_start_y( ptree.get<double>("cylinder_axis_start_y") ),
cylinder_axis_start_z( ptree.get<double>("cylinder_axis_start_z") ),
cylinder_axis_end_x( ptree.get<double>("cylinder_axis_end_x") ),
cylinder_axis_end_y( ptree.get<double>("cylinder_axis_end_y") ),
cylinder_axis_end_z( ptree.get<double>("cylinder_axis_end_z") ),
cylinder_radius( ptree.get<double>("cylinder_radius") )
{};
virtual ~Particle_source_cylinder_config_part() {};
virtual void print() {
Particle_source_config_part::print();
std::cout << "cylinder_axis_start_x = " << cylinder_axis_start_x << std::endl;
std::cout << "cylinder_axis_start_y = " << cylinder_axis_start_y << std::endl;
std::cout << "cylinder_axis_start_z = " << cylinder_axis_start_z << std::endl;
std::cout << "cylinder_axis_end_x = " << cylinder_axis_end_x << std::endl;
std::cout << "cylinder_axis_end_y = " << cylinder_axis_end_y << std::endl;
std::cout << "cylinder_axis_end_z = " << cylinder_axis_end_z << std::endl;
std::cout << "cylinder_radius = " << cylinder_radius << std::endl;
}
};
class Particle_source_tube_along_z_config_part : public Particle_source_config_part {
public:
double tube_along_z_axis_x;
double tube_along_z_axis_y;
double tube_along_z_axis_start_z;
double tube_along_z_axis_end_z;
double tube_along_z_inner_radius;
double tube_along_z_outer_radius;
public:
Particle_source_tube_along_z_config_part(){};
Particle_source_tube_along_z_config_part( std::string name,
boost::property_tree::ptree &ptree ) :
Particle_source_config_part( name, ptree ),
tube_along_z_axis_x( ptree.get<double>("tube_along_z_axis_x") ),
tube_along_z_axis_y( ptree.get<double>("tube_along_z_axis_y") ),
tube_along_z_axis_start_z( ptree.get<double>("tube_along_z_axis_start_z") ),
tube_along_z_axis_end_z( ptree.get<double>("tube_along_z_axis_end_z") ),
tube_along_z_inner_radius( ptree.get<double>("tube_along_z_inner_radius") ),
tube_along_z_outer_radius( ptree.get<double>("tube_along_z_outer_radius") )
{};
virtual ~Particle_source_tube_along_z_config_part() {};
virtual void print() {
Particle_source_config_part::print();
std::cout << "tube_along_z_axis_x = "
<< tube_along_z_axis_x << std::endl;
std::cout << "tube_along_z_axis_y = "
<< tube_along_z_axis_y << std::endl;
std::cout << "tube_along_z_axis_start_z = "
<< tube_along_z_axis_start_z << std::endl;
std::cout << "tube_along_z_axis_end_z = "
<< tube_along_z_axis_end_z << std::endl;
std::cout << "tube_along_z_inner_radius = "
<< tube_along_z_inner_radius << std::endl;
std::cout << "tube_along_z_outer_radius = "
<< tube_along_z_outer_radius << std::endl;
}
};
class Inner_region_config_part {
public:
std::string name;
double potential;
public:
Inner_region_config_part(){};
Inner_region_config_part(
std::string name, boost::property_tree::ptree &ptree ):
name( name ),
potential( ptree.get<double>("potential") )
{};
virtual ~Inner_region_config_part() {};
virtual void print() {
std::cout << "Inner region:" << std::endl;
std::cout << "name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
}
};
class Inner_region_box_config_part : public Inner_region_config_part{
public:
double box_x_left;
double box_x_right;
double box_y_bottom;
double box_y_top;
double box_z_near;
double box_z_far;
public:
Inner_region_box_config_part(){};
Inner_region_box_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
box_x_left( ptree.get<double>("box_x_left") ),
box_x_right( ptree.get<double>("box_x_right") ),
box_y_bottom( ptree.get<double>("box_y_bottom") ),
box_y_top( ptree.get<double>("box_y_top") ),
box_z_near( ptree.get<double>("box_z_near") ),
box_z_far( ptree.get<double>("box_z_far") )
{};
virtual ~Inner_region_box_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
std::cout << "box_x_left = " << box_x_left << std::endl;
std::cout << "box_x_right = " << box_x_right << std::endl;
std::cout << "box_y_bottom = " << box_y_bottom << std::endl;
std::cout << "box_y_top = " << box_y_top << std::endl;
std::cout << "box_z_near = " << box_z_near << std::endl;
std::cout << "box_z_far = " << box_z_far << std::endl;
}
};
class Inner_region_sphere_config_part : public Inner_region_config_part{
public:
double sphere_origin_x;
double sphere_origin_y;
double sphere_origin_z;
double sphere_radius;
public:
Inner_region_sphere_config_part(){};
Inner_region_sphere_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
sphere_origin_x( ptree.get<double>("sphere_origin_x") ),
sphere_origin_y( ptree.get<double>("sphere_origin_y") ),
sphere_origin_z( ptree.get<double>("sphere_origin_z") ),
sphere_radius( ptree.get<double>("sphere_radius") )
{};
virtual ~Inner_region_sphere_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
std::cout << "sphere_origin_x = " << sphere_origin_x << std::endl;
std::cout << "sphere_origin_y = " << sphere_origin_y << std::endl;
std::cout << "sphere_origin_z = " << sphere_origin_z << std::endl;
std::cout << "sphere_radius = " << sphere_radius << std::endl;
}
};
class Inner_region_cylinder_config_part : public Inner_region_config_part{
public:
double cylinder_axis_start_x;
double cylinder_axis_start_y;
double cylinder_axis_start_z;
double cylinder_axis_end_x;
double cylinder_axis_end_y;
double cylinder_axis_end_z;
double cylinder_radius;
public:
Inner_region_cylinder_config_part(){};
Inner_region_cylinder_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
cylinder_axis_start_x( ptree.get<double>("cylinder_axis_start_x") ),
cylinder_axis_start_y( ptree.get<double>("cylinder_axis_start_y") ),
cylinder_axis_start_z( ptree.get<double>("cylinder_axis_start_z") ),
cylinder_axis_end_x( ptree.get<double>("cylinder_axis_end_x") ),
cylinder_axis_end_y( ptree.get<double>("cylinder_axis_end_y") ),
cylinder_axis_end_z( ptree.get<double>("cylinder_axis_end_z") ),
cylinder_radius( ptree.get<double>("cylinder_radius") )
{};
virtual ~Inner_region_cylinder_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "inner_region_potential = " << potential << std::endl;
std::cout << "cylinder_axis_start_x = " << cylinder_axis_start_x << std::endl;
std::cout << "cylinder_axis_start_y = " << cylinder_axis_start_y << std::endl;
std::cout << "cylinder_axis_start_z = " << cylinder_axis_start_z << std::endl;
std::cout << "cylinder_axis_end_x = " << cylinder_axis_end_x << std::endl;
std::cout << "cylinder_axis_end_y = " << cylinder_axis_end_y << std::endl;
std::cout << "cylinder_axis_end_z = " << cylinder_axis_end_z << std::endl;
std::cout << "cylinder_radius = " << cylinder_radius << std::endl;
}
};
class Inner_region_tube_config_part : public Inner_region_config_part{
public:
double tube_axis_start_x;
double tube_axis_start_y;
double tube_axis_start_z;
double tube_axis_end_x;
double tube_axis_end_y;
double tube_axis_end_z;
double tube_inner_radius;
double tube_outer_radius;
public:
Inner_region_tube_config_part(){};
Inner_region_tube_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
tube_axis_start_x( ptree.get<double>("tube_axis_start_x") ),
tube_axis_start_y( ptree.get<double>("tube_axis_start_y") ),
tube_axis_start_z( ptree.get<double>("tube_axis_start_z") ),
tube_axis_end_x( ptree.get<double>("tube_axis_end_x") ),
tube_axis_end_y( ptree.get<double>("tube_axis_end_y") ),
tube_axis_end_z( ptree.get<double>("tube_axis_end_z") ),
tube_inner_radius( ptree.get<double>("tube_inner_radius") ),
tube_outer_radius( ptree.get<double>("tube_outer_radius") )
{};
virtual ~Inner_region_tube_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
std::cout << "tube_axis_start_x = " << tube_axis_start_x << std::endl;
std::cout << "tube_axis_start_y = " << tube_axis_start_y << std::endl;
std::cout << "tube_axis_start_z = " << tube_axis_start_z << std::endl;
std::cout << "tube_axis_end_x = " << tube_axis_end_x << std::endl;
std::cout << "tube_axis_end_y = " << tube_axis_end_y << std::endl;
std::cout << "tube_axis_end_z = " << tube_axis_end_z << std::endl;
std::cout << "tube_inner_radius = " << tube_inner_radius << std::endl;
std::cout << "tube_outer_radius = " << tube_outer_radius << std::endl;
}
};
class Inner_region_tube_along_z_segment_config_part : public Inner_region_config_part{
public:
double tube_along_z_segment_axis_x;
double tube_along_z_segment_axis_y;
double tube_along_z_segment_axis_start_z;
double tube_along_z_segment_axis_end_z;
double tube_along_z_segment_inner_radius;
double tube_along_z_segment_outer_radius;
double tube_along_z_segment_start_angle_deg;
double tube_along_z_segment_end_angle_deg;
public:
Inner_region_tube_along_z_segment_config_part(){};
Inner_region_tube_along_z_segment_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
tube_along_z_segment_axis_x(
ptree.get<double>("tube_along_z_segment_axis_x") ),
tube_along_z_segment_axis_y(
ptree.get<double>("tube_along_z_segment_axis_y") ),
tube_along_z_segment_axis_start_z(
ptree.get<double>("tube_along_z_segment_axis_start_z") ),
tube_along_z_segment_axis_end_z(
ptree.get<double>("tube_along_z_segment_axis_end_z") ),
tube_along_z_segment_inner_radius(
ptree.get<double>("tube_along_z_segment_inner_radius") ),
tube_along_z_segment_outer_radius(
ptree.get<double>("tube_along_z_segment_outer_radius") ),
tube_along_z_segment_start_angle_deg(
ptree.get<double>("tube_along_z_segment_start_angle_deg") ),
tube_along_z_segment_end_angle_deg(
ptree.get<double>("tube_along_z_segment_end_angle_deg") )
{};
virtual ~Inner_region_tube_along_z_segment_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
std::cout << "tube_along_z_segment_axis_x = "
<< tube_along_z_segment_axis_x << std::endl;
std::cout << "tube_along_z_segment_axis_y = "
<< tube_along_z_segment_axis_y << std::endl;
std::cout << "tube_along_z_segment_axis_start_z = "
<< tube_along_z_segment_axis_start_z << std::endl;
std::cout << "tube_along_z_segment_axis_end_z = "
<< tube_along_z_segment_axis_end_z << std::endl;
std::cout << "tube_along_z_segment_inner_radius = "
<< tube_along_z_segment_inner_radius << std::endl;
std::cout << "tube_along_z_segment_outer_radius = "
<< tube_along_z_segment_outer_radius << std::endl;
std::cout << "tube_along_z_segment_start_angle_deg = "
<< tube_along_z_segment_start_angle_deg << std::endl;
std::cout << "tube_along_z_segment_end_angle_deg = "
<< tube_along_z_segment_end_angle_deg << std::endl;
}
};
class Inner_region_cone_along_z_config_part : public Inner_region_config_part{
public:
double cone_axis_x;
double cone_axis_y;
double cone_axis_start_z;
double cone_axis_end_z;
double cone_start_inner_radius;
double cone_start_outer_radius;
double cone_end_inner_radius;
double cone_end_outer_radius;
public:
Inner_region_cone_along_z_config_part(){};
Inner_region_cone_along_z_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
Inner_region_config_part( name, ptree ),
cone_axis_x( ptree.get<double>("cone_axis_x") ),
cone_axis_y( ptree.get<double>("cone_axis_y") ),
cone_axis_start_z( ptree.get<double>("cone_axis_start_z") ),
cone_axis_end_z( ptree.get<double>("cone_axis_end_z") ),
cone_start_inner_radius( ptree.get<double>("cone_start_inner_radius") ),
cone_start_outer_radius( ptree.get<double>("cone_start_outer_radius") ),
cone_end_inner_radius( ptree.get<double>("cone_end_inner_radius") ),
cone_end_outer_radius( ptree.get<double>("cone_end_outer_radius") )
{};
virtual ~Inner_region_cone_along_z_config_part() {};
void print() {
std::cout << "Inner region: name = " << name << std::endl;
std::cout << "potential = " << potential << std::endl;
std::cout << "cone_axis_x = " << cone_axis_x << std::endl;
std::cout << "cone_axis_y = " << cone_axis_y << std::endl;
std::cout << "cone_axis_start_z = " << cone_axis_start_z << std::endl;
std::cout << "cone_axis_end_z = " << cone_axis_end_z << std::endl;
std::cout << "cone_start_inner_radius = " << cone_start_inner_radius << std::endl;
std::cout << "cone_start_outer_radius = " << cone_start_outer_radius << std::endl;
std::cout << "cone_end_inner_radius = " << cone_end_inner_radius << std::endl;
std::cout << "cone_end_outer_radius = " << cone_end_outer_radius << std::endl;
}
};
class Boundary_config_part {
public:
double boundary_phi_left;
double boundary_phi_right;
double boundary_phi_bottom;
double boundary_phi_top;
double boundary_phi_near;
double boundary_phi_far;
public:
Boundary_config_part(){};
Boundary_config_part( boost::property_tree::ptree &ptree ) :
boundary_phi_left( ptree.get<double>("boundary_phi_left") ),
boundary_phi_right( ptree.get<double>("boundary_phi_right") ),
boundary_phi_bottom( ptree.get<double>("boundary_phi_bottom") ),
boundary_phi_top( ptree.get<double>("boundary_phi_top") ),
boundary_phi_near( ptree.get<double>("boundary_phi_near") ),
boundary_phi_far( ptree.get<double>("boundary_phi_far") )
{} ;
virtual ~Boundary_config_part() {};
void print() {
std::cout << "boundary_phi_left = " << boundary_phi_left << std::endl;
std::cout << "boundary_phi_right = " << boundary_phi_right << std::endl;
std::cout << "boundary_phi_bottom = " << boundary_phi_bottom << std::endl;
std::cout << "boundary_phi_top = " << boundary_phi_top << std::endl;
std::cout << "boundary_phi_near = " << boundary_phi_near << std::endl;
std::cout << "boundary_phi_far = " << boundary_phi_far << std::endl;
}
};
class External_field_config_part {
public:
std::string name;
public:
External_field_config_part(){};
External_field_config_part(
std::string name, boost::property_tree::ptree &ptree ):
name( name )
{};
virtual ~External_field_config_part() {};
virtual void print() {
std::cout << "External field:" << std::endl;
std::cout << "name = " << name << std::endl;
}
};
class External_magnetic_field_uniform_config_part : public External_field_config_part{
public:
double magnetic_field_x;
double magnetic_field_y;
double magnetic_field_z;
public:
External_magnetic_field_uniform_config_part(){};
External_magnetic_field_uniform_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
External_field_config_part( name, ptree ),
magnetic_field_x( ptree.get<double>("magnetic_field_x") ),
magnetic_field_y( ptree.get<double>("magnetic_field_y") ),
magnetic_field_z( ptree.get<double>("magnetic_field_z") )
{} ;
virtual ~External_magnetic_field_uniform_config_part() {};
void print() {
std::cout << "External magnetic field uniform : name = " << name << std::endl;
std::cout << "magnetic_field_x = " << magnetic_field_x << std::endl;
std::cout << "magnetic_field_y = " << magnetic_field_y << std::endl;
std::cout << "magnetic_field_z = " << magnetic_field_z << std::endl;
}
};
class External_electric_field_uniform_config_part : public External_field_config_part{
public:
double electric_field_x;
double electric_field_y;
double electric_field_z;
public:
External_electric_field_uniform_config_part(){};
External_electric_field_uniform_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
External_field_config_part( name, ptree ),
electric_field_x( ptree.get<double>("electric_field_x") ),
electric_field_y( ptree.get<double>("electric_field_y") ),
electric_field_z( ptree.get<double>("electric_field_z") )
{} ;
virtual ~External_electric_field_uniform_config_part() {};
void print() {
std::cout << "External electric field uniform : name = " << name << std::endl;
std::cout << "electric_field_x = " << electric_field_x << std::endl;
std::cout << "electric_field_y = " << electric_field_y << std::endl;
std::cout << "electric_field_z = " << electric_field_z << std::endl;
}
};
class External_magnetic_field_tinyexpr_config_part : public External_field_config_part{
public:
std::string magnetic_field_x;
std::string magnetic_field_y;
std::string magnetic_field_z;
public:
External_magnetic_field_tinyexpr_config_part(){};
External_magnetic_field_tinyexpr_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
External_field_config_part( name, ptree ),
magnetic_field_x( ptree.get<std::string>("magnetic_field_x") ),
magnetic_field_y( ptree.get<std::string>("magnetic_field_y") ),
magnetic_field_z( ptree.get<std::string>("magnetic_field_z") )
{} ;
virtual ~External_magnetic_field_tinyexpr_config_part() {};
void print() {
std::cout << "External magnetic field tinyexpr: name = " << name << std::endl;
std::cout << "magnetic_field_x = " << magnetic_field_x << std::endl;
std::cout << "magnetic_field_y = " << magnetic_field_y << std::endl;
std::cout << "magnetic_field_z = " << magnetic_field_z << std::endl;
}
};
class External_electric_field_tinyexpr_config_part : public External_field_config_part{
public:
std::string electric_field_x;
std::string electric_field_y;
std::string electric_field_z;
public:
External_electric_field_tinyexpr_config_part(){};
External_electric_field_tinyexpr_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
External_field_config_part( name, ptree ),
electric_field_x( ptree.get<std::string>("electric_field_x") ),
electric_field_y( ptree.get<std::string>("electric_field_y") ),
electric_field_z( ptree.get<std::string>("electric_field_z") )
{} ;
virtual ~External_electric_field_tinyexpr_config_part() {};
void print() {
std::cout << "External electric field tinyexpr: name = " << name << std::endl;
std::cout << "electric_field_x = " << electric_field_x << std::endl;
std::cout << "electric_field_y = " << electric_field_y << std::endl;
std::cout << "electric_field_z = " << electric_field_z << std::endl;
}
};
class External_electric_field_on_regular_grid_config_part :
public External_field_config_part{
public:
std::string h5filename;
public:
External_electric_field_on_regular_grid_config_part(){};
External_electric_field_on_regular_grid_config_part(
std::string name, boost::property_tree::ptree &ptree ) :
External_field_config_part( name, ptree ),
h5filename( ptree.get<std::string>("filename") )
{} ;
virtual ~External_electric_field_on_regular_grid_config_part() {};
void print() {
std::cout << "External electric field on_regular_grid: name = "
<< name << std::endl;
std::cout << "h5filename = " << h5filename << std::endl;
}
};
class Particle_interaction_model_config_part {
public:
std::string particle_interaction_model;
public:
Particle_interaction_model_config_part(){};
Particle_interaction_model_config_part( boost::property_tree::ptree &ptree ) :
particle_interaction_model( ptree.get<std::string>("particle_interaction_model") )
{} ;
virtual ~Particle_interaction_model_config_part() {};
void print() {
std::cout << "Particle_interaction_model = "
<< particle_interaction_model << std::endl;
}
};
class Output_filename_config_part {
public:
std::string output_filename_prefix;
std::string output_filename_suffix;
public:
Output_filename_config_part(){};
Output_filename_config_part( boost::property_tree::ptree &ptree ) :
output_filename_prefix( ptree.get<std::string>("output_filename_prefix") ),
output_filename_suffix( ptree.get<std::string>("output_filename_suffix") )
{} ;
virtual ~Output_filename_config_part() {};
void print() {
std::cout << "Output_filename_prefix = " << output_filename_prefix << std::endl;
std::cout << "Output_filename_suffix = " << output_filename_suffix << std::endl;
}
};
class Config {
public:
Time_config_part time_config_part;
Mesh_config_part mesh_config_part;
boost::ptr_vector<Particle_source_config_part> sources_config_part;
boost::ptr_vector<Inner_region_config_part> inner_regions_config_part;
boost::ptr_vector<External_field_config_part> fields_config_part;
Boundary_config_part boundary_config_part;
Particle_interaction_model_config_part particle_interaction_model_config_part;
Output_filename_config_part output_filename_config_part;
public:
Config( const std::string &filename );
virtual ~Config() {};
void print() {
std::cout << "=== Config file echo ===" << std::endl;
time_config_part.print();
mesh_config_part.print();
for ( auto &s : sources_config_part ) {
s.print();
}
for ( auto &ir : inner_regions_config_part ) {
ir.print();
}
boundary_config_part.print();
particle_interaction_model_config_part.print();
output_filename_config_part.print();
for ( auto &f : fields_config_part ) {
f.print();
}
std::cout << "======" << std::endl;
}
};
#endif /* _CONFIG_H_ */