Files
JuliaFEM.jl/src/readers/read_aster_results.jl
T
Jukka Aho ef9cddff13 feat: Consolidate AbaqusReader and AsterReader (mesh I/O)
- Added 1111 lines of mesh reading code to src/readers/
- ABAQUS .inp format support (6 files: parse_mesh, parse_model, keywords, etc.)
- Code Aster .med format support (3 files: read_aster_mesh, read_aster_results)
- Modernized Julia 0.x → 1.x syntax:
  * Nullable{T} → Union{T, Nothing}
  * get(nullable) → direct field access
- Added Logging stdlib to Project.toml dependencies
- Functions verified: abaqus_read_mesh, aster_read_mesh

Result: 7 vendor packages consolidated (~6400 lines total)
        FEMBasis, FEMBase, FEMQuad, FEMSparse, AbaqusReader, AsterReader
Tests: 5 passing (baseline maintained)
2025-11-08 11:25:13 +02:00

61 lines
1.9 KiB
Julia

# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/AsterReader.jl/blob/master/LICENSE
""" Code Aster result file (.rmed). """
mutable struct RMEDFile
data :: Dict
end
function RMEDFile(fn::String)
return RMEDFile(h5read(fn, "/"))
end
""" Return nodes from result med file. """
function aster_read_nodes(rmed::RMEDFile)
increments = keys(rmed.data["ENS_MAA"]["MAIL"])
@assert length(increments) == 1
increment = first(increments)
nodes = rmed.data["ENS_MAA"]["MAIL"][increment]["NOE"]
node_names = nodes["NOM"]
node_coords = nodes["COO"]
nnodes = length(node_names)
dim = round(Int, length(node_coords)/nnodes)
node_coords = reshape(node_coords, nnodes, dim)'
stripper(node_name) = strip(ascii(unsafe_string(pointer(convert(Vector{UInt8}, node_name)))))
node_names = map(stripper, node_names)
node_ids = map(parse_node_id, node_names)
nodes = Dict(j => node_coords[:,j] for j in node_ids)
return nodes
end
""" Read nodal field from rmed file. """
function aster_read_data(rmed::RMEDFile, field_name; field_type=:NODE,
info_fields=true, node_ids=nothing)
if occursin("ELGA", field_name)
field_type = :GAUSS
end
if node_ids == nothing
nodes = aster_read_nodes(rmed)
node_ids = sort(collect(keys(nodes)))
end
if info_fields
field_names = keys(rmed.data["CHA"])
all_fields = join(field_names, ", ")
@info("results: $all_fields")
end
chdata = rmed.data["CHA"]["RESU____$field_name"]
@assert length(chdata) == 1
increment = chdata[first(keys(chdata))]
if field_type == :NODE
data = increment["NOE"]["MED_NO_PROFILE_INTERNAL"]["CO"]
results = Dict(j => data[j] for j in node_ids)
else
error("Unable to read result of type $field_type: not implemented")
end
return results
end