mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-18 17:47:29 +00:00
Improvements to preprocess scripts
* convert several elements to node sets in one command * possibility to find particular node from mesh filtered by node set
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ module Preprocess
|
||||
include("preprocess.jl")
|
||||
export create_elements, Mesh, add_node!, add_nodes!, add_element!,
|
||||
add_elements!, add_element_to_element_set!, add_node_to_node_set!,
|
||||
find_nearest_nodes, reorder_element_connectivity!
|
||||
find_nearest_nodes, reorder_element_connectivity!, create_node_set_from_element_set!
|
||||
include("preprocess_abaqus_reader.jl")
|
||||
export parse_abaqus, parse_section, parse_element_section,
|
||||
abaqus_read_mesh, abaqus_read_model
|
||||
|
||||
+16
-6
@@ -50,12 +50,16 @@ function add_node_to_node_set!(mesh::Mesh, set_name, nids...)
|
||||
end
|
||||
|
||||
""" Create a new node set from nodes in element set. """
|
||||
function create_node_set_from_element_set!(mesh::Mesh, set_name)
|
||||
node_ids = Set{Int}()
|
||||
for elid in mesh.element_sets[set_name]
|
||||
push!(node_ids, mesh.elements[elid]...)
|
||||
function create_node_set_from_element_set!(mesh::Mesh, set_names::String...)
|
||||
for set_name in set_names
|
||||
set_name = Symbol(set_name)
|
||||
info("Creating node set $set_name from element set")
|
||||
node_ids = Set{Int}()
|
||||
for elid in mesh.element_sets[set_name]
|
||||
push!(node_ids, mesh.elements[elid]...)
|
||||
end
|
||||
mesh.node_sets[set_name] = node_ids
|
||||
end
|
||||
mesh.node_sets[set_name] = node_ids
|
||||
return
|
||||
end
|
||||
|
||||
@@ -145,14 +149,20 @@ end
|
||||
|
||||
|
||||
""" find npts nearest nodes from mesh and return id numbers as list. """
|
||||
function find_nearest_nodes(mesh::Mesh, coords::Vector, npts=1)
|
||||
function find_nearest_nodes(mesh::Mesh, coords::Vector{Float64}, npts::Int=1; node_set=nothing)
|
||||
dist = Dict{Int, Float64}()
|
||||
for (nid, c) in mesh.nodes
|
||||
if node_set != nothing && !(nid in mesh.node_sets[Symbol(node_set)])
|
||||
continue
|
||||
end
|
||||
dist[nid] = norm(coords-c)
|
||||
end
|
||||
s = sort(collect(dist), by=x->x[2])
|
||||
nd = s[1:npts] # [(id1, dist1), (id2, dist2), ..., (id_npts, dist_npts)]
|
||||
node_ids = [n[1] for n in nd]
|
||||
if length(node_ids) == 1
|
||||
return first(node_ids)
|
||||
end
|
||||
return node_ids
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user