mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-19 01:48:47 +00:00
Change coords field type from Point to Tuple
Change to Tuple, Array is allocating memory.
This commit is contained in:
+4
-4
@@ -330,8 +330,8 @@ function get_integration_points{E}(element::Element{E})
|
||||
# first time initialize default integration points
|
||||
if length(element.integration_points) == 0
|
||||
ips = get_integration_points(element.properties)
|
||||
if E in (Seg2, Seg3, NSeg)
|
||||
element.integration_points = [IP(i, w, [xi]) for (i, (w, xi)) in enumerate(ips)]
|
||||
if E in (Poi1, Seg2, Seg3, NSeg)
|
||||
element.integration_points = [IP(i, w, (xi,)) for (i, (w, xi)) in enumerate(ips)]
|
||||
else
|
||||
element.integration_points = [IP(i, w, xi) for (i, (w, xi)) in enumerate(ips)]
|
||||
end
|
||||
@@ -344,8 +344,8 @@ of integration scheme mainly for mass matrix.
|
||||
"""
|
||||
function get_integration_points{E}(element::Element{E}, change_order::Int)
|
||||
ips = get_integration_points(element.properties, Val{change_order})
|
||||
if E in (Seg2, Seg3, NSeg)
|
||||
return [IP(i, w, [xi]) for (i, (w, xi)) in enumerate(ips)]
|
||||
if E in (Poi1, Seg2, Seg3, NSeg)
|
||||
return [IP(i, w, (xi,)) for (i, (w, xi)) in enumerate(ips)]
|
||||
else
|
||||
return [IP(i, w, xi) for (i, (w, xi)) in enumerate(ips)]
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ function get_integration_order(element::Poi1)
|
||||
end
|
||||
|
||||
function get_integration_points(element::Poi1, order::Int64)
|
||||
return [ (1.0, [] ) ]
|
||||
return [ (1.0, 0.0) ]
|
||||
end
|
||||
|
||||
function size(::Type{Poi1})
|
||||
|
||||
+1
-1
@@ -54,5 +54,5 @@ end
|
||||
|
||||
# All good codes needs a special case. Here we have it: Poi1
|
||||
function get_integration_points(element::Poi1)
|
||||
[ (1.0, [] ) ]
|
||||
[ (1.0, 0.0) ]
|
||||
end
|
||||
|
||||
+7
-2
@@ -8,7 +8,7 @@ abstract type AbstractPoint end
|
||||
type Point{P<:AbstractPoint}
|
||||
id :: Int
|
||||
weight :: Float64
|
||||
coords :: Vector{Float64}
|
||||
coords :: Tuple{Vararg{Float64}}
|
||||
fields :: Dict{AbstractString, Field}
|
||||
properties :: P
|
||||
end
|
||||
@@ -66,6 +66,11 @@ end
|
||||
|
||||
const IP = Point{IntegrationPoint}
|
||||
|
||||
function IP(id, weight, coords)
|
||||
function IP(id, weight, coords::Tuple)
|
||||
return IP(id, weight, coords, Dict(), IntegrationPoint())
|
||||
end
|
||||
|
||||
function IP(id, weight, coords::Vector)
|
||||
warn("Consider giving coords as Tuple.")
|
||||
return IP(id, weight, [c for c in coords], Dict(), IntegrationPoint())
|
||||
end
|
||||
|
||||
@@ -5,7 +5,8 @@ using JuliaFEM
|
||||
using JuliaFEM.Testing
|
||||
|
||||
@testset "test integration point" begin
|
||||
ip = IP(1, 1.0, sqrt(1.0/3.0)*[-1.0, -1.0])
|
||||
a = sqrt(1.0/3.0)
|
||||
ip = IP(1, 1.0, (a, -a))
|
||||
strain = [1.0 2.0; 3.0 4.0]
|
||||
update!(ip, "strain", 0.0 => strain)
|
||||
@test isapprox(ip("strain", 0.0), strain)
|
||||
|
||||
Reference in New Issue
Block a user