mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-08-30 08:02:50 +00:00
test2
This commit is contained in:
@@ -18,6 +18,10 @@ include("xdmf.jl")
|
||||
include("abaqus_reader.jl")
|
||||
include("interfaces.jl")
|
||||
|
||||
<<<<<<< HEAD
|
||||
export set_coordinates, get_coordinates #, set_material
|
||||
=======
|
||||
#export set_coordinates, get_coordinates, set_material
|
||||
>>>>>>> 18394347dd9874ca301e7612fc776ccab08f4601
|
||||
|
||||
end # module
|
||||
|
||||
+16
-32
@@ -8,7 +8,7 @@ Get jacobian of element evaluated at point xi
|
||||
"""
|
||||
function get_jacobian(el::Element, xi)
|
||||
dbasisdxi(xi) = get_dbasisdxi(el, xi)
|
||||
X = get_coordinates(el)
|
||||
X = get_field(el, "coordinates")
|
||||
J = interpolate(X, dbasisdxi, xi)'
|
||||
return J
|
||||
end
|
||||
@@ -24,28 +24,26 @@ function get_dbasisdX(el::Element, xi)
|
||||
end
|
||||
|
||||
"""
|
||||
Return coordinates of element in array of size dim x nnodes
|
||||
Set field variable.
|
||||
"""
|
||||
function get_coordinates(el::Element)
|
||||
el.coordinates
|
||||
function set_field(el::Element, field_name, field_value)
|
||||
el.fields[field_name] = field_value
|
||||
end
|
||||
|
||||
"""
|
||||
Set coordinates for element
|
||||
Get field variable.
|
||||
"""
|
||||
function set_coordinates(el::Element, coordinates)
|
||||
el.coordinates = coordinates
|
||||
function get_field(el::Element, field_name)
|
||||
el.fields[field_name]
|
||||
end
|
||||
|
||||
"""
|
||||
Get element id
|
||||
Evaluate field in point xi using basis functions.
|
||||
"""
|
||||
function get_element_id(el::Element)
|
||||
el.id
|
||||
function interpolate(el::Element, field::ASCIIString, xi::Array{Float64,1})
|
||||
(get_basis(el, xi)'*get_field(el, field))'
|
||||
end
|
||||
|
||||
|
||||
|
||||
### Lagrange family ###
|
||||
|
||||
abstract CG <: Element # Lagrange element family
|
||||
@@ -73,21 +71,13 @@ function create_lagrange_element(element_name, X, P, dP)
|
||||
invA = inv(A)'
|
||||
|
||||
type $element_name
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
|
||||
function $element_name(element_id, node_ids)
|
||||
coordinates = zeros(dim, nnodes)
|
||||
function $element_name(node_ids)
|
||||
fields = Dict{ASCIIString, Any}()
|
||||
$element_name(element_id, node_ids, coordinates, fields)
|
||||
end
|
||||
|
||||
function $element_name(element_id, node_ids, coordinates)
|
||||
fields = Dict{ASCIIString, Any}()
|
||||
$element_name(element_id, node_ids, coordinates, fields)
|
||||
$element_name(node_ids, fields)
|
||||
end
|
||||
|
||||
function get_basis(el::$element_name, xi)
|
||||
@@ -110,9 +100,7 @@ end
|
||||
1 node point element
|
||||
"""
|
||||
type Point1 <: CG
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
|
||||
@@ -122,9 +110,7 @@ end
|
||||
2 node linear line element
|
||||
"""
|
||||
type Seg2 <: CG
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
|
||||
@@ -137,9 +123,7 @@ end
|
||||
3 node quadratic line element
|
||||
"""
|
||||
type Seg2 <: CG
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
#X = [-1.0 1.0 0.0]'
|
||||
@@ -153,11 +137,13 @@ end
|
||||
4 node bilinear quadrangle element
|
||||
"""
|
||||
type Quad4 <: CG
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
function Quad4(node_ids)
|
||||
fields = Dict{ASCIIString, Any}()
|
||||
Quad4(node_ids, fields)
|
||||
end
|
||||
function get_basis(el::Quad4, xi)
|
||||
[(1-xi[1])*(1-xi[2])/4
|
||||
(1+xi[1])*(1-xi[2])/4
|
||||
@@ -193,9 +179,7 @@ end
|
||||
10 node quadratic tethahedron
|
||||
"""
|
||||
type Tet10 <: CG
|
||||
element_id :: Int
|
||||
node_ids :: Array{Int, 1}
|
||||
coordinates :: Array{Float64, 2}
|
||||
fields :: Dict{ASCIIString, Any}
|
||||
end
|
||||
# X = [
|
||||
|
||||
+5
-5
@@ -7,7 +7,7 @@ This module contains math stuff, including interpolation, integration, lineariza
|
||||
|
||||
using ForwardDiff
|
||||
|
||||
export interpolate, integrate, linearize
|
||||
#export interpolate, integrate, linearize
|
||||
|
||||
"""
|
||||
Interpolate field variable using basis functions f for point ip.
|
||||
@@ -59,10 +59,10 @@ function interpolate{T<:Real}(field::Array{T,2}, basis::Function, ip)
|
||||
end
|
||||
return result
|
||||
end
|
||||
function interpolate(e::Element, field::ASCIIString, x::Array{Float64,1}; derivative=false)
|
||||
basis = derivative ? get_dbasisdxi(e) : get_basis(e)
|
||||
return interpolate(e.attributes[field], basis, x)
|
||||
end
|
||||
#function interpolate(e::Element, field::ASCIIString, x::Array{Float64,1}; derivative=false)
|
||||
# basis = derivative ? get_dbasisdxi(e) : get_basis(e)
|
||||
# return interpolate(e.attributes[field], basis, x)
|
||||
#end
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-17
@@ -1,7 +1,7 @@
|
||||
# This file is a part of JuliaFEM.
|
||||
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
||||
|
||||
export IntegrationPoint, Element, Assembly, FunctionSpace
|
||||
export IntegrationPoint, Assembly
|
||||
|
||||
"""
|
||||
Integration point
|
||||
@@ -19,22 +19,7 @@ type IntegrationPoint
|
||||
weight :: Float64
|
||||
attributes :: Dict{ASCIIString, Any}
|
||||
end
|
||||
|
||||
type FunctionSpace
|
||||
basis :: Function
|
||||
dbasis :: Function
|
||||
end
|
||||
|
||||
abstract Element
|
||||
|
||||
#type Element
|
||||
# id :: Int
|
||||
# node_ids :: Array{Int, 1}
|
||||
# shape_functions :: FunctionSpace
|
||||
# integration_points :: Array{IntegrationPoint, 1}
|
||||
# attributes :: Dict{ASCIIString, Any}
|
||||
#end
|
||||
|
||||
IntegrationPoint(xi, weight) = IntegrationPoint(xi, weight, Dict{AsciiString, Any}())
|
||||
|
||||
type Assembly
|
||||
# LHS
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# This file is a part of JuliaFEM.
|
||||
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
|
||||
|
||||
using FactCheck
|
||||
|
||||
facts("test set and interpolate field variable") do
|
||||
el = Quad4(1, [1, 2, 3, 4])
|
||||
set_coordinates(el, [0.0 0.0; 10.0 0.0; 10.0 1.0; 0.0 1.0]')
|
||||
set_field(el, "displacement", [0.0 0.0; 0.0 0.0; 0.5 0.0; 0.0 0.0]'')
|
||||
fval = interpolate(el, "displacement", [0.0, 1.0])
|
||||
Logging.debug(fval)
|
||||
@fact fval --> roughly([0.25 0.0]')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user