Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition of the IO interface + HDF5/CGNS implementation #126

Merged
merged 43 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b7b9384
wip
May 15, 2024
48e30c5
wip
May 15, 2024
4599655
first tests on mesh ok
May 16, 2024
db16a80
fix indexrange
May 16, 2024
37f4038
reading pointList BCs
May 16, 2024
8195541
modifying solution structure
bmxam May 31, 2024
456762b
wip
bmxam Jun 3, 2024
fe61ac5
rename to JLD2
bmxam Jun 3, 2024
3696c82
rename JLD2Ext
bmxam Jun 3, 2024
6a204ee
rename JLD2 : OK !
bmxam Jun 3, 2024
bd31f29
reading vars ok
bmxam Jun 3, 2024
0a14f33
JLD2 does not support attributes
bmxam Jun 3, 2024
abd74ff
starting HDF5
bmxam Jun 4, 2024
d39af7b
HDF5 read seems ok
Jun 4, 2024
f87d500
writing elements ok (cgnscheck fail)
Jun 6, 2024
4a6f07d
write hdf5 (mesh only) seems ok -> cgnscheck ok, paraview ok
Jun 7, 2024
8929263
wip on write flowsol
bmxam Jun 10, 2024
38b33be
write seems ok
bmxam Jun 10, 2024
01782ac
wip on multiple flowsol
bmxam Jun 10, 2024
c269b95
writing multiple flowsolutions OK
Jun 11, 2024
24af29b
BaseIterativeData done
Jun 12, 2024
9146ef7
writing ZoneIterativeData ok
Jun 13, 2024
a3c6e49
reading multiple flowsolutions seems ok
Jun 13, 2024
11dfaf6
Merge branch 'main' into dev_io_interface
Jul 10, 2024
da85dfc
fix absence of ZoneBC
Jul 10, 2024
1e40483
Merge branch 'gmsh_compute_spadim' into dev_io_interface
bmxam Jul 15, 2024
9677d80
zone_space_dim vs usr_space_dim
bmxam Jul 15, 2024
c27c67b
Merge branch 'write_vtk_lagrange_0' into dev_io_interface
Jul 16, 2024
20ccd43
VTKIoHandler struct
Jul 16, 2024
d4cfbe8
moving "VTKExt" content into "vtk.jl"
Jul 16, 2024
875fb69
Merge branch 'write_vtk_lagrange_0' into dev_io_interface
Jul 17, 2024
74f445e
changing write API to use a unique U_export
Jul 23, 2024
bc2e0d7
new API "without" U_export
Jul 23, 2024
760082c
improve dispatch
Jul 23, 2024
17add07
remove VTKext
Jul 23, 2024
4342ba3
fix ambiguity
Jul 23, 2024
276310f
Merge branch 'main' into dev_io_interface
Jul 25, 2024
0d143d0
Merge branch 'optim_ref2phys' into dev_io_interface
ghislainb Jul 26, 2024
81194a3
Merge branch 'main' into dev_io_interface
ghislainb Jul 26, 2024
8a78a39
tiny typo fix
bmxam Jul 29, 2024
5796b1d
weird : apply formatter
bmxam Jul 29, 2024
d7e1f28
fix BaseIterativeData and write vector
bmxam Jul 30, 2024
a37f86a
ghislainb suggestions
bmxam Jul 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Bcube"
uuid = "cf06320b-b7f3-4748-8003-81a6b6979792"
authors = ["Ghislain Blanchard, Lokman Bennani and Maxime Bouyges"]
version = "0.1.11"
version = "0.1.12"

[deps]
FEMQuad = "be8e8821-3f6f-54c2-987c-d2773c3a52cb"
Expand All @@ -25,9 +25,19 @@ StaticArrays = "1.2"
Symbolics = "5"
WriteVTK = "1.12"
julia = "1.6"
JLD2 = "0.4.47"
HDF5 = "0.17"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

[weakdeps]
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"

[extensions]
JLD2Ext = "JLD2"
HDF5Ext = "HDF5"
8 changes: 8 additions & 0 deletions ext/HDF5Ext/HDF5Ext.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module HDF5Ext
using Bcube
using HDF5

