# Poisson solver using BSpline Galerkin method on a 2D grid

**URL:** https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524
**Category:** Numerics
**Tags:** question
**Created:** [March 4, 2025, 12:08pm UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524 "2025-03-04T12:08:57Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Sagar\_123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sagar_123/32/42788_2.png) [@Sagar\_123](https://discourse.julialang.org/u/Sagar_123)
#### Post date: [March 4, 2025, 12:08pm UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/1 "2025-03-04T12:08:57Z")

</div>

Hello! I am trying to implement a poisson solver (in a reduced form) using BSplines and Galerkin method. Form of the equation is :

 ![Screenshot 2025-03-04 at 12.49.59 PM](https://global.discourse-cdn.com/julialang/original/3X/3/b/3b45157388e2e97195c4cc6f6fa2d185452cffee.png)  
where \phi is potential and differential operation is in 2D :  
 ![Screenshot 2025-03-04 at 12.50.51 PM](https://global.discourse-cdn.com/julialang/original/3X/c/d/cd3234644dc8627e51b3799cae1b404f9f08df93.png)  
Now, if I were to expand \phi using BSplines, I’d have  
 ![Screenshot 2025-03-04 at 12.50.09 PM](https://global.discourse-cdn.com/julialang/original/3X/7/2/729cae44ac50f687d4e536a6a2f0cb517b8ebead.png)  
Thereafter, I can the solve the system using a linear system of equations as :  
 ![Screenshot 2025-03-04 at 12.50.34 PM](https://global.discourse-cdn.com/julialang/original/3X/0/5/0534bbb45ce193e39674e0a7d65389bd99c3ace3.png)  
I have non-uniform 2D grid, over which my RHS is defined and where I need to evaluate my potential \phi. Now, I tried looking at BSplineKit and other Julia tools, however I’m not finding much success, BSplinesKit seem to work for 1D splines yet (I don’t know how to make it work for 2D grid if it could be done). May someone suggest how to solve this in Julia with decent performance?

P.S. I have attached a few pictures of the equations, I don’t know if that it is advised not to in the community.

---

<div class="post-metadata">

### Author: ![yolhan\_mannes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yolhan_mannes/32/220485_2.png) [@yolhan\_mannes](https://discourse.julialang.org/u/yolhan_mannes)
#### Post date: [March 5, 2025, 5:37am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/2 "2025-03-05T05:37:30Z")

</div>

If it’s the first Time you implement it you should definitely do it from scratch or just use DifferentialEquation.jl for the time solver then you can have a look on how to improve it, DataInterpolation.jl supports BSpline approximation and integration/derivation of the interpolation but only for R-\> R^n function I think. If you need powerful tools for mesh ect Ferrite.jl may be great I don’t know if BSpline basis are supported though.

---

<div class="post-metadata">

### Author: ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)
#### Post date: [March 5, 2025, 8:26pm UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/3 "2025-03-05T20:26:11Z")

</div>

I think this is a pretty cool subject 🙂

I have some questions which might clarify some things:

- Is your grid curvilinear or more unstructured? As far as I know B-splines are quite Cartesiany
- Where does your decision to use B-splines stem from?
- Have you looked into isogeometric analysis (I think that only has implementations in C++ though)?

I’ve been working on SplineGrids.jl and I thought it’d be cool if that was integrated into FEM/FVM like methods, but you’d have to quite a lot of work to implement everything I think.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [March 6, 2025, 2:23am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/4 "2025-03-06T02:23:19Z")

</div>

I don’t know what all of those things are, but doesn’t this look like Helmholtz?

---

<div class="post-metadata">

### Author: ![KnutAM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knutam/32/37720_2.png) [@KnutAM](https://discourse.julialang.org/u/KnutAM)
#### Post date: [March 6, 2025, 6:17am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/5 "2025-03-06T06:17:14Z")

</div>

> [@yolhan\_mannes](#):
>
> If you need powerful tools for mesh ect [Ferrite.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/Ferrite) may be great I don’t know if BSpline basis are supported though

[IGA.jl](https://github.com/lijas/IGA.jl) builds on top of Ferrite.jl and gives you spline interpolations.

---

<div class="post-metadata">

### Author: ![Sagar\_123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sagar_123/32/42788_2.png) [@Sagar\_123](https://discourse.julialang.org/u/Sagar_123)
#### Post date: [March 6, 2025, 7:45am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/6 "2025-03-06T07:45:17Z")

</div>

1. It’s curvilinear only. Very much like 2D polar coordinates.
2. Using Bsplines is motivated by previous studies, the descritization of the fields takes care fixes the charge assignment process (calculation of delta n\_i in the equation, which is just charge density). Also, the finite support of BSplines make the matrices are quite sparse. Also, I’ll doing cubic interpolations so, BSpline seemed like a natural choice.
3. I did see one paper, where the very similar thing is done, not in Julia of course. [[https://hal.science/hal-00908500v1/document](https://hal.science/hal-00908500v1/document)]. The paper uses BSplines too, I may have to implement something like this from scratch. But, I was hoping that such things may be already available in Julia.

Thanks!

---

<div class="post-metadata">

### Author: ![Sagar\_123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sagar_123/32/42788_2.png) [@Sagar\_123](https://discourse.julialang.org/u/Sagar_123)
#### Post date: [March 6, 2025, 7:48am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/7 "2025-03-06T07:48:02Z")

</div>

Hello. The equation is just poisson’s equation. It’s 2D because the system has symmetry and the coordinate gets decoupled. Capital \lambda is just tensor product of 1D BSplines. So, it’s just a projection of the equation onto BSpline basis and using Galerkin to solve it as a linear system.

---

<div class="post-metadata">

### Author: ![Sagar\_123](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sagar_123/32/42788_2.png) [@Sagar\_123](https://discourse.julialang.org/u/Sagar_123)
#### Post date: [March 6, 2025, 7:49am UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/8 "2025-03-06T07:49:32Z")

</div>

@KnutAM, @yolhan_mannes Thank you, I’ll take a look.

---

<div class="post-metadata">

### Author: ![jcook](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jcook/32/18211_2.png) [@jcook](https://discourse.julialang.org/u/jcook)
#### Post date: [March 6, 2025, 10:00pm UTC](https://discourse.julialang.org/t/poisson-solver-using-bspline-galerkin-method-on-a-2d-grid/126524/10 "2025-03-06T22:00:15Z")

</div>

It would be great to be able to solve these SOL equations in Trixi. Have you tried? Trixi would be great for gridding but it’s primarily for hyperbolic equations. Perhaps Boussinesq approximation would be informative.
