spectralDNS / shenfun

High performance computational platform in Python for the spectral Galerkin method

Home Page:http://shenfun.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Role of BCBasis and BoundaryValues

sebglane opened this issue · comments

I would like to implement inhomogeneous mixed Dirichlet-Neumann BCs. Homogeneous mixed BCs are already available for example by using the class DirichletNeumannBasis. There are two types of classes which seem to handle the inhomogeneous Dirichlet BCs in shenfun: BCBasis and BoundaryValues. My question is whether both classes require a modification or if it is sufficient to modify BCBasis only.

Furthermore, it is not clear if both classes only work for the Dirichlet BCs or also for the mixed cases. All of the ansatz spaces are constructed such that the functions \phi_{N-2} and \phi_{N-1} fulfill the inhomogeneous BCs. All other functions fulfill homogeneous BCs. Thus, for u(x=-1)=a and u(x=1)=b, the coefficients are given by c_{N-2}=a and c_{N-1}=b. This relation regarding the coefficients also applies for the mixed BCs. Therefore, it seems to me that it is sufficient to modify BoundaryValues only.

I would be great if someone could clarify what is the purpose of the different classes such that I can try extend them for the mixed cases.

Briefly, there are two classes now that can handle non-homogeneous boundary conditions. The regular Dirichlet, which is using BCBasis Legendre and BCBasis Chebyshev, and the Biharmonic bases using BCBiharmonic Chebyshev and BCBiharmonic Legendre. So for each function space with nonzero boundary conditions there is a new tailored class, subclassed from [SpectralBase]. The Dirichlet boundary conditions adds two new basis functions, whereas the biharmonic adds four. The additional basis functions contribute to forward and backward transforms, as well as when solving equations. The contributions are computed with the BoundaryValues class. See, e.g., forward with self.bc.add_mass_rhs(u).

Note that for a new class it should be sufficient to add a new class like BCBasis, with the basis functions needed to get the desired boundary conditions.

Setting boundary conditions is trivial for 1D problems, but much more involved for higher dimensional problems. To understand that I think it can be useful to look at the Rayleigh-Bénard demo.

I have not looked into non-homogeneous Neumann boundary conditions yet, but they can probably be implemented in a similar fashion as the Dirichlet/Biharmonic by adding a few basis functions with non-homogeneous boundary conditions.