Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consolidate some of the standard Gauss-Legendre rules a bit
- Loading branch information
1 parent
913c987
commit 9bb8323
Showing
11 changed files
with
96 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Generates a tablaue of weights and points for Gauss Legendre quadrature | ||
# on a line | ||
using FastGaussQuadrature | ||
|
||
const MAX_ORDER = 5 | ||
open(joinpath(@__DIR__, "..", "src", "quaddata.jl"), "w") do f | ||
println(f, "const QUAD_DATA = [") | ||
for g in 1:MAX_ORDER | ||
points, weights = gausslegendre(g) | ||
println(f, "[(", join(points, ", "), ",),") | ||
println(f, "(", join(weights, ", "), ",)],") | ||
end | ||
println(f, "]") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,40 @@ | ||
# This file is a part of JuliaFEM. | ||
# License is MIT: see https://github.com/JuliaFEM/FEMQuad.jl/blob/master/LICENSE | ||
|
||
### Gauss quadrature rules for quadrilaterals | ||
# Tensorial quadrature rules in 1, 2, 3 dimensions | ||
|
||
function tensor_product(w::Tuple, p::Tuple, dim::Int) | ||
@assert length(w) == length(p) | ||
|
||
function tensor_product_2d(w::Tuple, p::Tuple) | ||
N = length(w) | ||
weights = Float64[] | ||
points = Tuple{Float64, Float64}[] | ||
for i in 1:N | ||
for j in 1:N | ||
push!(weights, w[i]*w[j]) | ||
push!(points, (p[i], p[j])) | ||
end | ||
points = NTuple{dim, Float64}[] | ||
for i in CartesianIndices(ntuple(i -> 1:N, dim)) | ||
push!(weights, prod(w[k] for k in Tuple(i))) | ||
push!(points, ntuple(k -> p[i[k]], dim)) | ||
end | ||
return zip(weights, points) | ||
end | ||
|
||
""" Gauss-Legendre quadrature, 1 point rule on quadrilateral. """ | ||
function get_quadrature_points(::Type{Val{:GLQUAD1}}) | ||
w = (2.0, ) | ||
p = (0.0, ) | ||
return tensor_product_2d(w, p) | ||
end | ||
|
||
function get_order(::Type{Val{:GLQUAD1}}) | ||
return 1 | ||
end | ||
|
||
""" Gauss-Legendre quadrature, 4 point rule on quadrilateral. """ | ||
function get_quadrature_points(::Type{Val{:GLQUAD4}}) | ||
w = (1.0, 1.0) | ||
p = (-sqrt(1.0/3.0), sqrt(1.0/3.0)) | ||
return tensor_product_2d(w, p) | ||
end | ||
|
||
function get_order(::Type{Val{:GLQUAD4}}) | ||
return 3 | ||
return zip(Tuple(weights), Tuple(points)) | ||
end | ||
|
||
""" Gauss-Legendre quadrature, 9 point rule on quadrilateral. """ | ||
function get_quadrature_points(::Type{Val{:GLQUAD9}}) | ||
w = (5.0/9.0, 8.0/9.0, 5.0/9.0) | ||
p = (-sqrt(3.0/5.0), 0.0, sqrt(3.0/5.0)) | ||
return tensor_product_2d(w, p) | ||
end | ||
|
||
function get_order(::Type{Val{:GLQUAD9}}) | ||
return 5 | ||
end | ||
names = [:GLSEG, :GLQUAD, :GLHEX] | ||
names2 = ["segment", "quadrilateral", "hexahedron"] | ||
|
||
""" Gauss-Legendre quadrature, 16 point rule on quadrilateral. """ | ||
function get_quadrature_points(::Type{Val{:GLQUAD16}}) | ||
w = ( | ||
1.0/36.0*(18.0-sqrt(30.0)), | ||
1.0/36.0*(18.0+sqrt(30.0)), | ||
1.0/36.0*(18.0+sqrt(30.0)), | ||
1.0/36.0*(18.0-sqrt(30.0))) | ||
p = ( | ||
-sqrt(3.0/7.0 + 2.0/7.0*sqrt(6.0/5.0)), | ||
-sqrt(3.0/7.0 - 2.0/7.0*sqrt(6.0/5.0)), | ||
sqrt(3.0/7.0 - 2.0/7.0*sqrt(6.0/5.0)), | ||
sqrt(3.0/7.0 + 2.0/7.0*sqrt(6.0/5.0))) | ||
return tensor_product_2d(w, p) | ||
end | ||
for n in 1:length(QUAD_DATA) | ||
points, weights = QUAD_DATA[n] | ||
order = 2(n-1)+1 | ||
for dim in (1, 2, 3) | ||
n_points = length(points)^dim | ||
quadname = QuoteNode(Symbol(string(names[dim], n_points))) | ||
z = tensor_product(weights, points, dim) | ||
@eval begin | ||
@doc """ | ||
get_quadrature_points(::Type{Val{:$($(quadname))}) | ||
function get_order(::Type{Val{:GLQUAD16}}) | ||
return 7 | ||
end | ||
|
||
""" Gauss-Legendre quadrature, 25 point rule on quadrilateral. """ | ||
function get_quadrature_points(::Type{Val{:GLQUAD25}}) | ||
w = ( | ||
1.0/900.0*(322.0-13.0*sqrt(70.0)), | ||
1.0/900.0*(322.0+13.0*sqrt(70.0)), | ||
128.0/225.0, | ||
1.0/900.0*(322.0+13.0*sqrt(70.0)), | ||
1.0/900.0*(322.0-13.0*sqrt(70.0))) | ||
p = ( | ||
-1.0/3.0*sqrt(5.0 + 2.0*sqrt(10.0/7.0)), | ||
-1.0/3.0*sqrt(5.0 - 2.0*sqrt(10.0/7.0)), | ||
0.0, | ||
1.0/3.0*sqrt(5.0 - 2.0*sqrt(10.0/7.0)), | ||
1.0/3.0*sqrt(5.0 + 2.0*sqrt(10.0/7.0))) | ||
return tensor_product_2d(w, p) | ||
Gauss-Legendre quadrature, $($(n_points)) point rule on $($(names2[dim])).""" | ||
get_quadrature_points(::Type{Val{$(quadname)}}) = $z | ||
end | ||
@eval get_order(::Type{Val{$(quadname)}}) = $order | ||
end | ||
end | ||
|
||
function get_order(::Type{Val{:GLQUAD25}}) | ||
return 9 | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const QUAD_DATA = [ | ||
[(0.0,), | ||
(2.0,)], | ||
[(-0.5773502691896258, 0.5773502691896258,), | ||
(1.0, 1.0,)], | ||
[(-0.7745966692414834, 0.0, 0.7745966692414834,), | ||
(0.5555555555555556, 0.8888888888888888, 0.5555555555555556,)], | ||
[(-0.8611363115940526, -0.3399810435848563, 0.3399810435848563, 0.8611363115940526,), | ||
(0.34785484513745385, 0.6521451548625462, 0.6521451548625462, 0.34785484513745385,)], | ||
[(-0.906179845938664, -0.5384693101056831, 0.0, 0.5384693101056831, 0.906179845938664,), | ||
(0.23692688505618908, 0.47862867049936647, 0.5688888888888889, 0.47862867049936647, 0.23692688505618908,)], | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.