Skip to content

Commit

Permalink
Merge 3c82c7d into c337df5
Browse files Browse the repository at this point in the history
  • Loading branch information
jtveiten committed Feb 15, 2018
2 parents c337df5 + 3c82c7d commit 600c2f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
13 changes: 7 additions & 6 deletions src/FEMTruss.jl
Expand Up @@ -34,13 +34,14 @@ function get_formulation_type(::Problem{Truss})
end

"""
get_K_and_T(element::Element{Seg2}, nnodes, ndim, time)
This function assembles the local stiffness and transformation matrix
Need this to find element forces later on
get_Kg_and_Tg(element::Element{Seg2}, nnodes, ndim, time)
This function assembles the local stiffness uses global transformation matrix
to make the global version of the local stiffnes matrix
Need these to find element forces later
Will need to change allocation strategy to pre-allocation later
Can discuss if we really need nnodes, since that is always 2 for trusses
"""
function get_K_and_T(element::Element{Seg2}, nnodes, ndim, time)
function get_Kg_and_Tg(element::Element{Seg2}, nnodes, ndim, time)
ndofs = nnodes*ndim
K = zeros(ndofs,ndofs)
T = zeros(2, ndofs*2)
Expand Down Expand Up @@ -96,7 +97,7 @@ function assemble!(assembly::Assembly, problem::Problem{Truss},
#Require that the number of nodes = 2 ?
nnodes = length(element)
ndim = get_unknown_field_dimension(problem)
K,T = get_K_and_T(element, nnodes, ndim, time)
K,T = get_Kg_and_Tg(element, nnodes, ndim, time)
gdofs = get_gdofs(problem, element)
add!(assembly.K, gdofs, gdofs, K)
#add!(assembly.f, gdofs, f)
Expand Down Expand Up @@ -132,6 +133,6 @@ function assemble_elements!(problem::Problem, assembly::Assembly,
end
end

export Truss
export Truss, get_Kg_and_Tg

end
20 changes: 16 additions & 4 deletions test/test_problems.jl
Expand Up @@ -65,8 +65,20 @@ using FEMTruss
@test isapprox(full(ls.u), u_glob)

# support forces
#println("K = ", full(ls.K))
#println("f = ", full(ls.f))
#println("u = ", full(ls.u))
println("la = ", full(ls.la))
support_forces = full(ls.K*ls.u)[1:4]
# This is the same as ls.la negated
# println("la = ", full(ls.la))
# The support forces from Sofistik
Rf = [-6.78823, -3.39411, -2.26274, 1.13137]
@test isapprox(support_forces, Rf, rtol=1e-5)
#find local truss Forces
K1,T1 = get_Kg_and_Tg(el1, 2,2, 0.0)
f_loc1 = T1*K1*ls.u[[1,2,5,6]] # No local forces her to add_elements
# both element forces should be stretch, item1 is negative
@test isapprox(-f_loc1[1], f_loc1[2])
@test isapprox(f_loc1[2], 7.58947, rtol=1e-5)
K2,T2 = get_Kg_and_Tg(el2, 2,2, 0.0)
f_loc2 = T2*K2*ls.u[3:6]
@test isapprox(-f_loc2[1], f_loc2[2])
@test isapprox(f_loc2[2], 2.52982,rtol=1e-5)
end

0 comments on commit 600c2f2

Please sign in to comment.