Home > Exercises Chapter 2 > Troubleshooting

Troubleshooting


         
On this page a number of points of attention will be given which might help when something is not going the way you want it to go. These points will be split into two categories. First a number of points concerning programming will be given and then the more fundamental spectral subjects will be touched.

Programming points of attention

  1. Make sure enough memory is allocated for every variable. How this is done can be seen for example in the dvector function in the code of exercise1a or in the dmatrix function in the code of exercise3a.
  2. Try to enter double precision numbers in decimal notation, sometimes rounding to integers will occur when this is not the case.
  3. Compilation in the way noted in the provided codes only works when polylib.c and polylib.h are in the same directory as your code.
  4. Include the right files, including iostream.h, stdio.h, math.h and polylib.h might help.
  5. To use the polylib library use the line: using namespace polylib;
  6. To use the cout function it might be necessary to use the line: using namespace std;
  7. Using Lapack the right way is explained here.
  8. Don't forget saving before you compile.

Spectral points of attention

  1. Enter the right matrix dimension, this changes with different boundary conditions (when an element has a Dirichlet boundary on one side, the boundary node at this side will be known and the matrix will have size P instead of P+1).
  2. Enter the right boundary conditions. When using for example -(pi^2+lambda)*sin(pi*x) as forcing remember that the Neumann boundary condition at x=0 is bc(0)=pi and not bc(0)=1 (the solution is u=sin(pi*x)).
  3. Take care of the changes in signs when going from the projection problem to the differential equation. You can find the weak form of the differential equation here.
  4. When applying the lifting of the solution of the differential equation, don't forget the extra factor of lambda and also don't forget the extra term due to the Laplacian.
  5. When constructing the global solution and thus summing the contributions of the different polynomials remember that at the element boundaries (except for the first and last element) the solution at this boundary is given by both elements, so don't sum them.
  6. Implementing Dirichlet boundary conditions changes the size of the element mass matrix whereas implementing Neumann boundary conditions doesn't.