Skip to content
Snippets Groups Projects
eigenSolver.h 2.12 KiB
Newer Older
Christophe Geuzaine's avatar
Christophe Geuzaine committed
// Gmsh - Copyright (C) 1997-2012 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.

Christophe Geuzaine's avatar
pp  
Christophe Geuzaine committed
#ifndef _EIGEN_SOLVER_H_
#define _EIGEN_SOLVER_H_
#include <string>
#include <complex>
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "dofManager.h"

#if defined(HAVE_SLEPC)

#include "linearSystemPETSc.h"
Christophe Geuzaine's avatar
Christophe Geuzaine committed
class eigenSolver{
  linearSystemPETSc<double> *_A, *_B;
  bool _hermitian;
  std::vector<std::complex<double> > _eigenValues;
  std::vector<std::vector<std::complex<double> > > _eigenVectors;
  void _try(int ierr) const { CHKERRABORT(PETSC_COMM_WORLD, ierr); }
 public:
  eigenSolver(dofManager<double> *manager, std::string A,
              std::string B="", bool hermitian=true);
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  eigenSolver(linearSystemPETSc<double> *A, linearSystemPETSc<double>* B = NULL,
              bool hermitian=true);
  bool solve(int numEigenValues=0, std::string which="");
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  int getNumEigenValues(){ return _eigenValues.size(); }
  std::complex<double> getEigenValue(int num){ return _eigenValues[num]; }
  std::vector<std::complex<double> > &getEigenVector(int num){ return _eigenVectors[num]; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  void clear()
  {
    _eigenValues.clear();
    _eigenVectors.clear();
  };
  std::complex<double> getEigenVectorComp(int num, int com)
  {
    return _eigenVectors[num][com];
  };
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Gauthier Becker's avatar
Gauthier Becker committed
#include "linearSystemPETSc.h"
Christophe Geuzaine's avatar
Christophe Geuzaine committed

Christophe Geuzaine's avatar
Christophe Geuzaine committed
class eigenSolver{
 private:
  std::vector<std::complex<double> > _dummy;
 public:
  eigenSolver(dofManager<double> *manager, std::string A,
              std::string B="", bool hermitian=false){}
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  eigenSolver(linearSystemPETSc<double> *A,linearSystemPETSc<double>* B = NULL,
              bool hermitian=false){}
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  bool solve(int numEigenValues=0, std::string which="")
  {
    Msg::Error("Eigen solver requires SLEPc");
Christophe Geuzaine's avatar
Christophe Geuzaine committed
    return false;
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  int getNumEigenValues(){ return 0; }
  std::complex<double> getEigenValue(int num){ return 0.; }
  std::vector<std::complex<double> > &getEigenVector(int num){ return _dummy; }
Christophe Geuzaine's avatar
Christophe Geuzaine committed
  void clear(){}
  std::complex<double> getEigenVectorComp(int num, int com) { return 0.; }