numerics 0.1.0
Loading...
Searching...
No Matches
poisson.hpp
Go to the documentation of this file.
1/// @file pde/poisson.hpp
2/// @brief 2D Poisson equation solved via the Discrete Sine Transform.
3///
4/// Solves the homogeneous Dirichlet problem
5/// \f[
6/// -\Delta u(x,y) = f(x,y), \qquad (x,y) \in (0,1)^2,
7/// \qquad u|_{\partial\Omega}=0 .
8/// \f]
9///
10/// On an \f$N \times N\f$ interior grid with \f$h = 1/(N+1)\f$, the finite
11/// difference variant diagonalizes
12/// \f[
13/// L_{2D} = L_{1D} \otimes I + I \otimes L_{1D}
14/// \f]
15/// with the DST-I basis
16/// \f[
17/// \phi_k(j) = \sin\!\left(\frac{j k \pi}{N+1}\right).
18/// \f]
19/// The transformed solve is
20/// \f[
21/// \hat{u}_{pq}
22/// = \frac{h^2 \hat{f}_{pq}}
23/// {2(1-\cos(p\pi/(N+1))) + 2(1-\cos(q\pi/(N+1)))} .
24/// \f]
25#pragma once
26
27#include "core/matrix.hpp"
28
29namespace num {
30namespace pde {
31
32/// Solve \f$-\Delta u=f\f$ using finite-difference eigenvalues.
33[[nodiscard]] Matrix poisson2d_fd(const Matrix& f, int N);
34
35/// Solve \f$-\Delta u=f\f$ using continuous eigenvalues \f$(k\pi)^2\f$.
36[[nodiscard]] Matrix poisson2d(const Matrix& f, int N);
37
38} // namespace pde
39} // namespace num
Dense row-major matrix templated over scalar type T.
Matrix poisson2d(const Matrix &f, int N)
Solve using continuous eigenvalues .
Definition poisson.cpp:141
Matrix poisson2d_fd(const Matrix &f, int N)
Solve using finite-difference eigenvalues.
Definition poisson.cpp:109
BasicMatrix< real > Matrix
Double-precision dense matrix with full backend dispatch (CPU + GPU).
Definition matrix.hpp:127