changed creating elements + preprocess aster med file more general for other inputs too

This commit is contained in:
Jukka Aho
2016-06-18 12:53:01 +03:00
parent bdb8f19bcf
commit 1ce7fd6096
8 changed files with 149 additions and 43 deletions
+8 -4
View File
@@ -76,8 +76,6 @@ export find_intersection, calc_reflection, calc_normal
### MORTAR STUFF ###
include("mortar.jl") # mortar projection
include("abaqus_reader_old.jl")
# rest of things
include("utils.jl")
include("core.jl")
@@ -88,9 +86,15 @@ include("api.jl")
end
module Preprocess
include("abaqus_reader.jl")
include("preprocess.jl")
export create_elements
include("preprocess_abaqus_reader.jl")
include("preprocess_abaqus_reader_old.jl")
include("preprocess_aster_reader.jl")
export aster_create_elements, parse_aster_med_file
export aster_create_elements, parse_aster_med_file, is_aster_mail_keyword,
parse_aster_header, aster_parse_nodes, aster_renumber_nodes!,
aster_renumber_elements!, aster_combine_meshes, aster_read_mesh,
filter_by_element_set, filter_by_element_id
end
module Postprocess
+75
View File
@@ -0,0 +1,75 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
importall Base
using JuliaFEM
type Mesh
nodes :: Dict{Int64, Vector{Float64}}
node_sets :: Dict{ASCIIString, Set{Int64}}
elements :: Dict{Int64, Vector{Int64}}
element_types :: Dict{Int64, Symbol}
element_sets :: Dict{ASCIIString, Set{Int64}}
end
function Mesh()
return Mesh(Dict(), Dict(), Dict(), Dict(), Dict())
end
function add_node!(mesh::Mesh, nid::Int, ncoords::Vector{Float64})
mesh.nodes[nid] = ncoords
end
function add_element!(mesh::Mesh, elid::Int, eltype::Symbol, connectivity::Vector{Int64})
mesh.elements[elid] = connectivity
mesh.element_types[elid] = eltype
end
function add_element_to_element_set!(mesh::Mesh, set_name::ASCIIString, elids...)
if !haskey(mesh.element_sets, set_name)
mesh.element_sets[set_name] = Set{Int64}()
end
push!(mesh.element_sets[set_name], elids...)
end
function copy(mesh::Mesh)
mesh2 = Mesh()
mesh2.nodes = copy(mesh.nodes)
mesh2.node_sets = copy(mesh.node_sets)
mesh2.elements = copy(mesh.elements)
mesh2.element_types = copy(mesh.element_types)
mesh2.element_sets = copy(mesh.element_sets)
return mesh2
end
function filter_by_element_id(mesh::Mesh, element_ids::Vector{Int64})
mesh2 = copy(mesh)
mesh2.elements = Dict()
for elid in element_ids
if haskey(mesh.elements, elid)
mesh2.elements[elid] = mesh.elements[elid]
end
end
return mesh2
end
function filter_by_element_set(mesh::Mesh, set_name::ASCIIString)
filter_by_element_id(mesh::Mesh, collect(mesh.element_sets[set_name]))
end
function create_elements(mesh::Mesh)
elements = Element[]
for (elid, elcon) in mesh.elements
eltype = mesh.element_types[elid]
element = Element(JuliaFEM.(eltype), elcon)
update!(element, "geometry", mesh.nodes)
push!(elements, element)
end
return elements
end
function create_elements(mesh::Mesh, element_set::ASCIIString)
return create_elements(filter_by_element_set(mesh, element_set))
end
+22
View File
@@ -372,3 +372,25 @@ function parse_aster_med_file(fn::ASCIIString, mesh_name=nothing)
result["connectivity"] = conn
return result
end
function aster_read_mesh(fn::ASCIIString, mesh_name=nothing)
result = parse_aster_med_file(fn, mesh_name)
mesh = Mesh()
for (nid, ncoords) in result["nodes"]
add_node!(mesh, nid, ncoords)
end
mapping = Dict(
:SE2 => :Seg2,
:TR3 => :Tri3,
:TR6 => :Tri6,
:QU4 => :Quad4,
:HE8 => :Hex8,
:TE4 => :Tet4,
:T10 => :Tet10)
for (elid, (eltype, elset, elcon)) in result["connectivity"]
add_element!(mesh, elid, mapping[eltype], elcon)
add_element_to_element_set!(mesh, string(elset), elid)
end
return mesh
end