Files
JuliaFEM.jl/src/types.jl
T

66 lines
1.4 KiB
Julia
Raw Normal View History

2015-08-16 13:33:02 +03:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
2015-12-23 17:39:53 +02:00
typealias Node Vector{Float64}
2016-05-25 22:33:47 +03:00
abstract AbstractPoint
2015-10-21 07:24:19 +03:00
2016-05-25 22:33:47 +03:00
type Point{P<:AbstractPoint}
id :: Int
2015-10-21 07:24:19 +03:00
weight :: Float64
2016-05-25 22:33:47 +03:00
coords :: Vector{Float64}
fields :: Dict{ASCIIString, Field}
2016-05-25 22:33:47 +03:00
properties :: P
2015-10-21 07:24:19 +03:00
end
2015-11-05 10:20:00 +02:00
2016-05-25 22:33:47 +03:00
function setindex!{T}(point::Point, val::Pair{Float64, T}, field_name::ASCIIString)
point.fields[field_name] = Field(val)
2015-10-21 07:24:19 +03:00
end
2016-05-25 22:33:47 +03:00
function getindex(point::Point, field_name::ASCIIString)
return point.fields[field_name]
end
2016-05-25 22:33:47 +03:00
function getindex(point::Point, idx::Int)
return point.coords[idx]
end
function haskey(point::Point, field_name::ASCIIString)
return haskey(point.fields, field_name)
end
2016-05-25 22:33:47 +03:00
function call(point::Point, field_name::ASCIIString, time::Float64=0.0)
point.fields[field_name](time).data
end
2016-05-25 22:33:47 +03:00
function update!{T}(point::Point, field_name, val::Pair{Float64, T})
if haskey(point, field_name)
update!(point[field_name], val)
else
point[field_name] = val
end
2015-11-05 10:20:00 +02:00
end
2015-11-11 00:52:16 +02:00
2016-05-25 22:33:47 +03:00
#= TODO: in future
type Node <: AbstractPoint
2015-11-11 00:52:16 +02:00
end
2016-05-25 22:33:47 +03:00
type MaterialPoint <: AbstractPoint
2015-11-11 00:52:16 +02:00
end
2016-05-25 22:33:47 +03:00
=#
2015-11-11 00:52:16 +02:00
2016-05-25 22:33:47 +03:00
type IntegrationPoint <: AbstractPoint
2015-11-11 00:52:16 +02:00
end
2016-05-25 22:33:47 +03:00
typealias IP Point{IntegrationPoint}
function IP(id, weight, coords)
return IP(id, weight, coords, Dict(), IntegrationPoint())
2015-11-11 00:52:16 +02:00
end
2015-11-21 18:23:41 +02:00
2016-05-25 22:33:47 +03:00
function convert(::Type{IP}, data::Tuple{Float64, Vector{Float64}})
weight, coords = data
return IP(-1, weight, coords)
2015-11-21 18:23:41 +02:00
end