Skip to content

Commit 01968aa

Browse files
committed
Update diskhelmholtz.jl
1 parent 7c5a10a commit 01968aa

File tree

1 file changed

+92
-9
lines changed

1 file changed

+92
-9
lines changed

examples/diskhelmholtz.jl

Lines changed: 92 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,102 @@
1-
using MultivariateOrthogonalPolynomials, FastTransforms, BlockBandedMatrices, Plots
1+
using MultivariateOrthogonalPolynomials, FastTransforms, BlockBandedMatrices, Plots, LinearAlgebra, StaticArrays
22
plotly()
33

4+
5+
####
6+
# Solving
7+
#
8+
# (Δ + k^2*I) * u = f
9+
#
10+
# in a unit disk |𝐱| ≤ 1,
11+
# using orthogonal polynomials (in x and y) in a disk
12+
# with the weight (1-|𝐱|^2) = (1-x^2-y^2)
13+
####
14+
415
Z = Zernike(1)
5-
W = Weighted(Z)
6-
xy = axes(Z,1); x,y = first.(xy),last.(xy)
16+
W = Weighted(Z) # w*Z
17+
xy = axes(Z, 1);
18+
x, y = first.(xy), last.(xy);
719
Δ = Z \ (Laplacian(xy) * W)
8-
S = Z \ W
20+
S = Z \ W # identity
21+
22+
23+
f = @.(cos(x * exp(y)))
24+
25+
f[SVector(0.1, 0.2)]
26+
g = ((1 .- x .^ 2 .- y .^ 2) .* f)
27+
@time W \ g
28+
29+
Z \ g
30+
N = 100
31+
S[Block.(1:N), Block.(1:N)] * (W\g)[Block.(1:N)]
32+
933

10-
k = 2
11-
f = @.(cos(x*exp(y)))
12-
F = factorize+ k^2 * S)
34+
# F = factorize(Δ + k^2 * S)
35+
# c = Z \ f
36+
# F \ c
37+
38+
# u = W * ((Δ + k^2 * S) \ (Z \ f))
39+
40+
41+
N = 20
42+
k = 20
43+
f = @.(cos(x * exp(y)))
1344
c = Z \ f
14-
F \ c
45+
𝐮 =+k^2*S)[Block.(1:N), Block.(1:N)] \ c[Block.(1:N)]
46+
u = W[:, Block.(1:N)] * 𝐮
47+
axes(u)
48+
49+
50+
= Z / Z \ u
51+
52+
= Z / Z \ u
53+
54+
= (Z / Z) \ u
55+
= inv(Z * inv(Z)) * u
56+
= Z * (inv(Z) * u)
57+
= Z * (Z \ u)
58+
# Z \ u means Find c s.t. Z*c == u
59+
60+
sum(ũ .* f)
61+
62+
W \ f
63+
64+
65+
sum(u .^ 2 * W \ f)
66+
norm(u)
67+
68+
surface(u)
69+
70+
# Δ*u == λ*u
71+
# Z\Δ*W*𝐮 == λ*Z\W*𝐮
72+
# Δ*𝐮 == λ*S*𝐮
73+
Matrix(Δ[Block.(1:N), Block.(1:N)])
74+
eigvals(Matrix(Δ[Block.(1:N), Block.(1:N)]), Matrix(S[Block.(1:N), Block.(1:N)]))
75+
76+
Z \ (x .* Z)
77+
78+
79+
80+
# u = (1-x^2) * P^(1,1) * 𝐮 = W * 𝐮
81+
# v = (1-x^2) * P^(1,1) * 𝐯 = W * 𝐯
82+
# -<D*v,D*u>
83+
# -(D*v)'(D*u) == -𝐯'*(D*W)'D*W*𝐮
84+
# <v,u> == 𝐯'*W'W*𝐮
85+
86+
= Jacobi(1, 1)
87+
W = Weighted(P¹)
88+
x = axes(W, 1)
89+
D = Derivative(x)
90+
-(D * W)' * (D * W)
91+
W'W
1592

16-
u = W * ((Δ + k^2 * S) \ (Z \ f))
93+
# p-FEM
1794

95+
P = Legendre()
96+
u = P * [randn(5); zeros(∞)]
97+
u' * u
1898

99+
T[0.1, 1:10]
100+
T'[1:10, 0.1]
101+
axes(T')
19102

0 commit comments

Comments
 (0)