mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-10-03 22:57:57 +00:00
more tests. fixed performace bug in creating elements from mesh
This commit is contained in:
+4
-2
@@ -6,6 +6,8 @@ This is JuliaFEM -- Finite Element Package
|
||||
"""
|
||||
module JuliaFEM
|
||||
|
||||
using Compat
|
||||
import Compat.String
|
||||
importall Base
|
||||
|
||||
include("fields.jl")
|
||||
@@ -15,10 +17,10 @@ export AbstractPoint, Point, IntegrationPoint, IP, Node
|
||||
|
||||
### ELEMENTS ###
|
||||
include("elements.jl") # common element routines
|
||||
export Node, AbstractElement, Element, update!, get_connectivity, get_basis, get_dbasis
|
||||
export Node, AbstractElement, Element, update!, get_connectivity, get_basis, get_dbasis, inside, get_local_coordinates
|
||||
include("elements_lagrange_macro.jl") # Continuous Galerkin (Lagrange) elements generated using macro
|
||||
include("elements_lagrange.jl") # Continuous Galerkin (Lagrange) elements
|
||||
export get_reference_coordinates
|
||||
export get_reference_coordinates, get_interpolation_polynomial
|
||||
export Poi1,
|
||||
Seg2, Seg3,
|
||||
Tri3, Tri6, Quad4, Quad8, Quad9,
|
||||
|
||||
+3
-8
@@ -89,13 +89,8 @@ function filter_by_element_set(mesh::Mesh, set_name::String)
|
||||
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
|
||||
elements = [Element(JuliaFEM.(mesh.element_types[elid]), elcon) for (elid, elcon) in mesh.elements]
|
||||
update!(elements, "geometry", mesh.nodes)
|
||||
return elements
|
||||
end
|
||||
|
||||
@@ -103,7 +98,7 @@ function create_elements(mesh::Mesh, element_sets::String...)
|
||||
elements = Element[]
|
||||
for element_set in element_sets
|
||||
new_elements = create_elements(filter_by_element_set(mesh, element_set))
|
||||
push!(elements, new_elements...)
|
||||
elements = [elements; new_elements]
|
||||
end
|
||||
return elements
|
||||
end
|
||||
|
||||
@@ -346,11 +346,13 @@ Dict containing fields "nodes" and "connectivity".
|
||||
"""
|
||||
function parse_aster_med_file(fn::String, mesh_name=nothing; debug=false)
|
||||
med = MEDFile(fn)
|
||||
if isa(mesh_name, Void)
|
||||
mesh_names = get_mesh_names(med::MEDFile)
|
||||
all_meshes = join(mesh_names, ", ")
|
||||
mesh_names = get_mesh_names(med::MEDFile)
|
||||
all_meshes = join(mesh_names, ", ")
|
||||
if mesh_name == nothing
|
||||
length(mesh_names) == 1 || error("several meshes found from med, pick one: $all_meshes")
|
||||
mesh_name = mesh_names[1]
|
||||
else
|
||||
mesh_name in mesh_names || error("Mesh $mesh_name not found from mesh file $fn. Available meshes: $all_meshes")
|
||||
end
|
||||
nsets = get_node_sets(med, mesh_name)
|
||||
elsets = get_element_sets(med, mesh_name)
|
||||
|
||||
@@ -21,7 +21,7 @@ xi
|
||||
"""
|
||||
function project_from_master_to_slave{E<:MortarElements2D}(
|
||||
slave_element::Element{E}, x1_::DVTI, n1_::DVTI, x2::Vector;
|
||||
tol=1.0e-10, max_iterations=20)
|
||||
tol=1.0e-10, max_iterations=20, debug=false)
|
||||
|
||||
x1(xi1) = vec(get_basis(slave_element, [xi1], time))*x1_
|
||||
dx1(xi1) = vec(get_dbasis(slave_element, [xi1], time))*x1_
|
||||
@@ -32,21 +32,32 @@ function project_from_master_to_slave{E<:MortarElements2D}(
|
||||
dR(xi1) = cross2(dx1(xi1), n1(xi1)) + cross2(x1(xi1)-x2, dn1(xi1))
|
||||
|
||||
xi1 = 0.0
|
||||
xi1_next = 0.0
|
||||
dxi1 = 0.0
|
||||
for i=1:max_iterations
|
||||
dxi1 = -R(xi1)/dR(xi1)
|
||||
xi1 += dxi1
|
||||
if norm(dxi1) < tol
|
||||
return xi1
|
||||
dxi1 = clamp(dxi1, -0.3, 0.3)
|
||||
xi1_next = clamp(xi1 + dxi1, -1.0, 1.0)
|
||||
if norm(xi1_next - xi1) < tol
|
||||
return xi1_next
|
||||
end
|
||||
if debug
|
||||
info("xi1 = $xi1")
|
||||
info("R(xi1) = $(R(xi1))")
|
||||
info("dR(xi1) = $(dR(xi1))")
|
||||
info("dxi1 = $dxi1")
|
||||
info("norm = $(norm(xi1_next - xi1))")
|
||||
info("xi1_next = $xi1_next")
|
||||
end
|
||||
xi1 = xi1_next
|
||||
end
|
||||
|
||||
info("x1 = $(ForwardDiff.get_value(x1_.data))")
|
||||
info("n1 = $(ForwardDiff.get_value(n1_.data))")
|
||||
info("x2 = $(ForwardDiff.get_value(x2))")
|
||||
info("xi1 = $(ForwardDiff.get_value(xi1)), dxi1 = $(ForwardDiff.get_value(dxi1))")
|
||||
info("-R(xi1) = $(ForwardDiff.get_value(-R(xi1)))")
|
||||
info("dR(xi1) = $(ForwardDiff.get_value(dR(xi1)))")
|
||||
info("x1 = $x1_")
|
||||
info("n1 = $n1_")
|
||||
info("x2 = $x2")
|
||||
info("xi1 = $xi1, dxi1 = $dxi1")
|
||||
info("-R(xi1) = $(-R(xi1))")
|
||||
info("dR(xi1) = $(dR(xi1))")
|
||||
error("find projection from master to slave: did not converge")
|
||||
|
||||
end
|
||||
@@ -157,17 +168,8 @@ function assemble!(problem::Problem{Contact}, time::Float64,
|
||||
#distance > props.maximum_distance && continue
|
||||
|
||||
# calculate segmentation: we care only about endpoints
|
||||
# note: these are quadratic/cubic functions, analytical solution possible
|
||||
xi1a = -Inf
|
||||
xi1b = -Inf
|
||||
try
|
||||
xi1a = project_from_master_to_slave(slave_element, x1, n1, x2[1])
|
||||
xi1b = project_from_master_to_slave(slave_element, x1, n1, x2[2])
|
||||
catch
|
||||
info("failed to create projection!!!!")
|
||||
# TODO
|
||||
continue
|
||||
end
|
||||
xi1a = project_from_master_to_slave(slave_element, x1, n1, x2[1])
|
||||
xi1b = project_from_master_to_slave(slave_element, x1, n1, x2[2])
|
||||
xi1 = clamp([xi1a; xi1b], -1.0, 1.0)
|
||||
l = 1/2*abs(xi1[2]-xi1[1])
|
||||
isapprox(l, 0.0) && continue # no contribution in this master element
|
||||
|
||||
Reference in New Issue
Block a user