include("./common.jl")
include("./read.jl")
include("./write.jl")
end
84 changes: 84 additions & 0 deletions ext/HDF5Ext/common.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const BCUBE_ENTITY_TO_CGNS_ENTITY = Dict(
Bcube.Node_t => 2,
Bcube.Bar2_t => 3,
Bcube.Bar3_t => 4,
Bcube.Tri3_t => 5,
Bcube.Tri6_t => 6,
Bcube.Tri9_t => 25,
Bcube.Tri10_t => 26,
Bcube.Quad4_t => 7,
Bcube.Quad8_t => 8,
Bcube.Quad9_t => 9,
Bcube.Quad16_t => 27,
Bcube.Tetra4_t => 10,
Bcube.Tetra10_t => 11,
Bcube.Pyra5_t => 12,
Bcube.Penta6_t => 14,
Bcube.Hexa8_t => 17,
Bcube.Hexa27_t => 27,
)
const CGNS_ENTITY_TO_BCUBE_ENTITY = Dict(v => k for (k, v) in BCUBE_ENTITY_TO_CGNS_ENTITY)

function bcube_entity_to_cgns_entity(::T) where {T <: Bcube.AbstractEntityType}
BCUBE_ENTITY_TO_CGNS_ENTITY[T]

Check warning on line 23 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L22-L23

Added lines #L22 - L23 were not covered by tests
end

cgns_entity_to_bcube_entity(code::Integer) = CGNS_ENTITY_TO_BCUBE_ENTITY[code]()

Check warning on line 26 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L26

Added line #L26 was not covered by tests

function get_child(parent; name = "", type = "")
child_name = findfirst(child -> child_match(child, name, type), parent)
return isnothing(child_name) ? nothing : parent[child_name]

Check warning on line 30 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L28-L30

Added lines #L28 - L30 were not covered by tests
end

function get_children(parent; name = "", type = "")
child_names = findall(child -> child_match(child, name, type), parent)
return map(child_name -> parent[child_name], child_names)

Check warning on line 35 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L33-L35

Added lines #L33 - L35 were not covered by tests
end

function child_match(child, name, type)
if get_name(child) == name
if length(name) > 0 && length(type) > 0
(get_cgns_type(child) == type) && (return true)
elseif length(name) > 0
return true

Check warning on line 43 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L38-L43

Added lines #L38 - L43 were not covered by tests
end
end

if get_cgns_type(child) == type
if length(name) > 0 && length(type) > 0
(get_name(child) == name) && (return true)
elseif length(type) > 0
return true

Check warning on line 51 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L47-L51

Added lines #L47 - L51 were not covered by tests
end
end

return false

Check warning on line 55 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L55

Added line #L55 was not covered by tests
end

get_name(obj) = String(last(split(HDF5.name(obj), '/')))

Check warning on line 58 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L58

Added line #L58 was not covered by tests

get_data_type(obj) = attributes(obj)["type"][]

Check warning on line 60 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L60

Added line #L60 was not covered by tests

get_cgns_type(obj) = haskey(attributes(obj), "label") ? attributes(obj)["label"][] : nothing

Check warning on line 62 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L62

Added line #L62 was not covered by tests

function get_value(obj)
data_type = get_data_type(obj)
data = read(obj[" data"])
if data_type == "C1"
return String(UInt8.(data))
elseif data_type in ("I4", "I8", "R4", "R8")
return data

Check warning on line 70 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L64-L70

Added lines #L64 - L70 were not covered by tests
else
error("Datatype '$(data_type)' not handled")

Check warning on line 72 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L72

Added line #L72 was not covered by tests
end
end

function get_cgns_base(obj)
cgnsBases = get_children(obj; type = "CGNSBase_t")
if length(cgnsBases) == 0
error("Could not find any CGNSBase_t node in the file")
elseif length(cgnsBases) > 1
error("The file contains several CGNSBase_t nodes, only one base is supported")

Check warning on line 81 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L76-L81

Added lines #L76 - L81 were not covered by tests
end
return first(cgnsBases)

Check warning on line 83 in ext/HDF5Ext/common.jl

View check run for this annotation

Codecov / codecov/patch

ext/HDF5Ext/common.jl#L83

Added line #L83 was not covered by tests
end
Loading
Loading