Skip to content

Commit

Permalink
Added basic testing for NURBS. Fixed bug in NSolid interpolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojukka5 committed Jan 28, 2017
1 parent 3aa5e7d commit 8be9a1c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/elements_nurbs.jl
Expand Up @@ -92,12 +92,12 @@ function get_basis(element::Element{NSolid}, xi::Vector, time)
tu = element.properties.knots_u
tv = element.properties.knots_v
tw = element.properties.knots_w
w = element.properties.weights
nu = length(tu)
nv = length(tv)
nw = length(tw)
weights = element.properties.weights
nu = length(tu)-pu-1
nv = length(tv)-pv-1
nw = length(tw)-pw-1
u, v, w = xi
N = [w[i,j,k]*NURBS(i,pu,u,tu)*NURBS(j,pv,v,tv)*NURBS(k,pw,w,tw) for i=1:nu, j=1:nv, k=1:nw]
N = vec([weights[i,j,k]*NURBS(i,pu,u,tu)*NURBS(j,pv,v,tv)*NURBS(k,pw,w,tw) for i=1:nu, j=1:nv, k=1:nw])'
return N / sum(N)
end

Expand Down
20 changes: 20 additions & 0 deletions test/test_elements_nurbs.jl
@@ -0,0 +1,20 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md

using JuliaFEM
using JuliaFEM.Testing

@testset "NSeg interpolate" begin
element = Element(NSeg, [1, 2])
@test element([0.0], 0.0) == [0.5 0.5]
end

@testset "NSurf interpolate" begin
element = Element(NSurf, [1, 2, 3, 4])
@test element([0.0, 0.0], 0.0) == [0.25 0.25 0.25 0.25]
end

@testset "NSolid interpolate" begin
element = Element(NSolid, [1, 2, 3, 4, 5, 6, 7, 8])
@test element([0.0, 0.0, 0.0], 0.0) == [0.125 0.125 0.125 0.125 0.125 0.125 0.125 0.125]
end

0 comments on commit 8be9a1c

Please sign in to comment.