# Finite Element Method: 2-D Poisson's Equation in Matlab, Gaussian quadrature

I'm having trouble understanding how to code 2-D Poisson's Equation with Dirichlet boundary conditions. What I have thus far is

1. Constructed square mesh with triangular elements
2. Assembled stiffness matrix. The function for this also gives the area of each element (all same, since square).
3. Use Gaussian Quadrature to construct the right hand side.

edit: I may have been a little vague in my question. Hopefully this is a better rephrasing: Separate from FE, my code for gaussian quadrature works just fine. However, I don't understand how gaussian quadrature can even be relevant/involved with obtaining a solution to 2D Poisson; hence, I don't know how to continue coding.

• It would be helpful to have more information on what you have tried and what exactly you can't make work. – Wolfgang Bangerth Feb 19 '13 at 5:04
• @WolfgangBangerth Well, my question isn't so much coding. I'm not sure how Gaussian quadrature is involved, i.e. how or even why it plays a role. – TheRealFakeNews Feb 19 '13 at 5:08
• This is a different question but may be helpful (also on Dirichlet conditions): scicomp.stackexchange.com/questions/5072/… – Nathan Collier Feb 19 '13 at 10:29
• Well, what I'm saying is that I simply don't understand your question. You say you have Gaussian quadrature working but that you don't know how to "implement that into 2D Poisson". Would it be correct to say that you know how Gaussian quadrature works but you simply don't know how quadrature is relevant to the solution of PDEs with the finite element method? – Wolfgang Bangerth Feb 20 '13 at 0:12
• @WolfgangBangerth Ah. I apologize. I wasn't sure how to phrase the question accurately to begin with. So, separate from FE, my code for Gaussian quadrature works. However, in regards to 2D Poisson, as you put, I'm not sure how it is relevant to the solution of 2D Poisson. I hope that clarifies my issues. – TheRealFakeNews Feb 20 '13 at 2:18

In the finite element method, you need to compute matrix entries (here in the case of the Laplace equation) $$A_{ij} = \sum_K \int_K \nabla\varphi_i \cdot \nabla \varphi_j$$ and right hand side entries $$F_{i} = \sum_K \int_K \varphi_i(x) f(x)$$ where $K$ are the cells of the mesh. The former can sometimes be computed analytically, but depending on the form of $f(x)$ in the latter, you may not be able to do that. If you can't analytically compute an integral, you use quadrature.