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.

  • $\begingroup$ It would be helpful to have more information on what you have tried and what exactly you can't make work. $\endgroup$ Feb 19, 2013 at 5:04
  • $\begingroup$ @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. $\endgroup$ Feb 19, 2013 at 5:08
  • $\begingroup$ This is a different question but may be helpful (also on Dirichlet conditions): scicomp.stackexchange.com/questions/5072/… $\endgroup$ Feb 19, 2013 at 10:29
  • 1
    $\begingroup$ 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? $\endgroup$ Feb 20, 2013 at 0:12
  • $\begingroup$ @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. $\endgroup$ Feb 20, 2013 at 2:18

1 Answer 1


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.

I don't know if it's a shameless plug, but I've actually recorded a video lecture on this topic -- see lecture 4 here: http://www.math.tamu.edu/~bangerth/videos.html


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.