Files
JuliaFEM.jl/src/integrate.jl
T

216 lines
7.1 KiB
Julia
Raw Normal View History

2015-10-27 06:37:58 +02:00
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
2016-05-22 02:34:38 +03:00
# Let's drop here all integration schemes and some defaults for different element types maybe parse from txt file ..?
### Gauss quadrature rules for one dimension
function get_integration_points(::Type{Val{1}})
return [2.0], [0.0]
end
function get_integration_points(::Type{Val{2}})
return [1.0, 1.0], sqrt(1.0/3.0)*[-1.0, 1.0]
end
function get_integration_points(::Type{Val{3}})
return 1.0/9.0*[5.0, 8.0, 5.0], sqrt(3.0/5.0)*[-1.0, 0.0, 1.0]
end
function get_integration_points(::Type{Val{4}})
weights = 1.0/36.0*[
18.0+sqrt(30.0),
18.0+sqrt(30.0),
18.0-sqrt(30.0),
18.0-sqrt(30.0)]
points = [
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 weights, points
end
function get_integration_points(::Type{Val{5}})
weights = [
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))]
points = [
-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 weights, points
end
### "cartesian" elements, integration rules comes from tensor product
2015-11-05 10:20:00 +02:00
2015-11-28 14:06:12 +02:00
### 1d elements
2015-11-18 01:19:04 +02:00
2016-05-25 22:33:47 +03:00
typealias CartesianLineElement Union{Seg2, Seg3}
typealias CartesianSurfaceElement Union{Quad4}
typealias CartesianVolumeElement Union{Hex8}
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianLineElement, ::Type{Val{1}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{1})
[ (w[i], [xi[i]]) for i=1:1 ]
2015-10-27 06:37:58 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianLineElement, ::Type{Val{2}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{2})
[ (w[i], [xi[i]]) for i=1:2 ]
2015-11-18 01:19:04 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianLineElement, ::Type{Val{3}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{3})
[ (w[i], [xi[i]]) for i=1:3 ]
2015-11-11 00:52:16 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianSurfaceElement, ::Type{Val{1}})
w, xi = get_integration_points(Val{1})
[ (w[i]*w[j], [xi[i], xi[j]]) for i=1:1, j=1:1 ]
2015-11-18 01:19:04 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianSurfaceElement, ::Type{Val{2}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{2})
[ (w[i]*w[j], [xi[i], xi[j]]) for i=1:2, j=1:2 ]
2015-11-11 00:52:16 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianSurfaceElement, ::Type{Val{3}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{3})
[ (w[i]*w[j], [xi[i], xi[j]]) for i=1:3, j=1:3 ]
2015-11-18 01:19:04 +02:00
end
2015-11-11 00:52:16 +02:00
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianVolumeElement, ::Type{Val{1}})
w, xi = get_integration_points(Val{1})
[ (w[i]*w[j]*w[k], [xi[i], xi[j], xi[k]]) for i=1:1, j=1:1, k=1:1 ]
end
function get_integration_points(element::CartesianVolumeElement, ::Type{Val{2}})
2016-05-22 02:34:38 +03:00
w, xi = get_integration_points(Val{2})
[ (w[i]*w[j]*w[k], [xi[i], xi[j], xi[k]]) for i=1:2, j=1:2, k=1:2 ]
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::CartesianVolumeElement, ::Type{Val{3}})
w, xi = get_integration_points(Val{3})
[ (w[i]*w[j]*w[k], [xi[i], xi[j], xi[k]]) for i=1:3, j=1:3, k=1:3 ]
2016-05-22 02:34:38 +03:00
end
2016-05-22 17:00:01 +03:00
2016-05-22 02:34:38 +03:00
### triangular and tetrahedral elements
2015-11-25 10:08:24 +02:00
2015-12-10 17:40:10 +02:00
# http://math2.uncc.edu/~shaodeng/TEACHING/math5172/Lectures/Lect_15.PDF
2016-05-24 08:29:24 +03:00
# http://libmesh.github.io/doxygen/quadrature__gauss__2D_8C_source.html
2015-12-10 17:40:10 +02:00
2016-05-25 22:33:47 +03:00
typealias TriangularElement Union{Tri3, Tri6}
2015-12-10 17:40:10 +02:00
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TriangularElement, ::Type{Val{1}})
2016-05-22 02:34:38 +03:00
weights = [0.5]
points = Vector{Float64}[1.0/3.0*[1.0, 1.0]]
2016-05-24 08:29:24 +03:00
return zip(weights, points)
2015-11-28 14:06:12 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TriangularElement, ::Type{Val{2}})
2016-05-22 02:34:38 +03:00
weights = 1.0/6.0*[1.0, 1.0, 1.0]
points = Vector{Float64}[
[2.0/3.0, 1.0/6.0],
[1.0/6.0, 2.0/3.0],
[1.0/6.0, 1.0/6.0]]
2016-05-24 08:29:24 +03:00
return zip(weights, points)
2015-11-28 14:06:12 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TriangularElement, ::Type{Val{3}})
weights = 0.5*[-0.5625, 0.5208333333333333, 0.5208333333333333, 0.5208333333333333]
points = Vector{Float64}[
[1.0/3.0, 1.0/3.0],
[0.2, 0.2],
[0.2, 0.6],
[0.6, 0.2]]
return zip(weights, points)
2016-02-26 18:18:00 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TriangularElement, ::Type{Val{4}})
2015-12-17 15:33:51 +02:00
[
IntegrationPoint([0.44594849091597, 0.44594849091597], 0.5*0.22338158967801),
IntegrationPoint([0.44594849091597, 0.10810301816807], 0.5*0.22338158967801),
IntegrationPoint([0.10810301816807, 0.44594849091597], 0.5*0.22338158967801),
IntegrationPoint([0.09157621350977, 0.09157621350977], 0.5*0.10995174365532),
IntegrationPoint([0.09157621350977, 0.81684757298046], 0.5*0.10995174365532),
IntegrationPoint([0.81684757298046, 0.09157621350977], 0.5*0.10995174365532)
]
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TriangularElement, ::Type{Val{5}})
2015-12-10 17:40:10 +02:00
[
IntegrationPoint([0.33333333333333, 0.33333333333333], 0.5*0.22500000000000),
IntegrationPoint([0.47014206410511, 0.47014206410511], 0.5*0.13239415278851),
IntegrationPoint([0.47014206410511, 0.05971587178977], 0.5*0.13239415278851),
IntegrationPoint([0.05971587178977, 0.47014206410511], 0.5*0.13239415278851),
IntegrationPoint([0.10128650732346, 0.10128650732346], 0.5*0.12593918054483),
IntegrationPoint([0.10128650732346, 0.79742698535309], 0.5*0.12593918054483),
IntegrationPoint([0.79742698535309, 0.10128650732346], 0.5*0.12593918054483)
2015-12-10 17:40:10 +02:00
]
end
2016-05-24 08:29:24 +03:00
### 3d elements
2016-05-25 22:33:47 +03:00
typealias TetrahedralElement Union{Tet4, Tet10}
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TetrahedralElement, ::Type{Val{1}})
weights = 1.0/6.0*[1.0]
points = Vector{Float64}[
1.0/4.0*[1.0, 1.0, 1.0]]
return zip(weights, points)
2015-12-10 17:40:10 +02:00
end
2016-05-24 08:29:24 +03:00
function get_integration_points(element::TetrahedralElement, ::Type{Val{2}})
a = (5.0+3.0*sqrt(5.0))/20.0
b = (5.0-sqrt(5.0))/20.0
w = 1.0/24.0
weights = [w, w, w, w]
points = Vector{Float64}[
[a, b, b],
[b, a, b],
[b, b, a],
[b, b, b]]
return zip(weights, points)
end
function get_integration_points(element::TetrahedralElement, ::Type{Val{3}})
a = 1.0/4.0
b = 1.0/6.0
c = 1.0/2.0
weights = [-2.0/15.0, 3.0/40.0, 3.0/40.0, 3.0/40.0, 3.0/40.0]
points = Vector{Float64}[
[a, a, a],
[b, b, b],
[b, b, c],
[b, c, b],
[c, b, b]]
return zip(weights, points)
end
2015-11-28 14:06:12 +02:00
2016-05-24 08:29:24 +03:00
### default number of integration points for each element
### 2 for linear elements, 3 for quadratic
2016-05-25 22:33:47 +03:00
typealias LinearElement Union{Seg2, Tri3, Quad4, Tet4, Hex8}
2016-05-24 08:29:24 +03:00
2016-05-25 22:33:47 +03:00
typealias QuadraticElement Union{Seg3, Tri6, Tet10}
2016-05-24 08:29:24 +03:00
2016-05-25 22:33:47 +03:00
function get_integration_order(element::LinearElement)
return 2
end
function get_integration_order(element::QuadraticElement)
return 3
end
function get_integration_points(element::LinearElement)
order = get_integration_order(element)
2016-05-24 08:29:24 +03:00
get_integration_points(element, Val{order})
2015-11-28 14:06:12 +02:00
end
2016-05-25 22:33:47 +03:00
function get_integration_points(element::QuadraticElement)
order= get_integration_order(element)
2016-05-24 08:29:24 +03:00
get_integration_points(element, Val{order})
2015-11-25 10:08:24 +02:00
end
2016-05-24 08:29:24 +03:00