diff --git a/Solver/eigenSolver.cpp b/Solver/eigenSolver.cpp index bc2bc3f51c780c6b893ec3349fe725b2090d8c59..e2591937fe332ec358b3a68f1697677b8e22474c 100644 --- a/Solver/eigenSolver.cpp +++ b/Solver/eigenSolver.cpp @@ -183,4 +183,29 @@ bool eigenSolver::solve(int numEigenValues, std::string which) } + +void eigenSolver::normalize_mode(){ + Msg::Info("Normalize all eigenvectors"); + for (unsigned int i=0; i<_eigenVectors.size(); i++){ + double norm = 0.; + for (unsigned int j=0; j<_eigenVectors[i].size(); j++){ + std::complex<double> val = _eigenVectors[i][j]; + double normval = std::abs(val); + if (normval >norm) + norm = normval; + }; + + + if (norm == 0) { + Msg::Error("zero eigenvector"); + return; + }; + + for (unsigned int j=0; j<_eigenVectors[i].size(); j++){ + _eigenVectors[i][j] /= norm; + }; + + }; +}; + #endif diff --git a/Solver/eigenSolver.h b/Solver/eigenSolver.h index 62ad7be6650cf4760351b60b2cd547b577573780..d8d8ef2c8f423322b45170e9079cf12e215a05ca 100644 --- a/Solver/eigenSolver.h +++ b/Solver/eigenSolver.h @@ -41,6 +41,8 @@ class eigenSolver{ { return _eigenVectors[num][com]; }; + int getNumberEigenvectors() {return _eigenVectors.size();}; + void normalize_mode(); }; #else @@ -65,6 +67,8 @@ class eigenSolver{ std::vector<std::complex<double> > &getEigenVector(int num){ return _dummy; } void clear(){} std::complex<double> getEigenVectorComp(int num, int com) { return 0.; } + int getNumberEigenvectors() {return 0;}; + void normalize_mode() {}; }; #endif