Skip to content
Snippets Groups Projects
Select Git revision
  • b86c7d390eda04e381a6092a3a7fb4f171598631
  • master default
  • gl2ps_1_4_0
  • gl2ps_1_3_9
  • gl2ps_1_3_8
  • gl2ps_1_3_7
  • gl2ps_1_3_6
  • gl2ps_1_3_5
  • gl2ps_1_3_4
  • gl2ps_1_3_3
  • gl2ps_1_3_2
  • gl2ps_1_3_1
  • gl2ps_1_3_0
  • gl2ps_1_2_7
  • gl2ps_1_2_6
  • gl2ps_1_2_5
  • gl2ps_1_2_4
  • gl2ps_1_2_3
  • gl2ps_1_2_2
  • gl2ps_1_2_1
  • gl2ps_1_2_0
  • gl2ps_1_1_2
22 results

gl2psTest.c

Blame
  • Forked from gl2ps / gl2ps
    Source project has a limited visibility.
    eigenSolver.h 2.49 KiB
    // Gmsh - Copyright (C) 1997-2019 C. Geuzaine, J.-F. Remacle
    //
    // See the LICENSE.txt file for license information. Please report all
    // issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
    
    #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"
    
    class eigenSolver {
    private:
      linearSystemPETSc<double> *_sysA, *_sysB;
      bool _hermitian;
      std::vector<std::complex<double> > _eigenValues;
      std::vector<std::vector<std::complex<double> > > _eigenVectors;
      void _check(int ierr) const;
    
    public:
      eigenSolver(dofManager<double> *manager, std::string A, std::string B = "",
                  bool hermitian = true);
      eigenSolver(linearSystemPETSc<double> *A, linearSystemPETSc<double> *B = NULL,
                  bool hermitian = true);
      bool solve(int numEigenValues = 0, std::string which = "",
                 std::string method = "krylovschur", double tolVal = 1.e-7,
                 int iterMax = 20);
    
      int getNumEigenValues() { return _eigenValues.size(); }
      int getNumberEigenvectors() { return _eigenVectors.size(); }
    
      std::complex<double> getEigenValue(int num) { return _eigenValues[num]; }
      std::complex<double> getEigenVectorComp(int num, int com)
      {
        return _eigenVectors[num][com];
      };
      std::vector<std::complex<double> > &getEigenVector(int num)
      {
        return _eigenVectors[num];
      }
    
      void normalize_mode(std::vector<int> modeView, double scale = 1.);
    
      void clear()
      {
        _eigenValues.clear();
        _eigenVectors.clear();
      };
    };
    
    #else
    
    #include "linearSystemPETSc.h"
    
    class eigenSolver {
    private:
      std::vector<std::complex<double> > _dummy;
    
    public:
      eigenSolver(dofManager<double> *manager, std::string A, std::string B = "",
                  bool hermitian = false)
      {
      }
      eigenSolver(linearSystemPETSc<double> *A, linearSystemPETSc<double> *B = NULL,
                  bool hermitian = false)
      {
      }
      bool solve(int = 0, std::string = "", std::string = "", double = 0, int = 0)
      {
        Msg::Error("Eigen solver requires SLEPc");
        return false;
      }
      int getNumEigenValues() { return 0; }
      int getNumberEigenvectors() { return 0; }
      std::complex<double> getEigenValue(int num) { return 0.; }
      std::complex<double> getEigenVectorComp(int num, int com) { return 0.; }
      std::vector<std::complex<double> > &getEigenVector(int num) { return _dummy; }
      void normalize_mode(std::vector<int> modeView, double scale = 1.) {}
      void clear() {}
    };
    
    #endif
    
    #endif