Skip to content

Commit 2e153b3

Browse files
Adds code to probesAdapter and changes pointprobes to fieldprobes in jsons
1 parent b71784b commit 2e153b3

File tree

3 files changed

+78
-152
lines changed

3 files changed

+78
-152
lines changed

test/adapter/ProbesAdapter.cpp

+21-13
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,38 @@ const Direction assignFieldSpatial(const std::string& direction)
3232
}
3333
}
3434

35+
std::vector<double> assembleVector(const json& input)
36+
{
37+
std::vector<double> res(input.size());
38+
for (int i = 0; i < input.size(); i++) {
39+
res[i] = input[i];
40+
}
41+
return res;
42+
}
43+
3544
Probes assembleProbes(const json& case_data)
3645
{
3746

3847
Probes probes;
3948

40-
if (case_data.contains("exporter_probes")) {
49+
if (case_data.contains("exporter")) {
4150
ExporterProbe exporter_probe;
42-
exporter_probe.name = case_data["name"];
43-
exporter_probe.visSteps = case_data["exporter_probe"]["steps"];
51+
exporter_probe.name = case_data["model"]["filename"];
52+
exporter_probe.visSteps = case_data["probes"]["exporter"]["steps"];
4453
probes.exporterProbes.push_back(exporter_probe);
4554
}
4655

47-
if (case_data.contains("point_probes")) {
48-
for (int p = 0; p < case_data["point_probes"].size(); p++) {
49-
auto field{ assignFieldType(case_data["point_probes"][p][0]) };
50-
auto direction{ assignFieldSpatial(case_data["point_probes"][p][1]) };
51-
std::vector<double> point(case_data["point_probes"][p][2].size());
52-
for (int i = 0; i < point.size(); i++) {
53-
point[i] = case_data["point_probes"][p][2][i];
54-
}
55-
PointProbe point_probe(field, direction, point);
56-
probes.pointProbes.push_back(point_probe);
56+
if (case_data.contains("field")) {
57+
for (int p = 0; p < case_data["field"].size(); p++) {
58+
FieldProbe field_probe(
59+
assembleVector(case_data["field"][p]["position"])
60+
);
61+
probes.fieldProbes.push_back(field_probe);
5762
}
5863
}
64+
65+
// Surface probes will go here.
66+
5967
return probes;
6068
}
6169

testData/maxwellInputs/1D_PEC_Centered/1D_PEC_Centered.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
"exporter": {
3434
"steps": 1
3535
},
36-
"points": [
36+
"field": [
3737
{
38-
"field": "E",
3938
"position": [ 0.0 ]
4039
}
4140
],
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,66 @@
11
{
2-
"solver_options": {
3-
"solver_type": {
4-
"__description": "Defines the evolution operator that will be used in the simulation. Can be 'Centered' or 'Upwind'.",
5-
"type": "string",
6-
"default": "Centered",
7-
"enum": ["Centered", "Upwind"]
8-
},
9-
"final_time": {
10-
"__description": "In Natural Units (1m/c), how long the problem will be simulated.",
11-
"type": "double",
12-
"default": 2.0
13-
},
14-
"time_step": {
15-
"__description": "In Natural Units (1m/c), defines the time step increments between iterations. If not defined or set to 0.0 in 1D, will use an automatic time step calculation approach through CFL's condition. Must be defined in 2D and/or 3D. Overrides CFL for 1D if defined.",
16-
"type": "double",
17-
"default": 0.0
18-
},
19-
"cfl": {
20-
"__description": "Courant–Friedrichs–Lewy condition, defines time step increments between iterations for 1D. Not available for 2D and/or 3D. If 'time_step' is defined this parameter is ignored.",
21-
"type": "double",
22-
"minimum": 0.1,
23-
"maximum": 1.0,
24-
"default": 0.7
25-
},
26-
"order": {
27-
"__description": "Polynomial order of the interpolation function used on the mesh elements.",
28-
"type": "integer",
29-
"minimum": 0,
30-
"default": 3
31-
},
32-
"spectral": {
33-
"__description": "Use an Evolution Operator that uses a complete matrix form for all E and H unknowns but allows to calculate an approximate time step through analysis of the Eigenvalues of the matrix. Heavy computational cost, slower than the default Evolution Operators. Does not support the latest features.",
34-
"type": "boolean",
35-
"default": false
36-
}
2+
"solver_options": {
3+
"solver_type": "Centered",
4+
"final_time": 2.0,
5+
"time_step": 1e-2,
6+
"cfl": 0.7,
7+
"order": 3,
8+
"spectral": false
379
},
3810

39-
"model": {
40-
"__description": "Contains the information relevant to the mesh, materials and boundary conditions.",
41-
"type": "object",
42-
"filename": {
43-
"__description": "Name of the mesh file. Must be the same as the folder name.",
44-
"type": "string"
45-
},
46-
"materials": {
47-
"__description": "Contains the physical information of the interiors of the materials in the problem.",
48-
"type": "array",
11+
"model": {
12+
"filename": "1D_PEC_Centered.msh",
13+
"materials": [
4914
{
50-
"tags": {
51-
"__description": "Contains the tags referring to the geometrical identification of volumetrical elements in the mesh. (Volumes in 3D, Surfaces in 2D, Segments in 1D.)",
52-
"type": "array of integers"
53-
},
54-
"class": {
55-
"__description": "Type of material.",
56-
"type": "string",
57-
"enum": [ "Vacuum", "Dielectric", "Conductor" ]
58-
},
59-
"relative_permittivity": {
60-
"__description": "Relative permittivity of the material.",
61-
"type": "double",
62-
"minimum": 1.0,
63-
"default": 1.0
64-
},
65-
"relative_permeability": {
66-
"__description": "Relative permeability of the material.",
67-
"type": "double",
68-
"minimum": 1.0,
69-
"default": 1.0
70-
}
71-
}
72-
},
73-
"boundaries": {
74-
"__description": "Contains the physical information of the surfaces of the problem.",
75-
"type": "array",
15+
"tags": [ 1 ],
16+
"type": "Vacuum"
17+
},
7618
{
77-
"tags": {
78-
"__description": "Contains the tags referring to the geometrical identification of surface elements in the mesh. (Surfaces in 3D, Segments in 2D, Points in 1D.)",
79-
"type": "array of integers"
80-
},
81-
"class": {
82-
"__description": "Type of boundary condition.",
83-
"type": "string",
84-
"enum": [ "PEC", "PMC", "SMA" ]
85-
}
19+
"tags": [ 2 ],
20+
"type": "Dielectric",
21+
"relative_permittivity": 3.1
8622
}
87-
},
88-
89-
"probes": {
90-
"__description": "Contains the information relevant to data extraction.",
91-
"type": "object",
23+
],
24+
"boundaries": [
9225
{
93-
"exporter": {
94-
"__description": "If defined, all fields will be exported for Paraview visualization.",
95-
"type": "object",
96-
{
97-
"steps": {
98-
"__description": "Every how many time steps data should be extracted.",
99-
"type": "integer",
100-
"minimum": 1,
101-
"default": 1
102-
}
103-
}
104-
},
105-
"points": {
106-
"__description": "If defined, will extract all components of the specified field at the defined position.",
107-
"type": "object"
108-
{
109-
"field": {
110-
"__description": "Field to extract.",
111-
"type": "string",
112-
"enum": ["E", "H"]
113-
},
114-
"position": {
115-
"__description": "Physical space position of the extraction. Must be defined within valid mesh limits or the simulation will crash.",
116-
"type": "nDimensional array",
117-
}
118-
}
119-
}
26+
"tags": [ 1, 2 ],
27+
"type": "PEC"
28+
}
29+
]
30+
},
12031

121-
},
32+
"probes": {
33+
"exporter": {
34+
"steps": 1
12235
},
36+
"field": [
37+
{
38+
"position": [ 0.0 ]
39+
}
40+
]
41+
},
12342

124-
"sources": [
125-
{
126-
"class": "initial",
127-
"field_type": "E",
128-
"center": [ 0.5 ],
129-
"polarization": [ 0.0, 1.0, 0.0 ],
130-
"dimension": 1,
131-
"magnitude": {
132-
"class": "gaussian",
133-
"spread": 0.15,
134-
"delay": 1.0
135-
}
136-
},
137-
{
138-
"class": "initial",
139-
"field_type": "E",
140-
"polarization": [ 0.0, 1.0, 0.0 ],
141-
"magnitude": {
142-
"class": "resonant",
143-
"mode": [ 2 ]
144-
}
145-
}
146-
]
147-
}
43+
"sources": [
44+
{
45+
"type": "initial",
46+
"field_type": "E",
47+
"center": [ 0.5 ],
48+
"polarization": [ 0.0, 1.0, 0.0 ],
49+
"dimension": 1,
50+
"magnitude": {
51+
"type": "gaussian",
52+
"spread": 0.15,
53+
"delay": 1.0
54+
}
55+
},
56+
{
57+
"type": "initial",
58+
"field_type": "E",
59+
"polarization": [ 0.0, 1.0, 0.0 ],
60+
"magnitude": {
61+
"type": "resonant",
62+
"mode": [ 2 ]
63+
}
64+
}
65+
]
66+
}

0 commit comments

Comments
 (0)