Skip to content

Commit 15d7a5e

Browse files
committed
Moved from BSON to JLD2 for storing systems
1 parent 2a2507d commit 15d7a5e

File tree

3 files changed

+4
-57
lines changed

3 files changed

+4
-57
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ authors = ["Taylor McDonnell <taylormcd@byu.edu", "Andrew Ning <aning@byu.edu>"]
44
version = "0.2.1"
55

66
[deps]
7-
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
87
CCBlade = "e1828068-15df-11e9-03e4-ef195ea46fa4"
98
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
109
FLOWMath = "6cb5d3fb-0fe8-4cc2-bd89-9fe0b19a99d3"
10+
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
1313
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
@@ -22,4 +22,3 @@ StaticArrays = "0.12, 1.0"
2222
VSPGeom = "0.6"
2323
WriteVTK = "1.8"
2424
julia = "1.10"
25-
BSON = "0.3"

src/VortexLattice.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using WriteVTK
77
using VSPGeom
88
using CCBlade
99
using DelimitedFiles
10-
using BSON
10+
using JLD2
1111

1212
# value for dimensionalizing, included just for clarity in the algorithms
1313
const RHO = 1.0

src/system.jl

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,7 @@ Save the system to a BSON file.
286286
- `nothing`: The function does not return anything, it saves the system to a file
287287
"""
288288
function save_system_to_bson(system::System, filename::AbstractString)
289-
fields = (
290-
:TF, :AIC, :w, , :V, :grids, :ratios, :surfaces, :invert_normals,
291-
:sections, :properties, :wakes, :trefftz, :reference,
292-
:freestream, :symmetric, :nwake, :surface_id, :wake_finite_core,
293-
:trailing_vortices, :xhat, :near_field_analysis, :derivatives, :dw, :dΓ,
294-
:dproperties, :wake_shedding_locations, :previous_surfaces, :Vcp, :Vh,
295-
:Vv, :Vte, :dΓdt
296-
)
297-
data = Dict{Symbol,Any}()
298-
for f in fields
299-
if f === :TF
300-
data[:TF] = eltype(system)
301-
else
302-
data[f] = getfield(system, f)
303-
end
304-
end
305-
BSON.bson(filename, data)
289+
JLD2.save_object(filename, system)
306290
return nothing
307291
end
308292

@@ -316,42 +300,6 @@ Load a system from a BSON file.
316300
- `system`: The system loaded from the file
317301
"""
318302
function load_system_from_bson(filename::AbstractString)
319-
data = BSON.load(filename)
320-
TF = data[:TF]
321-
322-
system = System{TF}(
323-
convert(Matrix{TF}, data[:AIC]),
324-
convert(Vector{TF}, data[:w]),
325-
convert(Vector{TF}, data[]),
326-
[convert(Matrix{SVector{3,TF}}, v) for v in data[:V]],
327-
[convert(Array{TF,3}, g) for g in data[:grids]],
328-
[convert(Array{TF,3}, r) for r in data[:ratios]],
329-
[convert(Matrix{SurfacePanel{TF}}, s) for s in data[:surfaces]],
330-
convert(Vector{Bool}, data[:invert_normals]),
331-
[convert(Vector{SectionProperties{TF}}, sec) for sec in data[:sections]],
332-
[convert(Matrix{PanelProperties{TF}}, p) for p in data[:properties]],
333-
[convert(Matrix{WakePanel{TF}}, w) for w in data[:wakes]],
334-
[convert(Vector{TrefftzPanel{TF}}, t) for t in data[:trefftz]],
335-
convert(Array{Reference{TF},0}, data[:reference]),
336-
convert(Array{Freestream{TF},0}, data[:freestream]),
337-
convert(Vector{Bool}, data[:symmetric]),
338-
convert(Vector{Int}, data[:nwake]),
339-
convert(Vector{Int}, data[:surface_id]),
340-
convert(Vector{Bool}, data[:wake_finite_core]),
341-
convert(Vector{Bool}, data[:trailing_vortices]),
342-
convert(Array{SVector{3,TF},0}, data[:xhat]),
343-
convert(Array{Bool,0}, data[:near_field_analysis]),
344-
convert(Array{Bool,0}, data[:derivatives]),
345-
Tuple(convert(Vector{TF}, d) for d in data[:dw]),
346-
Tuple(convert(Vector{TF}, d) for d in data[:dΓ]),
347-
Tuple([convert(Matrix{PanelProperties{TF}}, dp) for dp in d] for d in data[:dproperties]),
348-
[convert(Vector{SVector{3,TF}}, wsl) for wsl in data[:wake_shedding_locations]],
349-
[convert(Matrix{SurfacePanel{TF}}, ps) for ps in data[:previous_surfaces]],
350-
[convert(Matrix{SVector{3,TF}}, vcp) for vcp in data[:Vcp]],
351-
[convert(Matrix{SVector{3,TF}}, vh) for vh in data[:Vh]],
352-
[convert(Matrix{SVector{3,TF}}, vv) for vv in data[:Vv]],
353-
[convert(Vector{SVector{3,TF}}, vte) for vte in data[:Vte]],
354-
convert(Vector{TF}, data[:dΓdt])
355-
)
303+
system = JLD2.load_object(filename)
356304
return system
357305
end

0 commit comments

Comments
 (0)