Skip to content

Commit

Permalink
Adds code to probesAdapter and changes pointprobes to fieldprobes in …
Browse files Browse the repository at this point in the history
…jsons
  • Loading branch information
AlejandroMunozManterola committed Nov 3, 2023
1 parent b71784b commit 2e153b3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 152 deletions.
34 changes: 21 additions & 13 deletions test/adapter/ProbesAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,38 @@ const Direction assignFieldSpatial(const std::string& direction)
}
}

std::vector<double> assembleVector(const json& input)
{
std::vector<double> res(input.size());
for (int i = 0; i < input.size(); i++) {
res[i] = input[i];
}
return res;
}

Probes assembleProbes(const json& case_data)
{

Probes probes;

if (case_data.contains("exporter_probes")) {
if (case_data.contains("exporter")) {
ExporterProbe exporter_probe;
exporter_probe.name = case_data["name"];
exporter_probe.visSteps = case_data["exporter_probe"]["steps"];
exporter_probe.name = case_data["model"]["filename"];
exporter_probe.visSteps = case_data["probes"]["exporter"]["steps"];
probes.exporterProbes.push_back(exporter_probe);
}

if (case_data.contains("point_probes")) {
for (int p = 0; p < case_data["point_probes"].size(); p++) {
auto field{ assignFieldType(case_data["point_probes"][p][0]) };
auto direction{ assignFieldSpatial(case_data["point_probes"][p][1]) };
std::vector<double> point(case_data["point_probes"][p][2].size());
for (int i = 0; i < point.size(); i++) {
point[i] = case_data["point_probes"][p][2][i];
}
PointProbe point_probe(field, direction, point);
probes.pointProbes.push_back(point_probe);
if (case_data.contains("field")) {
for (int p = 0; p < case_data["field"].size(); p++) {
FieldProbe field_probe(
assembleVector(case_data["field"][p]["position"])
);
probes.fieldProbes.push_back(field_probe);
}
}

// Surface probes will go here.

return probes;
}

Expand Down
3 changes: 1 addition & 2 deletions testData/maxwellInputs/1D_PEC_Centered/1D_PEC_Centered.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
"exporter": {
"steps": 1
},
"points": [
"field": [
{
"field": "E",
"position": [ 0.0 ]
}
],
Expand Down
193 changes: 56 additions & 137 deletions testData/maxwellInputs/JSON_Parser_Test/JSON_Parser_Test.json
Original file line number Diff line number Diff line change
@@ -1,147 +1,66 @@
{
"solver_options": {
"solver_type": {
"__description": "Defines the evolution operator that will be used in the simulation. Can be 'Centered' or 'Upwind'.",
"type": "string",
"default": "Centered",
"enum": ["Centered", "Upwind"]
},
"final_time": {
"__description": "In Natural Units (1m/c), how long the problem will be simulated.",
"type": "double",
"default": 2.0
},
"time_step": {
"__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.",
"type": "double",
"default": 0.0
},
"cfl": {
"__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.",
"type": "double",
"minimum": 0.1,
"maximum": 1.0,
"default": 0.7
},
"order": {
"__description": "Polynomial order of the interpolation function used on the mesh elements.",
"type": "integer",
"minimum": 0,
"default": 3
},
"spectral": {
"__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.",
"type": "boolean",
"default": false
}
"solver_options": {
"solver_type": "Centered",
"final_time": 2.0,
"time_step": 1e-2,
"cfl": 0.7,
"order": 3,
"spectral": false
},

"model": {
"__description": "Contains the information relevant to the mesh, materials and boundary conditions.",
"type": "object",
"filename": {
"__description": "Name of the mesh file. Must be the same as the folder name.",
"type": "string"
},
"materials": {
"__description": "Contains the physical information of the interiors of the materials in the problem.",
"type": "array",
"model": {
"filename": "1D_PEC_Centered.msh",
"materials": [
{
"tags": {
"__description": "Contains the tags referring to the geometrical identification of volumetrical elements in the mesh. (Volumes in 3D, Surfaces in 2D, Segments in 1D.)",
"type": "array of integers"
},
"class": {
"__description": "Type of material.",
"type": "string",
"enum": [ "Vacuum", "Dielectric", "Conductor" ]
},
"relative_permittivity": {
"__description": "Relative permittivity of the material.",
"type": "double",
"minimum": 1.0,
"default": 1.0
},
"relative_permeability": {
"__description": "Relative permeability of the material.",
"type": "double",
"minimum": 1.0,
"default": 1.0
}
}
},
"boundaries": {
"__description": "Contains the physical information of the surfaces of the problem.",
"type": "array",
"tags": [ 1 ],
"type": "Vacuum"
},
{
"tags": {
"__description": "Contains the tags referring to the geometrical identification of surface elements in the mesh. (Surfaces in 3D, Segments in 2D, Points in 1D.)",
"type": "array of integers"
},
"class": {
"__description": "Type of boundary condition.",
"type": "string",
"enum": [ "PEC", "PMC", "SMA" ]
}
"tags": [ 2 ],
"type": "Dielectric",
"relative_permittivity": 3.1
}
},

"probes": {
"__description": "Contains the information relevant to data extraction.",
"type": "object",
],
"boundaries": [
{
"exporter": {
"__description": "If defined, all fields will be exported for Paraview visualization.",
"type": "object",
{
"steps": {
"__description": "Every how many time steps data should be extracted.",
"type": "integer",
"minimum": 1,
"default": 1
}
}
},
"points": {
"__description": "If defined, will extract all components of the specified field at the defined position.",
"type": "object"
{
"field": {
"__description": "Field to extract.",
"type": "string",
"enum": ["E", "H"]
},
"position": {
"__description": "Physical space position of the extraction. Must be defined within valid mesh limits or the simulation will crash.",
"type": "nDimensional array",
}
}
}
"tags": [ 1, 2 ],
"type": "PEC"
}
]
},

},
"probes": {
"exporter": {
"steps": 1
},
"field": [
{
"position": [ 0.0 ]
}
]
},

"sources": [
{
"class": "initial",
"field_type": "E",
"center": [ 0.5 ],
"polarization": [ 0.0, 1.0, 0.0 ],
"dimension": 1,
"magnitude": {
"class": "gaussian",
"spread": 0.15,
"delay": 1.0
}
},
{
"class": "initial",
"field_type": "E",
"polarization": [ 0.0, 1.0, 0.0 ],
"magnitude": {
"class": "resonant",
"mode": [ 2 ]
}
}
]
}
"sources": [
{
"type": "initial",
"field_type": "E",
"center": [ 0.5 ],
"polarization": [ 0.0, 1.0, 0.0 ],
"dimension": 1,
"magnitude": {
"type": "gaussian",
"spread": 0.15,
"delay": 1.0
}
},
{
"type": "initial",
"field_type": "E",
"polarization": [ 0.0, 1.0, 0.0 ],
"magnitude": {
"type": "resonant",
"mode": [ 2 ]
}
}
]
}

0 comments on commit 2e153b3

Please sign in to comment.