Skip to content

Commit 2535030

Browse files
Adjusted formulations to extract full matrices, skip ci
1 parent 33b8002 commit 2535030

4 files changed

Lines changed: 273 additions & 278 deletions

File tree

examples/tutorial3.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ opts = FEMOptions(
6767
force_remesh=false, # Force remeshing
6868
run_solver=true,
6969
overwrite_results=true,
70+
plot_field_maps=false,
7071
preview_geo=false, # Preview geometry
7172
preview_mesh=false, # Preview the mesh
7273
base_path=joinpath(@__DIR__, "fem_output"),

src/FEMTools.jl

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -182,44 +182,6 @@ mutable struct FEMElectrodynamics <: AbstractAdmittanceFormulation
182182
end
183183

184184

185-
function _run_solver(workspace)
186-
"""
187-
Verbosity Levels in GetDP
188-
Level Output Description
189-
0 Silent (no output)
190-
1 Errors only
191-
2 Errors + warnings
192-
3 Errors + warnings + basic info
193-
4 Detailed debugging
194-
5 Full internal tracing
195-
"""
196-
mesh_file = workspace.paths[:mesh_file]
197-
pro_file_path = workspace.paths[:pro_file]
198-
all_problemns = build_getdp_problem(workspace)
199-
200-
write_multiple_problems(all_problemns, pro_file_path)
201-
202-
# Set up paths
203-
getdp_exe_path = workspace.opts.getdp_executable
204-
205-
# Write all problems to files
206-
@info "Running opts..."
207-
for formulation in workspace.formulation.analysis_type
208-
# Run solver for each formulation
209-
solve_cmd = "$getdp_exe_path $pro_file_path -msh $mesh_file -solve $(formulation.resolution_name) -v$(workspace.opts.verbosity == 0 ? 2 : 3)"
210-
211-
@info "Solving... (Resolution = $(formulation.resolution_name))"
212-
213-
try
214-
gmsh.onelab.run("GetDP", solve_cmd)
215-
@info "Solve successful!"
216-
# gmsh.fltk.run()
217-
catch e
218-
println("Solve failed: ", e)
219-
end
220-
end
221-
end
222-
223185
"""
224186
$(TYPEDEF)
225187
@@ -339,14 +301,12 @@ struct FEMOptions <: FormulationOptions
339301
"Flag to remove or keep all files for each frequency run."
340302
cleanup_files::Bool
341303

342-
"Flag to run postprocessing."
343-
run_postprocessing::Bool
344304
"Flag to preview the mesh."
345305
preview_mesh::Bool
346306
"Flag to preview the geometry."
347307
preview_geo::Bool
348-
"Flag to plot results."
349-
plot_results::Bool
308+
"Flag to plot field maps in postprocessing stage."
309+
plot_field_maps::Bool
350310

351311
"Base path for output files."
352312
base_path::String
@@ -372,7 +332,7 @@ struct FEMOptions <: FormulationOptions
372332
- `run_postprocessing`: Flag to run postprocessing \\[dimensionless\\]. Default: true.
373333
- `preview_mesh`: Flag to preview the mesh \\[dimensionless\\]. Default: false.
374334
- `preview_geo`: Flag to preview the geometry \\[dimensionless\\]. Default: false.
375-
- `plot_results`: Flag to plot results \\[dimensionless\\]. Default: true.
335+
- `plot_field_maps`: Flag to plot results \\[dimensionless\\]. Default: true.
376336
- `base_path`: Base path for output files. Default: "./fem_output".
377337
- `gmsh_executable`: Path to Gmsh executable. Default: from environment.
378338
- `getdp_executable`: Path to GetDP executable. Default: from environment.
@@ -401,10 +361,9 @@ struct FEMOptions <: FormulationOptions
401361
run_solver::Bool=true,
402362
overwrite_results::Bool=false,
403363
cleanup_files::Bool=false,
404-
run_postprocessing::Bool=true,
405364
preview_mesh::Bool=false,
406365
preview_geo::Bool=false,
407-
plot_results::Bool=true,
366+
plot_field_maps::Bool=true,
408367
base_path::String="./fem_output",
409368
gmsh_executable::Union{String,Nothing}=nothing,
410369
getdp_executable::Union{String,Nothing}=nothing,
@@ -432,7 +391,7 @@ struct FEMOptions <: FormulationOptions
432391

433392
return new(
434393
force_remesh, run_solver, overwrite_results, cleanup_files,
435-
run_postprocessing, preview_mesh, preview_geo, plot_results,
394+
preview_mesh, preview_geo, plot_field_maps,
436395
base_path, gmsh_executable, getdp_executable, verbosity, logfile
437396
)
438397
end
@@ -603,7 +562,7 @@ function compute!(problem::LineParametersProblem,
603562
@info "Running GetDP solver..."
604563

605564
# Get dimensions for preallocation
606-
n_phases = problem.system.num_phases
565+
n_phases = sum([length(c.design_data.components) for c in workspace.problem_def.system.cables])
607566
n_frequencies = length(problem.frequencies)
608567

609568
# Preallocate 3D arrays for Z and Y matrices
@@ -623,8 +582,9 @@ function compute!(problem::LineParametersProblem,
623582
end
624583
end
625584
# Read results and store in 3D arrays
626-
Z[:, :, i] = read_results_file(formulation.analysis_type[1], frequency, workspace)
627-
Y[:, :, i] = read_results_file(formulation.analysis_type[2], frequency, workspace)
585+
Z[:, :, i] = read_results_file(formulation.analysis_type[1], workspace)
586+
Y[:, :, i] = read_results_file(formulation.analysis_type[2], workspace)
587+
628588
catch e
629589
@error "Failed to compute matrices for frequency $frequency Hz" exception = e
630590
rethrow(e)

0 commit comments

Comments
 (0)