@@ -6,104 +6,65 @@ namespace maxwell {
6
6
7
7
using namespace fixtures ::sources;
8
8
9
- mfem::Vector assembleCenterVector (const json& case_data )
9
+ mfem::Vector assembleCenterVector (const json& source_center )
10
10
{
11
- mfem::Vector res (case_data[ " dimension " ] );
12
- for (int i = 0 ; i < case_data[ " dimension " ] ; i++) {
13
- res[i] = case_data[ " sources " ][ " center " ] [i];
11
+ mfem::Vector res (source_center. size () );
12
+ for (int i = 0 ; i < source_center. size () ; i++) {
13
+ res[i] = source_center [i];
14
14
}
15
15
return res;
16
16
}
17
17
18
- mfem::Vector assemblePolarizationVector (const json& case_data )
18
+ mfem::Vector assemblePolarizationVector (const json& source_polarization )
19
19
{
20
- mfem::Vector res (case_data[ " sources " ][ " polarization " ] );
21
- for (int i = 0 ; i < case_data[ " sources " ][ " polarization " ] .size (); i++) {
22
- res[i] = case_data[ " sources " ][ " polarization " ] [i];
20
+ mfem::Vector res (3 );
21
+ for (int i = 0 ; i < source_polarization .size (); i++) {
22
+ res[i] = source_polarization [i];
23
23
}
24
24
return res;
25
25
}
26
26
27
- Source::CartesianAngles assembleRotationVector (const json& case_data )
27
+ mfem::Vector assemblePropagationVector (const json& source_propagation )
28
28
{
29
- Source::CartesianAngles res (3 );
30
- res[0 ] = 0.0 ;
31
- res[1 ] = 0.0 ;
32
- res[2 ] = 0.0 ;
33
- if (case_data[" rotation_angles" ]) {
34
- for (int i = 0 ; i < case_data[" sources" ][" rotation_angles" ].size (); i++) {
35
- res[i] = case_data[" sources" ][" rotation_angles" ][i];
36
- }
37
- }
38
- return res;
39
- }
40
-
41
- mfem::Vector assemblePropagationVector (const json& case_data)
42
- {
43
- mfem::Vector res (case_data[" sources" ][" propagation" ]);
44
- for (int i = 0 ; i < case_data[" sources" ][" propagation" ].size (); i++) {
45
- res[i] = case_data[" sources" ][" propagation" ][i];
29
+ mfem::Vector res (3 );
30
+ for (int i = 0 ; i < source_propagation.size (); i++) {
31
+ res[i] = source_propagation[i];
46
32
}
47
33
return res;
48
34
}
49
35
50
36
Sources assembleSources (const json& case_data)
51
37
{
52
-
53
- auto field{ assignFieldType (case_data[" sources" ][" field_type" ]) };
54
- auto direction{ assignFieldSpatial (case_data[" sources" ][" field_spatial" ])};
55
- auto center (assembleCenterVector (case_data));
56
- auto polarization (assemblePolarizationVector (case_data));
57
- auto rotation_angles (assembleRotationVector (case_data));
58
-
59
38
Sources res;
60
- if (case_data[" sources" ][" type" ] == " Initial" ) {
61
- return buildGaussianInitialField (
62
- field,
63
- case_data[" sources" ][" spread" ],
64
- center,
65
- polarization,
66
- case_data[" sources" ][" source_dimension" ],
67
- rotation_angles
68
- );
69
- }
70
- else if (case_data[" sources" ][" type" ] == " Resonant" ) {
71
- return buildResonantModeInitialField (
72
- field,
73
- polarization,
74
- case_data[" sources" ][" modes" ]
75
- );
76
- }
77
- else if (case_data[" sources" ][" type" ] == " TDPlanewave" ) {
78
- auto propagation (assemblePropagationVector (case_data));
79
- return buildGaussianPlanewave (
80
- case_data[" sources" ][" spread" ],
81
- case_data[" sources" ][" delay" ],
82
- polarization,
83
- propagation
84
- );
85
- }
86
- else if (case_data[" sources" ][" type" ] == " InitPlanewave" ) {
87
- auto propagation (assemblePropagationVector (case_data));
88
- if (case_data[" sources" ][" function_type" ] == " Gaussian" ) {
89
- auto function{
90
- Gaussian (
91
- case_data[" sources" ][" spread" ],
92
- mfem::Vector (0.0 ),
93
- case_data[" sources" ][" sources_dimension" ]
94
- )
95
- };
96
- return buildPlanewaveInitialField (
97
- function,
98
- center,
99
- polarization,
100
- propagation,
101
- rotation_angles
39
+ for (auto s{ 0 }; s < case_data[" sources" ].size (); s++) {
40
+ if (case_data[" sources" ][s][" type" ] == " initial" ) {
41
+ if (case_data[" sources" ][s][" magnitude" ][" type" ] == " gaussian" ) {
42
+ return buildGaussianInitialField (
43
+ assignFieldType (case_data[" sources" ][s][" field_type" ]),
44
+ case_data[" sources" ][s][" magnitude" ][" spread" ],
45
+ assembleCenterVector (case_data[" sources" ][s][" center" ]),
46
+ assemblePolarizationVector (case_data[" sources" ][s][" polarization" ]),
47
+ case_data[" sources" ][s][" dimension" ]
48
+ );
49
+ }
50
+ else if (case_data[" sources" ][s][" magnitude" ][" type" ] == " resonant" ) {
51
+ return buildResonantModeInitialField (
52
+ assignFieldType (case_data[" sources" ][s][" field_type" ]),
53
+ assemblePolarizationVector (case_data[" sources" ][s][" polarization" ]),
54
+ case_data[" sources" ][s][" magnitude" ][" modes" ]
55
+ );
56
+ }
57
+ }
58
+ else if (case_data[" sources" ][s][" type" ] == " totalField" ) {
59
+ auto propagation (assemblePropagationVector (case_data));
60
+ return buildGaussianPlanewave (
61
+ case_data[" sources" ][" spread" ],
62
+ case_data[" sources" ][" delay" ],
63
+ assemblePolarizationVector (case_data[" sources" ][s][" polarization" ]),
64
+ assemblePropagationVector (case_data[" sources" ][s][" propagation" ])
102
65
);
103
66
}
104
67
}
105
-
106
-
107
68
}
108
69
109
70
}
0 commit comments