 ## Demonstration of class EigenProblemSolver usage: Solution of the eigenvalue problem for the 2-D Laplace equation

We present a program to compute eigenvalues and eigenvectors of the Laplace equation with homogeneous Dirichlet boundary conditions, discretized by the P1 finite element method.

## The Code

• We start, as usual, by including the main header file of the library, and the header for the Laplace equation. The program has, as argument the name of the project file, from which we deduce the name of the mesh file and the number of sought eigenvalues (variable nb). We also construct a Mesh instance.

 ```#include "OFELI.h" #include "Laplace.h" using namespace OFELI; int main(int argc, char *argv[]) { IPF data(argv); Mesh ms(data.getMeshFile()); int nb = data.getInteger("nb"); ```

• We construct an instance of class Laplace2DT3 using the Mesh instance, and then construct an instance of class EigenProblemSolver by using the Laplace2DT3 instance. Finally, we run the subspace method to extract the eigenvalues.

 ``` Laplace2DT3 eq(ms); EigenProblemSolver e(eq); e.run(nb); ```

• We end by printing the number of performed iterations. Then we print the eigenvalues. The eigenvectors are stored one by one in vtk files. The names of theses files are given in the project file, by using the tag plot_file.

 ``` cout << "Nb. of iterations: " << e.getNbIter() << endl; Vect v(ms); for (int i=1; i<=nb; i++) { cout << "Eigenvalue #" << i << ": " << e.getEigenValue(i) << endl; e.getEigenVector(i,v); saveField(v,ms,data.getPlotFile(i),GMSH); } return 0; } ```

## A Project File

We give here an example of a project file.

 ``` EigenMode Project January 1, 2016 R. Touzani ```