diff --git a/src/FEMTruss.jl b/src/FEMTruss.jl index ff12e0e..9853ac7 100644 --- a/src/FEMTruss.jl +++ b/src/FEMTruss.jl @@ -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) @@ -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) @@ -132,6 +133,6 @@ function assemble_elements!(problem::Problem, assembly::Assembly, end end -export Truss +export Truss, get_Kg_and_Tg end diff --git a/test/test_problems.jl b/test/test_problems.jl index 943396d..a512194 100644 --- a/test/test_problems.jl +++ b/test/test_problems.jl @@ -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