Loading

   

Heat Transfer Demo 4: An eigenvalue problem

Here is a simple example to calculate eigenvalues and eigenvectors of an elliptic problem. We compute some eigenvalues of the Laplace operator using the Bathe subspace iteration method..

  • As usual, we construct an instance of class IPF to manage project data. We extract useful information from this instance: namely, the mesh file name and the number of eigenvalues to extract. Next, we construct the mesh and remove essential boundary conditions from the unknowns: This is essential for solving the eigenvalue problem.

       IPF data(argv[1]);
       int nb = data.getInteger("nb");
       Mesh ms(data.getMeshFile());
       ms.removeImposedDOF();
    

  • After outputting some information about the code, we declare an instance of class Mesh and remove imposed boundary conditions: In fact, in view of using an iterative procedure to solve the linear system. Penalty techniques are not efficient in this case.

       Laplace2DT3 eq(ms);
       eq.solveEigenProblem(nb);
    

  • In order to read various prescriptions (boundary conditions, heat sources, fluxes), we use the class Prescription. The name of the file containing these prescriptions is given in data.getDataFile()

       cout << "Nb. of iterations: " << eq.getEigenSolver().getNbIter() << endl;
       Vect v;
       for (int i=1; i<=nb; i++) {
          cout << "Eigenvalue #" << i << ": " << eq.getEigenValue(i) << endl;
          eq.getEigenVector(i,v);
          IOField ff(data.getMeshFile(),data.getPlotFile(i),ms,IOField::OUT);
          ff.put(v);
       }
    
      

    An example

    Let us run this program with the data presented in the following project file:

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <OFELI_File>
    <info>
        <title></title>
        <date></date>
        <author></author>
    </info>
    <Project name="eigen">
       <mesh_file value="square-20.m" />
       <parameter label="nb" value="2" />
       <plot_file value="test.ev1" />
       <plot_file value="test.ev2" />
    </Project>
    </OFELI_File>

    In summary, this file looks mainly like the one in the previous example.

     
    Copyright © 1998-2014 Rachid Touzani