// This codes shows how to calculate the eigenvalue spectrum of // the Laplace operator on a 2d square domain, using SLEPc. // // Usage : // mpirun -np 4 FreeFem++-mpi -wg lplace-complex-2d-SLEPc.edp \ // -split 1 -npts 400 -nev 10 // // Authors: Julien Garaud // Pierre Jolivet /**************************************/ /* Load PETSc & SLEPc macros */ /**************************************/ load "PETSc-complex" // PETSc plugin macro dimension( )2// End Of Macro // 2D or 3D include "macro_ddm.idp" // Additional DDM functions macro def(i)i// EOM macro init(i)i// EOM func Pk = P1; // Finite-element space /***************************************/ /* Options for distributed solver */ /***************************************/ int s = getARGV("-split", 1) ; // Refinement factor // int Npts = getARGV("-npts" , 200) ; // Number of points on the perimeter real Lx = getARGV("-lx" , pi) ; // Dimension of the domain real Ly = getARGV("-ly" , pi) ; // Dimension of the domain // int nEV = getARGV("-nev" , 10) ; // Number of eigenvalues /***************************************/ /* Verbosity and passed options */ /***************************************/ if(verbosity > 0 && mpirank == 0) { cout << "********************************************" << endl << " --- " << mpirank << "/" << mpisize << "- laplace-complex-2d-SLEPc.edp " << endl << "********************************************" << endl << "- input parameters: " << endl << " refinement factor = " << s << endl << "********************************************" << endl << " nb of pts on perimeter = " << Npts << " Domain size [Lx,Ly] = ["< A = vA(Vh,Vh); matrix B = vB(Vh,Vh); /***************************************/ /* Build distributed matrices */ /***************************************/ Mat DistA(A, intersection, D, clean = true); Mat DistB(DistA, B, clean = true); /***************************************/ /* Problem resolution */ /***************************************/ complex[int] EigenVAL(0); // array to store eigenvalues Vh[int] def(EigenVEC)(1); // array to store eigenvectors string ssparams = // Parameters for the distributed EigenValue solver " -eps_nev " + nEV + // Number of eigenvalues " -eps_type krylovschur" + " -st_type sinvert " + " -st_pc_type lu " + " -eps_view" + " -eps_pos_gen_non_hermitian" // The problem is symmetric ; int k = EPSSolve (DistA, // matrix OP = A − sigma*B DistB, // vectors = EigenVEC, // Array to store the FEM-EigenFunctions values = EigenVAL, // Array to store the EigenValues sparams = ssparams // Parameters for the distributed EigenValue solver ); k=min(k,nEV); // some time the number of converged eigen value // can be greater than nev; /***************************************/ /* View the solution */ /***************************************/ Vh Temp; for(int i=0;i