This tutorial shows how to solve the Helmholtz eigen problem with a finite-element approach using Bcube.
We consider the following Helmholtz equation, representing for instance the acoustic wave propagation with Neuman boundary condition(s):
\[\begin{cases}
\Delta u + \omega^2 u = 0 \\
\dfrac{\partial u}{\partial n} = 0 \textrm{ on } \Gamma
\end{cases}\]
An analytic solution of this equation can be obtained: for a rectangular domain $\Omega = [0,L_x] \times [0,L_y]$,
\[u(x,y) = \cos \left( \frac{k_x \pi}{L_x} x \right) \cos \left( \frac{k_y \pi}{L_y} y \right) \mathrm{~~with~~} k_x,~k_y \in \mathbb{N}\]
with $\omega^2 = \pi^2 \left( \dfrac{k_x^2}{L_x^2} + \dfrac{k_y^2}{L_y^2} \right)$
Now, both the finite-element method and the discontinuous Galerkin method requires to write the weak form of the problem:
\[\int_\Omega (\Delta u \Delta v + \omega^2u)v \mathrm{\,d}\Omega = 0\]
\[- \int_\Omega \nabla u \cdot \nabla v \mathrm{\,d}\Omega
@@ -43,4 +43,4 @@
end
To write a VTK file, we need to build a dictionnary linking the variable name with its values and type
using WriteVTK
out_dir = joinpath(@__DIR__, "../myout") # output directory
dict_vars = Dict("u_$i" => (values[:, i], VTKPointData()) for i in 1:nvecs)
-write_vtk(joinpath(out_dir, "helmholtz_rectangle_mesh"), 0, 0.0, mesh, dict_vars)
And here is the eigenvector corresponding to the 4th eigenvalue:
This page was generated using Literate.jl.