diff --git a/Solver/eigenSolver.cpp b/Solver/eigenSolver.cpp index e2591937fe332ec358b3a68f1697677b8e22474c..291a9c8f1a7e9837bf2882de3ac9ce6f05231ed1 100644 --- a/Solver/eigenSolver.cpp +++ b/Solver/eigenSolver.cpp @@ -184,28 +184,28 @@ bool eigenSolver::solve(int numEigenValues, std::string which) } -void eigenSolver::normalize_mode(){ +void eigenSolver::normalize_mode(double scale){ 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) + 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; + _eigenVectors[i][j] *= (scale/norm); }; - }; + }; }; #endif diff --git a/Solver/eigenSolver.h b/Solver/eigenSolver.h index d8d8ef2c8f423322b45170e9079cf12e215a05ca..57c7b6b20e80353b578dd2419397824d8b1ac244 100644 --- a/Solver/eigenSolver.h +++ b/Solver/eigenSolver.h @@ -42,7 +42,7 @@ class eigenSolver{ return _eigenVectors[num][com]; }; int getNumberEigenvectors() {return _eigenVectors.size();}; - void normalize_mode(); + void normalize_mode(double scale=1.); }; #else @@ -68,7 +68,7 @@ class eigenSolver{ void clear(){} std::complex<double> getEigenVectorComp(int num, int com) { return 0.; } int getNumberEigenvectors() {return 0;}; - void normalize_mode() {}; + void normalize_mode(double scale=1.) {}; }; #endif