Skip to content

Commit

Permalink
Making Lagrange2Tri345 interpolation values exact (#633)
Browse files Browse the repository at this point in the history
This patche makes shape function evaluation of the Lagrange2Tri345 interpolations
exact by reordering some floating point operations. Fixes #582.
  • Loading branch information
AbdAlazezAhmed authored Mar 23, 2023
1 parent cc81e6c commit ae96dbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,9 @@ function value(ip::Lagrange2Tri345, i::Int, ξ::Vec{2})
i = permdof2DLagrange2Tri345[order][i]
ξ_x = ξ[1]
ξ_y = ξ[2]
γ = 1. - ξ_x - ξ_y
i1, i2, i3 = _numlin_basis2D(i, order)
val = one(γ)
i1 1 && (val *= prod((order * γ - j) / (j + 1) for j = 0:(i1 - 1)))
val = one(ξ_y)
i1 1 && (val *= prod((order - order * (ξ_x + ξ_y ) - j) / (j + 1) for j = 0:(i1 - 1)))
i2 1 && (val *= prod((order * ξ_x - j) / (j + 1) for j = 0:(i2 - 1)))
i3 1 && (val *= prod((order * ξ_y - j) / (j + 1) for j = 0:(i3 - 1)))
return val
Expand Down
2 changes: 1 addition & 1 deletion test/test_interpolations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Lagrange{2, RefTetrahedron, 2}(),
Lagrange{2, RefTetrahedron, 3}(),
Lagrange{2, RefTetrahedron, 4}(),
#Lagrange{2, RefTetrahedron, 5}(),
Lagrange{2, RefTetrahedron, 5}(),
Lagrange{3, RefCube, 1}(),
Lagrange{3, RefCube, 2}(),
Serendipity{2, RefCube, 2}(),
Expand Down

0 comments on commit ae96dbd

Please sign in to comment.