Skip to content

Commit

Permalink
add conversion methods
Browse files Browse the repository at this point in the history
  • Loading branch information
taylormcd committed Aug 23, 2022
1 parent d1d3818 commit cdae1d1
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/afmesh.jl
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ end
Base.eltype(::Layer{TF}) where {TF} = TF
Base.eltype(::Type{Layer{TF}}) where {TF} = TF

Layer{TF}(l::Layer) where {TF} = Layer{TF}(l.material, l.t, l.theta)
Base.convert(::Type{Layer{TF}}, l::Layer) where {TF} = Layer{TF}(l)

# from https://discourse.julialang.org/t/findnearest-function/4143/4
function searchsortednearest(a, x)
idx = searchsortedfirst(a, x)
10 changes: 10 additions & 0 deletions src/section.jl
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@ end
Base.eltype(::Material{TF}) where TF = TF
Base.eltype(::Type{Material{TF}}) where TF = TF

Material{TF}(m::Material) where {TF} = Material{TF}(m.E1, m.E2, m.E3, m.G12, m.G13, m.G23,
m.nu12, m.nu13, m.nu23, m.rho)
Base.convert(::Type{Material{TF}}, m::Material) where {TF} = Material{TF}(m)

"""
Node(x, y)
@@ -44,6 +48,9 @@ end
Base.eltype(::Node{TF}) where TF = TF
Base.eltype(::Type{Node{TF}}) where TF = TF

Node{TF}(n::Node) where {TF} = Node{TF}(n.x, n.y)
Base.convert(::Type{Node{TF}}, n::Node) where {TF} = Node{TF}(n)

"""
MeshElement(nodenum, material, theta)
@@ -64,6 +71,9 @@ end
Base.eltype(::MeshElement{VI, TF}) where {VI, TF} = TF
Base.eltype(::Type{MeshElement{VI, TF}}) where {VI, TF} = TF

MeshElement{VI,TF}(e::MeshElement) where {VI,TF} = MeshElement{VI,TF}(e.nodenum, e.material, e.theta)
Base.convert(::Type{MeshElement{VI,TF}}, e::MeshElement) where {VI,TF} = MeshElement{VI,TF}(e)

"""
internal cache so allocations happen only once upfront
"""

0 comments on commit cdae1d1

Please sign in to comment.