XLiFE++ website is now hosted here with up-to-date content. The current website, with potentially deprecated content, will be removed soon.
Example 11/18 - Eigenvalues and eigenvectors of Laplace operator
This example shows how to get eigen functions of Laplace operator equipped with homogeneous Neumann condition:and its variational formulation in :
#include "xlife++.h"
using namespace xlifepp;
int main(int argc, char** argv)
{
init(argc, argv, _lang=en); // mandatory initialization of xlifepp
// mesh square
SquareGeo sq(_origin=Point(0., 0.), _length=1, _nnodes=20);
Mesh mesh2d(sq, triangle, 1, gmsh);
Domain omega = mesh2d.domain("Omega");
// build P2 interpolation
Space Vk(_domain=omega, _interpolation=P2, _name="Vk");
Unknown u(Vk, "u");
TestFunction v(u, "v");
// build eigen system
BilinearForm auv = intg(omega, grad(u) | grad(v)) + intg(omega, u * v) ,
muv = intg(omega, u * v);
TermMatrix A(auv, "auv"), M(muv, "muv");
// compute the 10 first smallest in magnitude
EigenElements eigs = eigenInternSolve(A, M, _nev=10, _mode=krylovSchur, _which="SM"); // internal solver
theCout << eigs.values;
saveToFile("eigs", eigs.vectors, vtu);
return 0;
}