Closed BoundaryValueProblems closed 6 years ago
Ah, it was because you were using concatenation (which combines vector-valued functions) when you really want
u=\([B;Δ+k2*I],[f,0.0];tolerance=1E-12)
@dlfivefifty: Thanks a lot! It works now. But could you explain to me the difference of this [f,0.0]
for this Neumann problem as I posed earlier and the Dirichlet problem in README.md
that uses [f;0.0]
? Why does the concatenation ;
work for the latter case? Is this because f
in the latter is not a function but simply a vector? Thanks!
Yes that’s right: there’s an inconsistency with Dirichlet and Neumann conditions. Direchlet are treating as scalar valued functions defined on the boundary. Neumann conditions are (due to older code) treated as vector-valued functions.
@dlfivefifty: Thanks for your clarification. Then, I have another question for specifying the boundary condition. In this case, the Dirichlet boundary condition. Consider the following codes:
Ω=Interval()^2 #The domain is the square [-1,1]^2.
Δ=Laplacian(Ω) #This defines the Laplace operator on Ω.
Bd=Dirichlet(Ω) #This defines the Dirichlet boundary operator on Ω.
g=Fun((x,y)->sin(5π*x-7π*y),Ω) #A trial 2D sinusoid
f=Fun((x,y)->g(x,y),∂(Ω)) #This computes the Dirichlet boundary condition from g.
f2=Bd*g # This should compute the same Dirichlet boundary condition from g.
k2=(5π)^2+(7π)^2-0.001 #Slightly perturbed k^2
u=\([Bd;Δ+k2*I],[f;0.0];tolerance=1E-12) #The solution!
u2=\([Bd;Δ+k2*I],[f2;0.0];tolerance=1E-12) #The solution too!
Then, let's check the relative L^2 error:
julia> norm(u-u2)/norm(u)
1.928042887351262e-12
Of course, I really shouldn't complain since these solutions have error tolerance of 1E-12
as I specified in solving them. Yet, I want to know what's the real difference between:
f=Fun((x,y)->g(x,y),∂(Ω)) #This computes the Dirichlet boundary condition from g.
f2=Bd*g # This should compute the same Dirichlet boundary condition from g.
Is this difference between function evaluation vs matrix multiplication? Thanks a lot!
That’s right: Bd*g
creates a (sparse) matrix to multiply the coefficients while the other version uses transforms
Thanks a lot, @dlfivefifty!
The following code segment worked sometime ago, but now with the current version of ApproxFun with Julia v1.0.1, I got the
DimensionMismatch
error as follows. Something must have been changed.