1 #ifndef SELDON_FILE_VIRTUAL_EIGENVALUE_SOLVER_CXX
3 #include "VirtualEigenvalueSolver.hxx"
5 #ifdef SELDON_WITH_SLEPC
85 block_size = -1; nstep = -1;
86 type_extraction = -1; quadrature_rule = -1;
87 nstep_inner = -1; nstep_outer = -1;
89 moment_size = -1; block_max_size = -1; npart = 1;
90 delta_rank = 0.0; delta_spur = 0.0;
91 borth = -1; double_exp = -1;
93 krylov_restart = -1; restart_number = -1; restart_add = -1;
94 nb_conv_vector = -1; nb_conv_vector_proj = -1;
95 non_locking_variant =
false;
101 #ifndef SELDON_WITH_SLEPC
102 const char* SlepcParam::GetEigensolverChar()
const
123 radius_spectrum = 0.0;
137 return emax_interval;
159 double ratio,
double teta)
185 display_every = 100000;
191 #ifdef SELDON_WITH_MPI
193 comm = MPI_COMM_WORLD;
194 rci_comm = MPI_COMM_WORLD;
195 comm_global = MPI_COMM_WORLD;
196 global_comm_set =
false;
207 #ifdef SELDON_WITH_MPI
208 void GeneralEigenProblem_Base::SetCommunicator(
const MPI_Comm& comm_)
217 int key = 0; MPI_Comm_rank(comm_global, &key);
218 int solver_rank = 0; MPI_Comm_rank(comm, &solver_rank);
219 MPI_Comm_split(comm_global, solver_rank, key, &rci_comm);
222 rci_comm = MPI_COMM_SELF;
227 MPI_Comm& GeneralEigenProblem_Base::GetCommunicator()
233 MPI_Comm& GeneralEigenProblem_Base::GetRciCommunicator()
239 void GeneralEigenProblem_Base::SetGlobalCommunicator(
const MPI_Comm& comm_)
242 global_comm_set =
true;
246 MPI_Comm& GeneralEigenProblem_Base::GetGlobalCommunicator()
256 #ifdef SELDON_WITH_MPI
258 MPI_Comm_rank(comm, &rank_proc);
269 #ifdef SELDON_WITH_MPI
271 MPI_Comm_rank(comm_global, &rank_proc);
390 display_every = 1000000;
392 display_every = 1000;
419 #ifdef SELDON_WITH_MPI
420 int rank; MPI_Comm_rank(comm_global, &rank);
425 if (print_level >= 1)
443 #ifdef SELDON_WITH_MPI
444 MPI_Allreduce(&n, &nglob, 1, MPI_INTEGER, MPI_SUM, comm);
471 compar_eigenval = NULL;
472 SetComplexZero(shift); SetComplexZero(shift_imag);
524 s = complex<Treal>(sr, si);
546 this->type_spectrum_wanted = type;
548 this->type_sort_eigenvalues = type_sort;
563 this->type_spectrum_wanted = type;
565 shift_imag = imag(val);
567 this->type_sort_eigenvalues = type_sort;
575 compar_eigenval = ev;
578 #ifdef SELDON_WITH_SLEPC
579 template<
class T>
template<
class T0>
584 cout <<
"Incompatibles types between T and PetscScalar" << endl;
592 PetscErrorCode GeneralEigenProblem<T>::
593 GetComparisonEigenvalueSlepcGen(PetscScalar Lr, PetscScalar Li, PetscScalar Lr2, PetscScalar Li2, PetscScalar,
594 PetscInt* res,
void* ctx)
597 GeneralEigenProblem<T>& var = *
reinterpret_cast<GeneralEigenProblem<T>*
>(ctx);
598 if (var.compar_eigenval == NULL)
600 cout <<
"Invalid pointer for compar_eigenval" << endl;
604 T Lr_, Li_, Lr2_, Li2_;
605 to_complex_eigen(Lr, Lr_); to_complex_eigen(Li, Li_);
606 to_complex_eigen(Lr2, Lr2_); to_complex_eigen(Li2, Li2_);
607 int y = var.compar_eigenval->CompareEigenvalue(Lr_, Li_, Lr2_, Li2_);
615 PetscErrorCode GeneralEigenProblem<T>::
616 GetComparisonEigenvalueSlepc(PetscScalar Lr, PetscScalar Li, PetscScalar Lr2, PetscScalar Li2,
617 PetscInt* res,
void* ctx)
619 T z; SetComplexZero(z);
620 GetComparisonEigenvalueSlepcGen(Lr, Li, Lr2, Li2, z, res, ctx);
632 void GeneralEigenProblem<double>
633 ::FillComplexEigenvectors(
int m,
const complex<double>& Emid,
double eps,
634 const Vector<complex<double> >& lambda_cplx,
641 bool imag_pos =
true;
648 type_eigenval.Fill(-1);
650 for (
int i = 0; i < m; i++)
652 if (abs(imag(lambda_cplx(i))) <= eps)
654 type_eigenval(i) = 0;
661 if (imag(lambda_cplx(i)) > 0)
663 type_eigenval(i) = 1;
669 if (imag(lambda_cplx(i)) < 0)
671 type_eigenval(i) = 1;
679 int N = Ecplx.GetM();
680 Lr.Reallocate(nb_val);
681 Li.Reallocate(nb_val);
682 E.Reallocate(N, nb_val);
684 for (
int i = 0; i < m; i++)
686 if (type_eigenval(i) == 0)
688 Lr(nb_val) = realpart(lambda_cplx(i));
690 for (
int j = 0; j < N; j++)
691 E(j, nb_val) = realpart(Ecplx(j, i));
695 else if (type_eigenval(i) == 1)
697 Lr(nb_val) = real(lambda_cplx(i));
698 Li(nb_val) = imag(lambda_cplx(i));
699 Lr(nb_val+1) = Lr(nb_val);
700 Li(nb_val+1) = -Li(nb_val);
701 for (
int j = 0; j < N; j++)
703 E(j, nb_val) = real(Ecplx(j, i));
704 E(j, nb_val+1) = imag(Ecplx(j, i));
716 ::FillComplexEigenvectors(
int m,
const complex<double>& Emid,
double eps,
717 const Vector<complex<double> >& lambda_cplx,
719 Vector<complex<double> >& Lr,
Vector<complex<double> >& Li,
723 int N = Ecplx.
GetM();
726 for (
int i = 0; i < m; i++)
728 Lr(i) = lambda_cplx(i);
729 for (
int j = 0; j < N; j++)
730 E(j, i) = Ecplx(j, i);
742 #ifdef SELDON_WITH_MPI
748 int nloc,
int nodl_scalar_,
int nb_unknowns_scal_)
750 int nvec = eigen_vec.GetN();
751 eigen_vec.Resize(nloc, nvec);
754 for (
int j = 0; j < nvec; j++)
757 for (
int i = 0; i < this->n_; i++)
758 X(local_col_numbers(i)) = eigen_vec(i, j);
760 AssembleVector(X, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
761 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
763 for (
int i = 0; i < nloc; i++)
764 eigen_vec(i, j) = X(i);
778 eigenvalue_computation_mode = 1;
779 nb_add_eigenvalues = 0;
781 use_cholesky =
false;
782 diagonal_mass =
false;
784 complex_system =
false;
785 selected_part = COMPLEX_PART;
793 return eigenvalue_computation_mode;
801 eigenvalue_computation_mode = mode;
809 return nb_add_eigenvalues;
816 nb_add_eigenvalues = n;
824 return anasazi_param;
865 diagonal_mass = diag;
873 return diagonal_mass;
881 cout <<
"InitMatrix has not been called" << endl;
913 void EigenProblem_Base<T>
914 ::ComputeStiffnessMatrix(
const T& a,
const T& b)
926 void EigenProblem_Base<T>
927 ::ComputeAndFactorizeStiffnessMatrix(
const Treal& a,
const Treal& b,
996 void EigenProblem_Base<T>
1043 template<
class T,
class StiffValue,
class MassValue>
1057 template<
class T,
class StiffValue,
class MassValue>
1063 this->diagonal_mass =
true;
1064 if ( (!K.IsSymmetric()) && (!K.IsComplex()) && (this->shift_imag != T(0)) )
1068 this->diagonal_mass =
false;
1072 this->Init(K.
GetM());
1083 template<
class T,
class StiffValue,
class MassValue>
1089 this->diagonal_mass =
false;
1092 this->Init(K.
GetM());
1103 template<
class T,
class StiffValue,
class MassValue>
1117 template<
class T,
class StiffValue,
class MassValue>
1130 template<
class T,
class StiffValue,
class MassValue>
1138 if ( (!Kh->IsSymmetric())
1139 && (!Kh->IsComplex()) && (this->shift_imag != T(0)) )
1143 this->diagonal_mass =
false;
1150 template<
class T,
class StiffValue,
class MassValue>
1155 if (Kh->IsSymmetric())
1160 return Mh->IsSymmetric();
1164 this->PrintErrorInit();
1171 template<
class T,
class StiffValue,
class MassValue>
1176 if (Kh->IsComplex())
1180 if (Kh->IsSymmetric())
1186 if (Mh->IsComplex())
1189 return Mh->IsSymmetric();
1195 this->PrintErrorInit();
1202 template<
class T,
class StiffValue,
class MassValue>
1209 D.Reallocate(this->n_);
1214 cout <<
"not implemented for this kind of eigenproblem" << endl;
1221 template<
class T,
class StiffValue,
class MassValue>
1225 sqrt_diagonal_mass.Reallocate(D.GetM());
1226 for (
int i = 0; i < D.GetM(); i++)
1227 sqrt_diagonal_mass(i) = sqrt(D(i));
1232 template<
class T,
class StiffValue,
class MassValue>
1235 D.Reallocate(sqrt_diagonal_mass.GetM());
1236 for (
int i = 0; i < D.GetM(); i++)
1237 D(i) = sqrt_diagonal_mass(i);
1242 template<
class T,
class StiffValue,
class MassValue>
1246 for (
int i = 0; i < X.GetM(); i++)
1247 X(i) /= realpart(sqrt_diagonal_mass(i));
1252 template<
class T,
class StiffValue,
class MassValue>
1256 for (
int i = 0; i < X.GetM(); i++)
1257 X(i) *= realpart(sqrt_diagonal_mass(i));
1263 template<
class T,
class StiffValue,
class MassValue>
1267 for (
int i = 0; i < X.GetM(); i++)
1268 X(i) /= sqrt_diagonal_mass(i);
1273 template<
class T,
class StiffValue,
class MassValue>
1277 for (
int i = 0; i < X.GetM(); i++)
1278 X(i) *= sqrt_diagonal_mass(i);
1283 template<
class T,
class StiffValue,
class MassValue>
1293 Mh->MltVector(X, Y);
1298 template<
class T,
class StiffValue,
class MassValue>
1308 Mh->MltVector(X, Y);
1313 template<
class T,
class StiffValue,
class MassValue>
1323 Mh->MltVector(trans, X, Y);
1328 template<
class T,
class StiffValue,
class MassValue>
1338 Mh->MltVector(trans, X, Y);
1343 template<
class T,
class StiffValue,
class MassValue>
1348 this->PrintErrorInit();
1350 Kh->MltVector(X, Y);
1355 template<
class T,
class StiffValue,
class MassValue>
1360 this->PrintErrorInit();
1362 Kh->MltVector(X, Y);
1367 template<
class T,
class StiffValue,
class MassValue>
1373 this->PrintErrorInit();
1375 Kh->MltVector(X, Y);
1377 Treal coef_mass, coef_stiff;
1380 if (coef_mass != T(0))
1383 for (
int i = 0; i < Y.GetM(); i++)
1384 Y(i) += coef_mass*X(i);
1386 Mh->MltAddVector(coef_mass, X, coef_stiff, Y);
1390 if (coef_stiff != T(1))
1397 template<
class T,
class StiffValue,
class MassValue>
1403 this->PrintErrorInit();
1405 Kh->MltVector(X, Y);
1407 if (coef_mass != T(0))
1410 for (
int i = 0; i < Y.GetM(); i++)
1411 Y(i) += coef_mass*X(i);
1413 Mh->MltAddVector(coef_mass, X, coef_stiff, Y);
1417 if (coef_stiff != T(1))
1424 template<
class T,
class StiffValue,
class MassValue>
1429 this->PrintErrorInit();
1431 Kh->MltVector(trans, X, Y);
1436 template<
class T,
class StiffValue,
class MassValue>
1441 this->PrintErrorInit();
1443 Kh->MltVector(trans, X, Y);
1448 template<
class T,
class StiffValue,
class MassValue>
1451 sqrt_diagonal_mass.
Clear();
1467 template<
class T0,
class Prop,
class Storage>
1471 const T0& shiftr,
const T0& shifti)
1476 var.GetSqrtDiagonal(sqrt_Dh);
1478 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1479 for (
int j = 0; j < eigen_vectors.GetN(); j++)
1480 eigen_vectors(i, j) /= sqrt_Dh(i);
1485 for (
int j = 0; j < eigen_vectors.GetN(); j++)
1487 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1488 Xcol(i) = eigen_vectors(i, j);
1491 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1492 eigen_vectors(i, j) = Xcol(i);
1496 var.DistributeEigenvectors(eigen_vectors);
1500 bool use_rayleigh_coef =
false;
1510 use_rayleigh_coef =
true;
1513 if (!use_rayleigh_coef)
1514 for (
int i = 0; i < eigen_values.GetM(); i++)
1516 if ((eigen_values(i) == 0) && (lambda_imag(i) == 0))
1518 eigen_values(i) = 0;
1523 complex<T0> val = 1.0/complex<T0>(eigen_values(i), lambda_imag(i))
1524 + complex<T0>(shiftr, shifti);
1526 eigen_values(i) = real(val);
1527 lambda_imag(i) = imag(val);
1533 use_rayleigh_coef =
true;
1536 if (use_rayleigh_coef)
1538 int n = eigen_vectors.GetM();
1543 while (j < eigen_values.GetM())
1545 if (lambda_imag(j) == T0(0))
1549 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1550 X(i) = eigen_vectors(i,j);
1554 eigen_values(j) = DotProd(X, Ax)/DotProd(X, Mx);
1561 if (j == eigen_values.GetM() - 1)
1563 eigen_values(j) = 0.0;
1564 lambda_imag(j) = 0.0;
1570 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1572 X(i) = eigen_vectors(i, j);
1573 Y(i) = eigen_vectors(i, j+1);
1578 T0 numr = DotProd(X, Ax);
1579 T0 numi = DotProd(Y, Ax);
1582 numr += DotProd(Y, Ax);
1583 numi -= DotProd(X, Ax);
1586 T0 denr = DotProd(X, Mx);
1587 T0 deni = DotProd(Y, Mx);
1590 denr += DotProd(Y, Mx);
1591 deni -= DotProd(X, Mx);
1593 complex<T0> val = complex<T0>(numr, numi)/complex<T0>(denr, deni);
1595 eigen_values(j) = real(val);
1596 eigen_values(j+1) = real(val);
1598 lambda_imag(j) = -imag(val);
1599 lambda_imag(j+1) = imag(val);
1617 template<
class T0,
class Prop,
class Storage>
1619 Vector<complex<T0> >& eigen_values,
1620 Vector<complex<T0> >& lambda_imag,
1621 Matrix<complex<T0>, Prop, Storage>& eigen_vectors,
1622 const complex<T0>& shiftr,
const complex<T0>& shifti)
1625 if (var.DiagonalMass())
1628 var.GetSqrtDiagonal(sqrt_Dh);
1630 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1631 for (
int j = 0; j < eigen_vectors.GetN(); j++)
1632 eigen_vectors(i, j) /= sqrt_Dh(i);
1634 else if (var.UseCholeskyFactoForMass())
1637 for (
int j = 0; j < eigen_vectors.GetN(); j++)
1639 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1640 Xcol(i) = eigen_vectors(i, j);
1642 var.SolveCholeskyMass(SeldonTrans, Xcol);
1643 for (
int i = 0; i < eigen_vectors.GetM(); i++)
1644 eigen_vectors(i, j) = Xcol(i);
1648 var.DistributeEigenvectors(eigen_vectors);
1650 if (var.GetComputationalMode() != var.REGULAR_MODE)
1652 if ( (var.eigenvalue_computation_mode == var.INVERT_MODE)
1653 && (var.GetTypeSpectrum() != var.CENTERED_EIGENVALUES))
1657 else if ((var.DiagonalMass())|| (var.UseCholeskyFactoForMass())
1658 || (var.eigenvalue_computation_mode == var.INVERT_MODE))
1661 for (
int i = 0; i < eigen_values.GetM(); i++)
1663 complex<T0> val = 1.0/eigen_values(i) + shiftr;
1665 eigen_values(i) = val;
1679 template<
class T,
class Storage1,
class Storage2>
1683 int type_spectrum,
int type_sort,
1684 const T& shift_r,
const T& shift_i)
1686 int n = min(lambda_r.GetM(),
long(eigen_old.GetN()));
1688 IVect permutation(n);
1690 eigen_new.Reallocate(eigen_old.GetM(), n);
1701 for (
int i = 0; i < n; i++)
1702 L(i) = 1.0/abs(shift_r - lambda_r(i));
1707 for (
int i = 0; i < n; i++)
1708 L(i) = 1.0/abs(shift_i - lambda_i(i));
1713 for (
int i = 0; i < n; i++)
1714 L(i) = 1.0/abs(complex<T>(shift_r - lambda_r(i), shift_i - lambda_i(i)));
1726 for (
int i = 0; i < n; i++)
1727 L(i) = abs(lambda_r(i));
1732 for (
int i = 0; i < n; i++)
1733 L(i) = abs(lambda_i(i));
1738 for (
int i = 0; i < n; i++)
1739 L(i) = abs(complex<T>(lambda_r(i), lambda_i(i)));
1746 Sort(L, permutation);
1749 Vector<T> oldLambda_r = lambda_r, oldLambda_i = lambda_i;
1750 for (
int i = 0; i < n; i++)
1752 lambda_r(i) = oldLambda_r(permutation(i));
1753 lambda_i(i) = oldLambda_i(permutation(i));
1754 for (
int j = 0; j < eigen_old.GetM(); j++)
1755 eigen_new(j, i) = eigen_old(j, permutation(i));
1762 template<
class T,
class Storage1,
class Storage2>
1766 int type_spectrum,
int type_sort,
1767 const complex<T>& shift_r,
const complex<T>& shift_i)
1770 int n = min(lambda_r.GetM(),
long(eigen_old.GetN()));
1772 IVect permutation(n);
1774 eigen_new.Reallocate(eigen_old.GetM(), n);
1785 for (
int i = 0; i < n; i++)
1786 L(i) = 1.0/abs(real(shift_r - lambda_r(i)));
1791 for (
int i = 0; i < n; i++)
1792 L(i) = 1.0/abs(imag(shift_r - lambda_r(i)));
1797 for (
int i = 0; i < n; i++)
1798 L(i) = 1.0/abs(shift_r - lambda_r(i));
1810 for (
int i = 0; i < n; i++)
1811 L(i) = abs(real(lambda_r(i)));
1816 for (
int i = 0; i < n; i++)
1817 L(i) = abs(imag(lambda_r(i)));
1822 for (
int i = 0; i < n; i++)
1823 L(i) = abs(lambda_r(i));
1830 Sort(L, permutation);
1834 for (
int i = 0; i < n; i++)
1836 lambda_r(i) = oldLambda_r(permutation(i));
1837 lambda_i(i) = oldLambda_i(permutation(i));
1838 for (
int j = 0; j < eigen_old.GetM(); j++)
1839 eigen_new(j, i) = eigen_old(j, permutation(i));
1851 template<
class T,
class Tstiff,
class Prop,
class Storage,
1852 class Tmass,
class PropM,
class StorageM>
1853 DenseEigenProblem<T, Tstiff, Prop, Storage, Tmass, PropM, StorageM>::
1854 DenseEigenProblem() : VirtualEigenProblem<T, Tstiff, Tmass>()
1862 template<
class T,
class Tstiff,
class Prop,
class Storage,
1863 class Tmass,
class PropM,
class StorageM>
1864 void DenseEigenProblem<T, Tstiff, Prop, Storage, Tmass, PropM, StorageM>
1874 template<
class T,
class Tstiff,
class Prop,
class Storage,
1875 class Tmass,
class PropM,
class StorageM>
1887 template<
class T,
class Tstiff,
class Prop,
class Storage,
1888 class Tmass,
class PropM,
class StorageM>
1896 D.Reallocate(this->n_);
1901 D.Reallocate(this->n_);
1902 for (
int i = 0; i < this->n_; i++)
1909 template<
class T,
class Tstiff,
class Prop,
class Storage,
1910 class Tmass,
class PropM,
class StorageM>
1916 mat_chol.Reallocate(this->n_, this->n_);
1917 mat_chol.SetIdentity();
1922 GetCholesky(mat_chol);
1923 Xchol_real.Reallocate(mat_chol.GetM());
1924 Xchol_imag.Reallocate(mat_chol.GetM());
1930 template<
class T,
class Tstiff,
class Prop,
class Storage,
1931 class Tmass,
class PropM,
class StorageM>
1932 void DenseEigenProblem<T, Tstiff, Prop, Storage, Tmass, PropM, StorageM>::
1935 MltCholesky(transA, mat_chol, X);
1940 template<
class T,
class Tstiff,
class Prop,
class Storage,
1941 class Tmass,
class PropM,
class StorageM>
1945 for (
int i = 0; i < X.GetM(); i++)
1947 Xchol_real(i) = real(X(i));
1948 Xchol_imag(i) = imag(X(i));
1951 MltCholesky(transA, mat_chol, Xchol_real);
1952 MltCholesky(transA, mat_chol, Xchol_imag);
1954 for (
int i = 0; i < X.GetM(); i++)
1955 X(i) = complex<Treal>(Xchol_real(i), Xchol_imag(i));
1960 template<
class T,
class Tstiff,
class Prop,
class Storage,
1961 class Tmass,
class PropM,
class StorageM>
1965 SolveCholesky(transA, mat_chol, X);
1970 template<
class T,
class Tstiff,
class Prop,
class Storage,
1971 class Tmass,
class PropM,
class StorageM>
1975 for (
int i = 0; i < X.GetM(); i++)
1977 Xchol_real(i) = real(X(i));
1978 Xchol_imag(i) = imag(X(i));
1981 SolveCholesky(transA, mat_chol, Xchol_real);
1982 SolveCholesky(transA, mat_chol, Xchol_imag);
1984 for (
int i = 0; i < X.GetM(); i++)
1985 X(i) = complex<Treal>(Xchol_real(i), Xchol_imag(i));
1990 template<
class T,
class Tstiff,
class Prop,
class Storage,
1991 class Tmass,
class PropM,
class StorageM>
2006 template<
class T,
class Tstiff,
class Prop,
class Storage,
2007 class Tmass,
class PropM,
class StorageM>
2022 template<
class T,
class Tstiff,
class Prop,
class Storage,
2023 class Tmass,
class PropM,
class StorageM>
2033 Mlt(trans, *Mh, X, Y);
2038 template<
class T,
class Tstiff,
class Prop,
class Storage,
2039 class Tmass,
class PropM,
class StorageM>
2049 Mlt(trans, *Mh, X, Y);
2054 template<
class T,
class Tstiff,
class Prop,
class Storage,
2055 class Tmass,
class PropM,
class StorageM>
2060 this->PrintErrorInit();
2067 template<
class T,
class Tstiff,
class Prop,
class Storage,
2068 class Tmass,
class PropM,
class StorageM>
2073 this->PrintErrorInit();
2080 template<
class T,
class Tstiff,
class Prop,
class Storage,
2081 class Tmass,
class PropM,
class StorageM>
2087 this->PrintErrorInit();
2091 Treal coef_mass, coef_stiff;
2094 if (coef_mass != T(0))
2097 for (
int i = 0; i < Y.GetM(); i++)
2098 Y(i) += coef_mass*X(i);
2100 MltAdd(coef_mass, *Mh, X, coef_stiff, Y);
2104 if (coef_stiff != T(1))
2111 template<
class T,
class Tstiff,
class Prop,
class Storage,
2112 class Tmass,
class PropM,
class StorageM>
2118 this->PrintErrorInit();
2122 if (coef_mass != T(0))
2125 for (
int i = 0; i < Y.GetM(); i++)
2126 Y(i) += coef_mass*X(i);
2128 MltAdd(coef_mass, *Mh, X, coef_stiff, Y);
2132 if (coef_stiff != T(1))
2139 template<
class T,
class Tstiff,
class Prop,
class Storage,
2140 class Tmass,
class PropM,
class StorageM>
2145 this->PrintErrorInit();
2147 Mlt(SeldonTrans, *Kh, X, Y);
2152 template<
class T,
class Tstiff,
class Prop,
class Storage,
2153 class Tmass,
class PropM,
class StorageM>
2158 this->PrintErrorInit();
2160 Mlt(SeldonTrans, *Kh, X, Y);
2165 template<
class T,
class Tstiff,
class Prop,
class Storage,
2166 class Tmass,
class PropM,
class StorageM>
2171 ComputeAndFactoRealMatrix(T(0), a, b, which_part);
2176 template<
class T,
class Tstiff,
class Prop,
class Storage,
2177 class Tmass,
class PropM,
class StorageM>
2181 cout <<
"Provide coefficients a and b of the same type as T" << endl;
2187 template<
class T,
class Tstiff,
class Prop,
class Storage,
2188 class Tmass,
class PropM,
class StorageM>
2191 const Treal& b,
int which_part)
2193 this->selected_part = which_part;
2195 this->PrintErrorInit();
2197 this->complex_system =
false;
2199 Copy(*Kh, mat_lu_real);
2200 Mlt(b, mat_lu_real);
2203 for (
int i = 0; i < this->n_; i++)
2204 mat_lu_real(i, i) += a;
2207 Add(a, *Mh, mat_lu_real);
2210 GetLU(mat_lu_real, pivot);
2215 template<
class T,
class Tstiff,
class Prop,
class Storage,
2216 class Tmass,
class PropM,
class StorageM>
2221 this->selected_part = which_part;
2223 this->PrintErrorInit();
2225 this->complex_system =
true;
2228 for (
int i = 0; i < this->n_; i++)
2229 for (
int j = 0; j < this->n_; j++)
2230 InvMat(i, j) = (*Kh)(i, j);
2235 for (
int i = 0; i < this->n_; i++)
2240 for (
int i = 0; i < this->n_; i++)
2241 for (
int j = 0; j < this->n_; j++)
2242 InvMat(i, j) += a * (*this->Mh)(i, j);
2247 mat_lu_cplx = InvMat;
2249 GetLU(mat_lu_cplx, pivot);
2257 mat_lu_real.Reallocate(this->n_, this->n_);
2260 for (
int i = 0; i < this->n_; i++)
2261 for (
int j = 0; j < this->n_; j++)
2262 mat_lu_real(i, j) = real(InvMat(i, j));
2266 for (
int i = 0; i < this->n_; i++)
2267 for (
int j = 0; j < this->n_; j++)
2268 mat_lu_real(i, j) = imag(InvMat(i, j));
2275 template<
class T,
class Tstiff,
class Prop,
class Storage,
2276 class Tmass,
class PropM,
class StorageM>
2280 if (this->complex_system)
2284 cout <<
"The result can not be a real vector" << endl;
2288 Mlt(mat_lu_real, X, Y);
2293 SolveLU(mat_lu_real, pivot, Y);
2299 template<
class T,
class Tstiff,
class Prop,
class Storage,
2300 class Tmass,
class PropM,
class StorageM>
2304 if (this->complex_system)
2309 SolveLU(mat_lu_cplx, pivot, Y);
2312 Mlt(mat_lu_real, X, Y);
2317 SolveLU(mat_lu_real, pivot, Y);
2323 template<
class T,
class Tstiff,
class Prop,
class Storage,
2324 class Tmass,
class PropM,
class StorageM>
2329 if (this->complex_system)
2333 cout <<
"The result can not be a real vector" << endl;
2337 Mlt(transA, mat_lu_real, X, Y);
2342 SolveLU(transA, mat_lu_real, pivot, Y);
2348 template<
class T,
class Tstiff,
class Prop,
class Storage,
2349 class Tmass,
class PropM,
class StorageM>
2354 if (this->complex_system)
2359 SolveLU(transA, mat_lu_cplx, pivot, Y);
2362 Mlt(transA, mat_lu_real, X, Y);
2367 SolveLU(transA, mat_lu_real, pivot, Y);
2373 template<
class T,
class Tstiff,
class Prop,
class Storage,
2374 class Tmass,
class PropM,
class StorageM>
2380 mat_lu_real.Clear();
2381 mat_lu_cplx.Clear();
2392 template<
class T,
class MatStiff,
class MatMass>
2393 SparseEigenProblem<T, MatStiff, MatMass>::
2394 SparseEigenProblem()
2395 : VirtualEigenProblem<T, typename MatStiff::entry_type,
2396 typename MatMass::entry_type>()
2402 ProcSharingRows = NULL;
2403 SharingRowNumbers = NULL;
2404 nodl_scalar_ = nb_unknowns_scal_ = 0;
2410 template<
class T,
class MatStiff,
class MatMass>
2413 chol_facto_mass_matrix.SelectDirectSolver(type);
2417 template<
class T,
class MatStiff,
class MatMass>
2418 int SparseEigenProblem<T, MatStiff, MatMass>::RetrieveLocalNumbers(MatStiff& K)
2422 #ifdef SELDON_WITH_MPI
2425 DistributedMatrix_Base<typename MatStiff::entry_type>& A
2426 =
dynamic_cast<DistributedMatrix_Base<typename MatStiff::entry_type>&
>(K);
2428 MPI_Comm comm = A.GetCommunicator();
2429 this->SetCommunicator(comm);
2431 MPI_Comm_size(comm, &nb_proc);
2438 int m = A.GetLocalM();
2439 const IVect& OverlapRow = A.GetOverlapRowNumber();
2440 int noverlap = OverlapRow.GetM();
2441 int n = m - noverlap;
2442 local_col_numbers.Reallocate(n);
2443 Vector<bool> OverlappedRow(m); OverlappedRow.Fill(
false);
2444 for (
int i = 0; i < noverlap; i++)
2445 OverlappedRow(OverlapRow(i)) =
true;
2448 for (
int i = 0; i < m; i++)
2449 if (!OverlappedRow(i))
2450 local_col_numbers(ncol++) = i;
2452 ProcSharingRows = &A.GetProcessorSharingRows();
2453 SharingRowNumbers = &A.GetSharingRowNumbers();
2454 nodl_scalar_ = A.GetNodlScalar();
2455 nb_unknowns_scal_ = A.GetNbScalarUnknowns();
2459 catch (
const std::bad_cast&)
2462 this->SetCommunicator(MPI_COMM_SELF);
2464 local_col_numbers.Clear();
2472 template<
class T,
class MatStiff,
class MatMass>
2473 void SparseEigenProblem<T, MatStiff, MatMass>::InitMatrix(MatStiff& K)
2475 int n = RetrieveLocalNumbers(K);
2476 distributed =
false;
2480 VirtualEigenProblem<T,
typename MatStiff::entry_type,
2481 typename MatMass::entry_type>::InitMatrix(K, n);
2487 template<
class T,
class MatStiff,
class MatMass>
2488 void SparseEigenProblem<T, MatStiff, MatMass>
2489 ::InitMatrix(MatStiff& K, MatMass& M)
2491 int n = RetrieveLocalNumbers(K);
2492 distributed =
false;
2496 VirtualEigenProblem<T,
typename MatStiff::entry_type,
2497 typename MatMass::entry_type>::InitMatrix(K, M, n);
2505 template<
class T,
class MatStiff,
class MatMass>
2512 D.Reallocate(this->n_);
2518 for (
int i = 0; i < nloc; i++)
2521 #ifdef SELDON_WITH_MPI
2526 AssembleVector(M, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2527 this->comm, nodl_scalar_, nb_unknowns_scal_, 15);
2529 D.Reallocate(local_col_numbers.GetM());
2530 for (
int i = 0; i < local_col_numbers.GetM(); i++)
2531 D(i) = M(local_col_numbers(i));
2539 template<
class T,
class MatStiff,
class MatMass>
2543 this->PrintErrorInit();
2546 #ifdef SELDON_WITH_MPI
2547 MPI_Comm_rank(this->rci_comm, &rank_rci);
2550 if ((this->print_level > 2) && (rank_rci == 0))
2551 chol_facto_mass_matrix.ShowMessages();
2553 FactorizeCholeskyMass(*Mh);
2555 chol_facto_mass_matrix.HideMessages();
2557 Xchol_real.Reallocate(nloc);
2558 Xchol_imag.Reallocate(nloc);
2563 template<
class T,
class MatStiff,
class MatMass>
2564 template<
class Storage>
2568 chol_facto_mass_matrix.Factorize(M,
true);
2573 template<
class T,
class MatStiff,
class MatMass>
2574 template<
class T0,
class Prop,
class Storage>
2578 cout <<
"Cholesky factorisation has not been implemented "
2579 <<
"for complex matrices" << endl;
2584 #ifdef SELDON_WITH_MPI
2585 template<
class T,
class MatStiff,
class MatMass>
2587 template<
class Storage>
2591 chol_facto_mass_matrix.Factorize(M,
true);
2596 template<
class T,
class MatStiff,
class MatMass>
2597 template<
class T0,
class Prop,
class Storage>
2601 cout <<
"Cholesky factorisation has not been implemented "
2602 <<
"for complex matrices" << endl;
2609 template<
class T,
class MatStiff,
class MatMass>
2615 #ifdef SELDON_WITH_MPI
2616 Xchol_real.Reallocate(nloc);
2618 for (
int i = 0; i < this->n_; i++)
2619 Xchol_real(local_col_numbers(i)) = X(i);
2630 chol_facto_mass_matrix.Mlt(TransA, Xchol_real,
false);
2634 #ifdef SELDON_WITH_MPI
2635 for (
int i = 0; i < this->n_; i++)
2636 X(i) = Xchol_real(local_col_numbers(i));
2640 Copy(Xchol_real, X);
2645 template<
class T,
class MatStiff,
class MatMass>
2651 #ifdef SELDON_WITH_MPI
2652 Xchol_real.Reallocate(nloc);
2654 for (
int i = 0; i < this->n_; i++)
2655 Xchol_real(local_col_numbers(i)) = X(i);
2666 chol_facto_mass_matrix.Solve(TransA, Xchol_real,
false);
2670 #ifdef SELDON_WITH_MPI
2671 for (
int i = 0; i < this->n_; i++)
2672 X(i) = Xchol_real(local_col_numbers(i));
2676 Copy(Xchol_real, X);
2681 template<
class T,
class MatStiff,
class MatMass>
2687 #ifdef SELDON_WITH_MPI
2688 Xchol_real.Reallocate(nloc);
2689 Xchol_imag.Reallocate(nloc);
2690 for (
int i = 0; i < this->n_; i++)
2692 Xchol_real(local_col_numbers(i)) = real(X(i));
2693 Xchol_imag(local_col_numbers(i)) = imag(X(i));
2703 for (
int i = 0; i < X.GetM(); i++)
2705 Xchol_real(i) = real(X(i));
2706 Xchol_imag(i) = imag(X(i));
2709 chol_facto_mass_matrix.Mlt(TransA, Xchol_real,
false);
2710 chol_facto_mass_matrix.Mlt(TransA, Xchol_imag,
false);
2714 #ifdef SELDON_WITH_MPI
2715 for (
int i = 0; i < this->n_; i++)
2716 X(i) = complex<Treal>(Xchol_real(local_col_numbers(i)), Xchol_imag(local_col_numbers(i)));
2720 for (
int i = 0; i < X.GetM(); i++)
2721 X(i) = complex<Treal>(Xchol_real(i), Xchol_imag(i));
2726 template<
class T,
class MatStiff,
class MatMass>
2732 #ifdef SELDON_WITH_MPI
2733 Xchol_real.Reallocate(nloc);
2734 Xchol_imag.Reallocate(nloc);
2735 for (
int i = 0; i < this->n_; i++)
2737 Xchol_real(local_col_numbers(i)) = real(X(i));
2738 Xchol_imag(local_col_numbers(i)) = imag(X(i));
2748 for (
int i = 0; i < X.GetM(); i++)
2750 Xchol_real(i) = real(X(i));
2751 Xchol_imag(i) = imag(X(i));
2754 chol_facto_mass_matrix.Solve(TransA, Xchol_real,
false);
2755 chol_facto_mass_matrix.Solve(TransA, Xchol_imag,
false);
2759 #ifdef SELDON_WITH_MPI
2760 for (
int i = 0; i < this->n_; i++)
2761 X(i) = complex<Treal>(Xchol_real(local_col_numbers(i)), Xchol_imag(local_col_numbers(i)));
2765 for (
int i = 0; i < X.GetM(); i++)
2766 X(i) = complex<Treal>(Xchol_real(i), Xchol_imag(i));
2771 template<
class T,
class MatStiff,
class MatMass>
2780 #ifdef SELDON_WITH_MPI
2783 for (
int i = 0; i < this->n_; i++)
2784 Xcplx(local_col_numbers(i)) = X(i);
2786 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2787 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2789 Mh->MltVector(Xcplx, Ycplx);
2791 for (
int i = 0; i < this->n_; i++)
2792 Y(i) = Ycplx(local_col_numbers(i));
2796 Mh->MltVector(X, Y);
2802 template<
class T,
class MatStiff,
class MatMass>
2811 #ifdef SELDON_WITH_MPI
2814 for (
int i = 0; i < this->n_; i++)
2815 Xcplx(local_col_numbers(i)) = X(i);
2817 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2818 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2820 Mh->MltVector(Xcplx, Ycplx);
2822 for (
int i = 0; i < this->n_; i++)
2823 Y(i) = Ycplx(local_col_numbers(i));
2827 Mh->MltVector(X, Y);
2833 template<
class T,
class MatStiff,
class MatMass>
2843 #ifdef SELDON_WITH_MPI
2846 for (
int i = 0; i < this->n_; i++)
2847 Xcplx(local_col_numbers(i)) = X(i);
2849 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2850 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2852 Mh->MltVector(trans, Xcplx, Ycplx);
2854 for (
int i = 0; i < this->n_; i++)
2855 Y(i) = Ycplx(local_col_numbers(i));
2859 Mh->MltVector(trans, X, Y);
2865 template<
class T,
class MatStiff,
class MatMass>
2875 #ifdef SELDON_WITH_MPI
2878 for (
int i = 0; i < this->n_; i++)
2879 Xcplx(local_col_numbers(i)) = X(i);
2881 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2882 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2884 Mh->MltVector(trans, Xcplx, Ycplx);
2886 for (
int i = 0; i < this->n_; i++)
2887 Y(i) = Ycplx(local_col_numbers(i));
2891 Mh->MltVector(trans, X, Y);
2897 template<
class T,
class MatStiff,
class MatMass>
2902 this->PrintErrorInit();
2907 #ifdef SELDON_WITH_MPI
2910 for (
int i = 0; i < this->n_; i++)
2911 Xcplx(local_col_numbers(i)) = X(i);
2913 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2914 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2916 Kh->MltVector(Xcplx, Ycplx);
2918 for (
int i = 0; i < this->n_; i++)
2919 Y(i) = Ycplx(local_col_numbers(i));
2923 Kh->MltVector(X, Y);
2929 template<
class T,
class MatStiff,
class MatMass>
2934 this->PrintErrorInit();
2939 #ifdef SELDON_WITH_MPI
2942 for (
int i = 0; i < this->n_; i++)
2943 Xcplx(local_col_numbers(i)) = X(i);
2945 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2946 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2948 Kh->MltVector(Xcplx, Ycplx);
2950 for (
int i = 0; i < this->n_; i++)
2951 Y(i) = Ycplx(local_col_numbers(i));
2955 Kh->MltVector(X, Y);
2961 template<
class T,
class MatStiff,
class MatMass>
2967 this->PrintErrorInit();
2973 #ifdef SELDON_WITH_MPI
2974 Treal coef_mass, coef_stiff;
2980 for (
int i = 0; i < this->n_; i++)
2981 Xcplx(local_col_numbers(i)) = X(i);
2983 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
2984 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
2986 Kh->MltVector(Xcplx, Ycplx);
2988 for (
int i = 0; i < nloc; i++)
2989 Ycplx(i) += coef_mass*Xcplx(i);
2991 Mh->MltAddVector(coef_mass, Xcplx, coef_stiff, Ycplx);
2993 for (
int i = 0; i < this->n_; i++)
2994 Y(i) = Ycplx(local_col_numbers(i));
3005 template<
class T,
class MatStiff,
class MatMass>
3011 this->PrintErrorInit();
3016 #ifdef SELDON_WITH_MPI
3019 for (
int i = 0; i < this->n_; i++)
3020 Xcplx(local_col_numbers(i)) = X(i);
3022 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
3023 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
3025 Kh->MltVector(Xcplx, Ycplx);
3027 for (
int i = 0; i < nloc; i++)
3028 Ycplx(i) += coef_mass*Xcplx(i);
3030 Mh->MltAddVector(coef_mass, Xcplx, coef_stiff, Ycplx);
3032 for (
int i = 0; i < this->n_; i++)
3033 Y(i) = Ycplx(local_col_numbers(i));
3044 template<
class T,
class MatStiff,
class MatMass>
3049 this->PrintErrorInit();
3054 #ifdef SELDON_WITH_MPI
3057 for (
int i = 0; i < this->n_; i++)
3058 Xcplx(local_col_numbers(i)) = X(i);
3060 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
3061 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
3063 Kh->MltVector(trans, Xcplx, Ycplx);
3065 for (
int i = 0; i < this->n_; i++)
3066 Y(i) = Ycplx(local_col_numbers(i));
3070 Kh->MltVector(trans, X, Y);
3076 template<
class T,
class MatStiff,
class MatMass>
3081 this->PrintErrorInit();
3086 #ifdef SELDON_WITH_MPI
3089 for (
int i = 0; i < this->n_; i++)
3090 Xcplx(local_col_numbers(i)) = X(i);
3092 AssembleVector(Xcplx, MPI_SUM, *ProcSharingRows, *SharingRowNumbers,
3093 this->comm, nodl_scalar_, nb_unknowns_scal_, 17);
3095 Kh->MltVector(trans, Xcplx, Ycplx);
3097 for (
int i = 0; i < this->n_; i++)
3098 Y(i) = Ycplx(local_col_numbers(i));
3102 Kh->MltVector(trans, X, Y);
3109 template<
class T,
class MatStiff,
class MatMass>
3113 ComputeAndFactoRealMatrix(T(0), a, b, which);
3119 template<
class T,
class MatStiff,
class MatMass>
3123 cout <<
"Provide coefficients a and b of the same type as T" << endl;
3130 template<
class T,
class MatStiff,
class MatMass>
3134 this->complex_system =
false;
3137 this->PrintErrorInit();
3140 #ifdef SELDON_WITH_MPI
3141 MPI_Comm_rank(this->rci_comm, &rank_rci);
3144 if ((this->print_level > 2) && (rank_rci == 0))
3145 mat_lu_real.ShowMessages();
3155 T zero; SetComplexZero(zero);
3162 #ifdef SELDON_WITH_MPI
3171 catch (
const std::bad_cast&)
3179 A.Reallocate(nloc, nloc);
3186 mat_lu_real.Factorize(A);
3190 #ifdef SELDON_WITH_MPI
3197 mat_lu_real.Factorize(A);
3203 #ifdef SELDON_WITH_MPI
3215 #ifdef SELDON_WITH_MPI
3218 for (
int i = 0; i < this->local_col_numbers.GetM(); i++)
3220 int iloc = this->local_col_numbers(i);
3221 A.AddInteraction(iloc, iloc, a);
3225 for (
int i = 0; i < nloc; i++)
3226 A.AddInteraction(i, i, a);
3228 for (
int i = 0; i < nloc; i++)
3229 A.AddInteraction(i, i, a);
3236 mat_lu_real.Factorize(A);
3241 #ifdef SELDON_WITH_MPI
3252 #ifdef SELDON_WITH_MPI
3255 for (
int i = 0; i < this->local_col_numbers.GetM(); i++)
3257 int iloc = this->local_col_numbers(i);
3258 A.AddInteraction(iloc, iloc, a);
3262 for (
int i = 0; i < nloc; i++)
3263 A.AddInteraction(i, i, a);
3265 for (
int i = 0; i < nloc; i++)
3266 A.AddInteraction(i, i, a);
3273 mat_lu_real.Factorize(A);
3276 mat_lu_real.HideMessages();
3281 template<
class T,
class MatStiff,
class MatMass>
3285 this->complex_system =
true;
3286 this->selected_part = which;
3289 this->PrintErrorInit();
3292 #ifdef SELDON_WITH_MPI
3293 MPI_Comm_rank(this->rci_comm, &rank_rci);
3296 if ((this->print_level > 2) && (rank_rci == 0))
3297 mat_lu_cplx.ShowMessages();
3314 #ifdef SELDON_WITH_MPI
3323 catch (
const std::bad_cast&)
3331 A.Reallocate(nloc, nloc);
3338 mat_lu_cplx.Factorize(A);
3342 #ifdef SELDON_WITH_MPI
3349 mat_lu_cplx.Factorize(A);
3355 #ifdef SELDON_WITH_MPI
3366 #ifdef SELDON_WITH_MPI
3369 for (
int i = 0; i < this->local_col_numbers.GetM(); i++)
3371 int iloc = this->local_col_numbers(i);
3372 A.AddInteraction(iloc, iloc, a);
3376 for (
int i = 0; i < nloc; i++)
3377 A.AddInteraction(i, i, a);
3379 for (
int i = 0; i < nloc; i++)
3380 A.AddInteraction(i, i, a);
3387 mat_lu_cplx.Factorize(A);
3392 #ifdef SELDON_WITH_MPI
3403 #ifdef SELDON_WITH_MPI
3406 for (
int i = 0; i < this->local_col_numbers.GetM(); i++)
3408 int iloc = this->local_col_numbers(i);
3409 A.AddInteraction(iloc, iloc, a);
3413 for (
int i = 0; i < nloc; i++)
3414 A.AddInteraction(i, i, a);
3416 for (
int i = 0; i < nloc; i++)
3417 A.AddInteraction(i, i, a);
3424 mat_lu_cplx.Factorize(A);
3427 mat_lu_cplx.HideMessages();
3432 template<
class T,
class MatStiff,
class MatMass>
3436 ComputeSolution(SeldonNoTrans, X, Y);
3441 template<
class T,
class MatStiff,
class MatMass>
3445 ComputeSolution(SeldonNoTrans, X, Y);
3450 template<
class T,
class MatStiff,
class MatMass>
3455 if (this->complex_system)
3459 cout <<
"The result can not be a real vector" << endl;
3466 #ifdef SELDON_WITH_MPI
3468 for (
int i = 0; i < this->n_; i++)
3469 Xcplx(local_col_numbers(i)) = Tcplx(X(i), 0);
3478 for (
int i = 0; i < nloc; i++)
3479 Xcplx(i) = Tcplx(X(i), 0);
3481 mat_lu_cplx.Solve(transA, Xcplx,
false);
3487 #ifdef SELDON_WITH_MPI
3488 for (
int i = 0; i < this->n_; i++)
3489 Y(i) = imag(Xcplx(local_col_numbers(i)));
3493 for (
int i = 0; i < nloc; i++)
3494 Y(i) = imag(Xcplx(i));
3500 #ifdef SELDON_WITH_MPI
3501 for (
int i = 0; i < this->n_; i++)
3502 Y(i) = real(Xcplx(local_col_numbers(i)));
3506 for (
int i = 0; i < this->n_; i++)
3507 Y(i) = real(Xcplx(i));
3515 #ifdef SELDON_WITH_MPI
3517 for (
int i = 0; i < this->n_; i++)
3518 Xreal(local_col_numbers(i)) = X(i);
3529 mat_lu_real.Solve(transA, Xreal,
false);
3533 #ifdef SELDON_WITH_MPI
3534 for (
int i = 0; i < this->n_; i++)
3535 Y(i) = Xreal(local_col_numbers(i));
3545 template<
class T,
class MatStiff,
class MatMass>
3550 if (this->complex_system)
3557 #ifdef SELDON_WITH_MPI
3559 for (
int i = 0; i < this->n_; i++)
3560 Xcplx(local_col_numbers(i)) = X(i);
3571 mat_lu_cplx.Solve(transA, Xcplx,
false);
3575 #ifdef SELDON_WITH_MPI
3576 for (
int i = 0; i < this->n_; i++)
3577 Y(i) = Xcplx(local_col_numbers(i));
3585 cout <<
"not implemented" << endl;
3591 cout <<
"not implemented" << endl;
3600 template<
class T,
class MatStiff,
class MatMass>
3606 #ifdef SELDON_WITH_MPI
3607 this->AssembleEigenvectors(eigen_vec, local_col_numbers, ProcSharingRows,
3608 SharingRowNumbers, nloc, nodl_scalar_, nb_unknowns_scal_);
3614 template<
class T,
class MatStiff,
class MatMass>
3617 mat_lu_real.Clear();
3618 mat_lu_cplx.Clear();
3619 chol_facto_mass_matrix.Clear();
3628 #ifdef SELDON_WITH_ARPACK
3632 #ifdef SELDON_WITH_ANASAZI
3636 #ifdef SELDON_WITH_FEAST
3640 #ifdef SELDON_WITH_SLEPC
3651 #ifdef SELDON_WITH_FEAST
3655 #ifdef SELDON_WITH_SLEPC
3666 #ifdef SELDON_WITH_SLEPC
3674 template<
class T,
class Prop,
class Storage>
3680 if (type_solver == TypeEigenvalueSolver::DEFAULT)
3683 if (type_solver == TypeEigenvalueSolver::ARPACK)
3685 #ifdef SELDON_WITH_ARPACK
3686 T zero; SetComplexZero(zero);
3692 eigen_vec, var_eig.LARGE_EIGENVALUES,
3695 cout <<
"Recompile with Arpack" << endl;
3699 else if (type_solver == TypeEigenvalueSolver::ANASAZI)
3701 #ifdef SELDON_WITH_ANASAZI
3702 T zero; SetComplexZero(zero);
3703 Matrix<T, General, ColMajor> eigen_old;
3708 eigen_vec, var_eig.LARGE_EIGENVALUES,
3711 cout <<
"Recompile with Anasazi" << endl;
3715 else if (type_solver == TypeEigenvalueSolver::FEAST)
3717 #ifdef SELDON_WITH_FEAST
3718 T zero; SetComplexZero(zero);
3719 Matrix<T, General, ColMajor> eigen_old;
3720 FindEigenvaluesFeast(var_eig, lambda, lambda_imag, eigen_old);
3724 eigen_vec, var_eig.LARGE_EIGENVALUES,
3727 cout <<
"Recompile with MKL or Feast" << endl;
3731 else if (type_solver == TypeEigenvalueSolver::SLEPC)
3733 #ifdef SELDON_WITH_SLEPC
3734 T zero; SetComplexZero(zero);
3735 Matrix<T, General, ColMajor> eigen_old;
3736 FindEigenvaluesSlepc(var_eig, lambda, lambda_imag, eigen_old);
3740 eigen_vec, var_eig.LARGE_EIGENVALUES,
3743 cout <<
"Recompile with Slepc" << endl;
3749 cout <<
"Recompile with eigenvalue solver" << endl;
3756 #define SELDON_FILE_VIRTUAL_EIGENVALUE_SOLVER_CXX