Numerical solving of Laplace equation

May 13, 2015 at 11:26 AM

I'm trying to solve a simple Laplase equation for my university study. I've created a tool for setting geometry and added an import in *.poly format. Then I've used Triangle.NET for calculating a mesh. It looks like this so far:





Now I need to set boundary conditions. Simply I should be able to select all points on the some geometry edge and calculate boundary equation in it. So there is the question - how to select all points that belongs to the one particular edge?
May 13, 2015 at 2:19 PM
Edited May 13, 2015 at 2:23 PM
First, you should use boundary markers in your input geometry (at least if you have to apply multiple boundary conditions). Any segment of the mesh has a Boundary property, so you can easily identify different boundary parts.

To access the boundary information you have two choices:
  1. Segment based:
    You can use the mesh.Segments property and loop over all the segments. You can use the GetVertex(i) method to get the segment endpoints and GetTriangle(i) to get the triangle(s) the segment belongs to.
  2. Triangle based (preferred)
    Since you usually assemble the system matrix by looping over the elements (mesh.Triangles property), you can call GetSegment(i) [i=0,1,2] for each triangle. If it returns null, the triangle side is not on the boundary. If it is, it returns a segment and you can look at its boundary marker to find the boundary condition you want to apply. Then use GetVertex(i) to get the vertices and do the actual integration.
You can use the vertex.ID property for indexing your matrix entries. If don't use any custom numbering, you can call mesh.Renumber(), which will ensure that vertex ids are numbered linearly from 0 to N-1 (assuming the final mesh has N vertices).
May 14, 2015 at 8:42 AM
Thanks a lot. I'll try do that and report.
May 26, 2015 at 2:38 PM
Hi, I've managed the boundary markers. Now I can determine multiple boundary conditions for my region.
Is there any neat .Net library for solving Laplace equation numerically? I have an old Fortran library (which I'm going to use), but I want to maintain the .Net lib to my project.
May 27, 2015 at 4:11 PM
If you want to solve the Laplace equation using the Finite Element method, there are 4 steps:

1) Discretize the domain (done by Triangle.NET)
2) Assemble the system matrix
3) Solve the linear system (use some math library like MathNet or CSparse.NET)
4) Check the solution, visualize the results (you can use Triangle.NETs RenderManager for basic visualization)

So the only thing you need to do, is to code the assembling routine. It's a great learning experience, so I suggest you have a go.

Here's a screenshot from a test app I wrote a while ago. It solves the laplace equation for a simple potential problem:

-laplace(u)=0, u=0 on the outer boundary, u=-1 and u=1 on the slits

It's less than 200 lines of code.

May 28, 2015 at 2:34 PM
Edited May 28, 2015 at 2:34 PM
Thank you! Can you please give an advise how to assemble the system matrix?
May 29, 2015 at 12:30 PM
So, is your university study about learning to solve PDEs numerically, or do you just need some tool to get the job done. If it's the latter, why did you choose C#/.NET? You could use some software package like Matlab.