trilinos_eigen_solver.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_TRILINOS_EIGEN_SOLVER_HEADER
27 #define OOMPH_TRILINOS_EIGEN_SOLVER_HEADER
28 
29 // oomph-lib includes
30 #include "double_multi_vector.h"
31 #include "problem.h"
32 #include "linear_solver.h"
33 #include "eigen_solver.h"
34 
35 // Trilinos includes
36 #include "AnasaziOutputManager.hpp"
37 #include "AnasaziBasicOutputManager.hpp"
38 #include "AnasaziConfigDefs.hpp"
39 #include "AnasaziOperator.hpp"
40 #include "AnasaziMultiVec.hpp"
41 #include "AnasaziBasicEigenproblem.hpp"
42 #include "AnasaziBlockKrylovSchurSolMgr.hpp"
43 
44 namespace Anasazi
45 {
46  //========================================================================
49  //========================================================================
50  template<>
51  class MultiVecTraits<double, oomph::DoubleMultiVector>
52  {
53  public:
56  static Teuchos::RCP<oomph::DoubleMultiVector> Clone(
57  const oomph::DoubleMultiVector& mv, const int numvecs)
58  {
59  return Teuchos::rcp(new oomph::DoubleMultiVector(numvecs, mv));
60  }
61 
64  static Teuchos::RCP<oomph::DoubleMultiVector> CloneCopy(
65  const oomph::DoubleMultiVector& mv)
66  {
67  return Teuchos::rcp(new oomph::DoubleMultiVector(mv));
68  }
69 
74  static Teuchos::RCP<oomph::DoubleMultiVector> CloneCopy(
75  const oomph::DoubleMultiVector& mv, const std::vector<int>& index)
76  {
77  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index));
78  }
79 
82  static Teuchos::RCP<oomph::DoubleMultiVector> CloneCopy(
83  const oomph::DoubleMultiVector& mv, const Teuchos::Range1D& index)
84  {
85  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index));
86  }
87 
92  static Teuchos::RCP<oomph::DoubleMultiVector> CloneViewNonConst(
93  oomph::DoubleMultiVector& mv, const std::vector<int>& index)
94  {
95  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index, false));
96  }
97 
102  static Teuchos::RCP<oomph::DoubleMultiVector> CloneViewNonConst(
103  oomph::DoubleMultiVector& mv, const Teuchos::Range1D& index)
104  {
105  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index, false));
106  }
107 
113  static Teuchos::RCP<const oomph::DoubleMultiVector> CloneView(
114  const oomph::DoubleMultiVector& mv, const std::vector<int>& index)
115  {
116  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index, false));
117  }
118 
124  static Teuchos::RCP<oomph::DoubleMultiVector> CloneView(
125  oomph::DoubleMultiVector& mv, const std::vector<int>& index)
126  {
127  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index, false));
128  }
129 
135  static Teuchos::RCP<oomph::DoubleMultiVector> CloneView(
136  oomph::DoubleMultiVector& mv, const Teuchos::Range1D& index)
137  {
138  return Teuchos::rcp(new oomph::DoubleMultiVector(mv, index, false));
139  }
140 
143  {
144  return static_cast<int>(mv.nrow());
145  }
146 
149  {
150  return static_cast<int>(mv.nvector());
151  }
152 
154  static void MvTimesMatAddMv(
155  const double alpha,
157  const Teuchos::SerialDenseMatrix<int, double>& B,
158  const double beta,
160  {
161  // For safety let's (deep) copy A
163  // First pre-multiply by the scalars
164  mv *= beta;
165  C *= alpha;
166 
167  // Find the number of vectors in each multivector
168  int mv_n_vector = mv.nvector();
169  int A_n_vector = A.nvector();
170  // Find the number of rows
171  int n_row_local = A.nrow_local();
172  // Now need to multiply by the matrix and add the result
173  // to the appropriate entry in the multivector
174  for (int i = 0; i < n_row_local; ++i)
175  {
176  for (int j = 0; j < mv_n_vector; j++)
177  {
178  double res = 0.0;
179  for (int k = 0; k < A_n_vector; k++)
180  {
181  res += C(k, i) * B(k, j);
182  }
183  mv(j, i) += res;
184  }
185  }
186  }
187 
189  static void MvAddMv(const double alpha,
191  const double beta,
194  {
195  const unsigned n_vector = A.nvector();
196  const unsigned n_row_local = A.nrow_local();
197  for (unsigned v = 0; v < n_vector; v++)
198  {
199  for (unsigned i = 0; i < n_row_local; i++)
200  {
201  mv(v, i) = alpha * A(v, i) + beta * B(v, i);
202  }
203  }
204  }
205 
208  static void MvScale(oomph::DoubleMultiVector& mv, const double alpha)
209  {
210  mv *= alpha;
211  }
212 
217  const std::vector<double>& alpha)
218  {
219  const unsigned n_vector = mv.nvector();
220  const unsigned n_row_local = mv.nrow_local();
221  for (unsigned v = 0; v < n_vector; v++)
222  {
223  for (unsigned i = 0; i < n_row_local; i++)
224  {
225  mv(v, i) *= alpha[v];
226  }
227  }
228  }
229 
233  static void MvTransMv(const double alpha,
235  const oomph::DoubleMultiVector& mv,
236  Teuchos::SerialDenseMatrix<int, double>& B)
237  {
238  const unsigned A_nvec = A.nvector();
239  const unsigned A_nrow_local = A.nrow_local();
240  const unsigned mv_nvec = mv.nvector();
241  // const unsigned mv_nrow_local = mv.nrow_local();
242 
243  for (unsigned v1 = 0; v1 < A_nvec; v1++)
244  {
245  for (unsigned v2 = 0; v2 < mv_nvec; v2++)
246  {
247  B(v1, v2) = 0.0;
248  for (unsigned i = 0; i < A_nrow_local; i++)
249  {
250  B(v1, v2) += A(v1, i) * mv(v2, i);
251  }
252  B(v1, v2) *= alpha;
253  }
254  }
255 
256  // This will need to be communicated if we're in parallel and distributed
257 #ifdef OOMPH_HAS_MPI
258  if (A.distributed() &&
259  A.distribution_pt()->communicator_pt()->nproc() > 1)
260  {
261  const int n_total_val = A_nvec * mv_nvec;
262  // Pack entries into a vector
263  double b[n_total_val];
264  double b2[n_total_val];
265  unsigned count = 0;
266  for (unsigned v1 = 0; v1 < A_nvec; v1++)
267  {
268  for (unsigned v2 = 0; v2 < mv_nvec; v2++)
269  {
270  b[count] = B(v1, v2);
271  b2[count] = b[count];
272  ++count;
273  }
274  }
275 
276 
277  MPI_Allreduce(&b,
278  &b2,
279  n_total_val,
280  MPI_DOUBLE,
281  MPI_SUM,
282  A.distribution_pt()->communicator_pt()->mpi_comm());
283 
284  count = 0;
285  for (unsigned v1 = 0; v1 < A_nvec; v1++)
286  {
287  for (unsigned v2 = 0; v2 < mv_nvec; v2++)
288  {
289  B(v1, v2) = b2[count];
290  ++count;
291  }
292  }
293  }
294 #endif
295  }
296 
297 
302  static void MvDot(const oomph::DoubleMultiVector& mv,
304  std::vector<double>& b)
305  {
306  mv.dot(A, b);
307  }
308 
309 
314  static void MvNorm(const oomph::DoubleMultiVector& mv,
315  std::vector<double>& normvec)
316  {
317  mv.norm(normvec);
318  }
319 
321 
323 
324 
331  static void SetBlock(const oomph::DoubleMultiVector& A,
332  const std::vector<int>& index,
334  {
335  // Check some stuff
336  const unsigned n_index = index.size();
337  if (n_index == 0)
338  {
339  return;
340  }
341  const unsigned n_row_local = mv.nrow_local();
342  for (unsigned v = 0; v < n_index; v++)
343  {
344  for (unsigned i = 0; i < n_row_local; i++)
345  {
346  mv(index[v], i) = A(v, i);
347  }
348  }
349  }
350 
363  static void SetBlock(const oomph::DoubleMultiVector& A,
364  const Teuchos::Range1D& index,
366  {
367  // Check some stuff
368  const unsigned n_index = index.size();
369  if (n_index == 0)
370  {
371  return;
372  }
373  const unsigned n_row_local = mv.nrow_local();
374  unsigned range_index = index.lbound();
375  for (unsigned v = 0; v < n_index; v++)
376  {
377  for (unsigned i = 0; i < n_row_local; i++)
378  {
379  mv(range_index, i) = A(v, i);
380  }
381  ++range_index;
382  }
383  }
384 
388  static void Assign(const oomph::DoubleMultiVector& A,
390  {
391  mv = A;
392  }
393 
397  {
398  const unsigned n_vector = mv.nvector();
399  const unsigned n_row_local = mv.nrow_local();
400  for (unsigned v = 0; v < n_vector; v++)
401  {
402  for (unsigned i = 0; i < n_row_local; i++)
403  {
404  mv(v, i) = Teuchos::ScalarTraits<double>::random();
405  }
406  }
407  }
408 
411  static void MvInit(
414  {
415  mv.initialise(alpha);
416  }
417 
419 
421 
422 
425  static void MvPrint(const oomph::DoubleMultiVector& mv, std::ostream& os)
426  {
427  mv.output(os);
428  }
429 
431  };
432 
433 
434 } // namespace Anasazi
435 
436 namespace oomph
437 {
438  //===================================================================
441  //==================================================================
443  {
444  public:
447 
450 
452  virtual void apply(const DoubleMultiVector& x,
453  DoubleMultiVector& y) const = 0;
454  };
455 
456 } // namespace oomph
457 
458 namespace Anasazi
459 {
460  //======================================================================
463  //======================================================================
464  template<>
465  class OperatorTraits<double,
466  oomph::DoubleMultiVector,
468  {
469  public:
474  {
475  Op.apply(x, y);
476  }
477 
478  }; // End of the specialised traits class
479 
480 } // namespace Anasazi
481 
482 
483 namespace oomph
484 {
485  //====================================================================
487  //====================================================================
489  {
490  private:
491  // Pointer to the problem
493 
494  // Pointer to the linear solver used
496 
497  // Storage for the shift
498  double Sigma;
499 
500  // Storage for the matrices
502 
503  public:
505  LinearSolver* const& linear_solver_pt,
506  const double& sigma = 0.0)
507  : Problem_pt(problem_pt), Linear_solver_pt(linear_solver_pt), Sigma(sigma)
508  {
509  // Before we get into the Arnoldi loop solve the shifted matrix problem
510  // Allocated Row compressed matrices for the mass matrix and shifted main
511  // matrix
512  M_pt = new CRDoubleMatrix(problem_pt->dof_distribution_pt());
513  AsigmaM_pt = new CRDoubleMatrix(problem_pt->dof_distribution_pt());
514 
515  // Assemble the matrices
517 
518  // Do not report the time taken
520  }
521 
522 
523  // Now specify how to apply the operator
525  {
526  const unsigned n_vec = x.nvector();
527  const unsigned n_row_local = x.nrow_local();
528  if (n_vec > 1)
529  {
531  }
532  // Solve the first vector
533 
534  DoubleVector X(x.distribution_pt());
535  // Premultiply by mass matrix
536  M_pt->multiply(x.doublevector(0), X);
537  // For some reason I need to create a new vector and copy here
538  // This is odd and not expected, examine carefully
539  DoubleVector Y(x.distribution_pt());
541  // Need to synchronise
542  //#ifdef OOMPH_HAS_MPI
543  // Problem_pt->synchronise_all_dofs();
544  //#endif
545  for (unsigned i = 0; i < n_row_local; i++)
546  {
547  y(0, i) = Y[i];
548  }
549 
550  // Now loop over the others and resolve
551  for (unsigned v = 1; v < n_vec; ++v)
552  {
553  M_pt->multiply(x.doublevector(v), X);
555  //#ifdef OOMPH_HAS_MPI
556  // Problem_pt->synchronise_all_dofs();
557  //#endif
558  for (unsigned i = 0; i < n_row_local; i++)
559  {
560  y(v, i) = Y[i];
561  }
562  }
563  }
564  };
565 
566 
567  //=====================================================================
569  //=====================================================================
570  class ANASAZI : public EigenSolver
571  {
572  private:
573  typedef double ST;
574  typedef Teuchos::ScalarTraits<ST> SCT;
575  typedef SCT::magnitudeType MT;
576  typedef Anasazi::MultiVec<ST> MV;
577  typedef Anasazi::Operator<ST> OP;
578  typedef Anasazi::MultiVecTraits<ST, MV> MVT;
579  typedef Anasazi::OperatorTraits<ST, MV, OP> OPT;
580 
582  Anasazi::OutputManager<ST>* Output_manager_pt;
583 
586 
589 
593  int Spectrum;
594 
596  int NArnoldi;
597 
599  double Sigma;
600 
603  bool Small;
604 
607 
608 
609  public:
612  : Linear_solver_pt(0),
614  Spectrum(0),
615  NArnoldi(10),
616  Sigma(0.0),
618  {
619  Output_manager_pt = new Anasazi::BasicOutputManager<ST>();
620  // Set verbosity level
621  int verbosity =
622  Anasazi::Warnings + Anasazi::FinalSummary + Anasazi::TimingDetails;
623  Output_manager_pt->setVerbosity(verbosity);
624 
625  // print greeting
626  Output_manager_pt->stream(Anasazi::Warnings)
627  << Anasazi::Anasazi_Version() << std::endl
628  << std::endl;
629  }
630 
632  ANASAZI(const ANASAZI&) : Sigma(0.0) {}
633 
635  virtual ~ANASAZI() {}
636 
638  int& narnoldi()
639  {
640  return NArnoldi;
641  }
642 
644  const int& narnoldi() const
645  {
646  return NArnoldi;
647  }
648 
651  {
652  Compute_eigenvectors = true;
653  }
654 
657  {
658  Compute_eigenvectors = false;
659  }
660 
662  void solve_eigenproblem(Problem* const& problem_pt,
663  const int& n_eval,
664  Vector<std::complex<double>>& eigenvalue,
665  Vector<DoubleVector>& eigenvector)
666  {
667  // No access to sigma, so set from sigma real
668  Sigma = Sigma_real;
669 
670  // Initially be dumb here
671  Linear_solver_pt = problem_pt->linear_solver_pt();
672 
673  // Let's make the initial vector
674  Teuchos::RCP<DoubleMultiVector> initial = Teuchos::rcp(
675  new DoubleMultiVector(1, problem_pt->dof_distribution_pt()));
676  Anasazi::MultiVecTraits<double, DoubleMultiVector>::MvRandom(*initial);
677 
678  // Make the operator
679  Teuchos::RCP<DoubleMultiVectorOperator> Op_pt =
680  Teuchos::rcp(new ProblemBasedShiftInvertOperator(
681  problem_pt, this->linear_solver_pt(), Sigma));
682 
683  // Create the basic problem
684  Teuchos::RCP<Anasazi::BasicEigenproblem<double,
687  anasazi_pt = Teuchos::rcp(
688  new Anasazi::BasicEigenproblem<double,
691  initial));
692 
693  // Think I have it?
694  anasazi_pt->setHermitian(false);
695 
696  // set the number of eigenvalues requested
697  anasazi_pt->setNEV(n_eval);
698 
699  // Inform the eigenproblem that you are done passing it information
700  if (anasazi_pt->setProblem() != true)
701  {
702  oomph_info << "Anasazi::BasicEigenproblem::setProblem() had an error."
703  << std::endl
704  << "End Result: TEST FAILED" << std::endl;
705  }
706 
707  // Create the solver manager
708  // No need to have ncv specificed, Triliinos has a sensible default
709  // int ncv = 10;
710  MT tol = 1.0e-10;
711  int verbosity =
712  Anasazi::Warnings + Anasazi::FinalSummary + Anasazi::TimingDetails;
713 
714  Teuchos::ParameterList MyPL;
715  MyPL.set("Which", "LM");
716  MyPL.set("Block Size", 1);
717  // MyPL.set( "Num Blocks", ncv );
718  MyPL.set("Maximum Restarts", 500);
719  MyPL.set("Orthogonalization", "DGKS");
720  MyPL.set("Verbosity", verbosity);
721  MyPL.set("Convergence Tolerance", tol);
722  Anasazi::BlockKrylovSchurSolMgr<double,
725  BKS(anasazi_pt, MyPL);
726 
727  // Solve the problem to the specified tolerances or length
728  Anasazi::ReturnType ret = BKS.solve();
729  bool testFailed = false;
730  if (ret != Anasazi::Converged)
731  {
732  testFailed = true;
733  }
734 
735  if (testFailed)
736  {
737  oomph_info << "Eigensolver not converged\n";
738  }
739 
740  // Get the eigenvalues and eigenvectors from the eigenproblem
741  Anasazi::Eigensolution<double, DoubleMultiVector> sol =
742  anasazi_pt->getSolution();
743  std::vector<Anasazi::Value<double>> evals = sol.Evals;
744  Teuchos::RCP<DoubleMultiVector> evecs = sol.Evecs;
745 
746  eigenvalue.resize(evals.size());
747  eigenvector.resize(evals.size());
748 
749  for (unsigned i = 0; i < evals.size(); i++)
750  {
751  // Undo shift and invert
752  double a = evals[i].realpart;
753  double b = evals[i].imagpart;
754  double det = a * a + b * b;
755  eigenvalue[i] = std::complex<double>(a / det + Sigma, -b / det);
756 
757  // Now set the eigenvectors, I hope
758  eigenvector[i].build(evecs->distribution_pt());
759  unsigned nrow_local = evecs->nrow_local();
760  // Would be faster with pointers, but I'll sort that out later!
761  for (unsigned n = 0; n < nrow_local; n++)
762  {
763  eigenvector[i][n] = (*evecs)(i, n);
764  }
765  }
766  }
767 
770  {
771  Small = true;
772  }
773 
776  {
777  Small = false;
778  }
779 
782  {
783  Spectrum = 1;
784  }
785 
788  {
789  Spectrum = -1;
790  }
791 
794  {
795  Spectrum = 0;
796  }
797 
800  {
801  return Linear_solver_pt;
802  }
803 
806  {
807  return Linear_solver_pt;
808  }
809  };
810 
811 } // namespace oomph
812 
813 
814 #endif
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
Map< RowVectorXf > v2(M2.data(), M2.size())
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
Scalar * b
Definition: benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< Scalar, Dynamic, Dynamic > C
Definition: bench_gemm.cpp:49
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
static Teuchos::RCP< oomph::DoubleMultiVector > CloneCopy(const oomph::DoubleMultiVector &mv)
Creates a deep copy of the DoubleMultiVector mv return Reference-counted pointer to the new DoubleMul...
Definition: trilinos_eigen_solver.h:64
static int GetVecLength(const oomph::DoubleMultiVector &mv)
Obtain the global length of the vector.
Definition: trilinos_eigen_solver.h:142
static Teuchos::RCP< oomph::DoubleMultiVector > CloneCopy(const oomph::DoubleMultiVector &mv, const std::vector< int > &index)
Creates a new oomph::DoubleMultiVector and (deep) copies the contents of the vectors in index into th...
Definition: trilinos_eigen_solver.h:74
static void MvTransMv(const double alpha, const oomph::DoubleMultiVector &A, const oomph::DoubleMultiVector &mv, Teuchos::SerialDenseMatrix< int, double > &B)
Compute a dense matrix B through the matrix-matrix multiply .
Definition: trilinos_eigen_solver.h:233
static void MvTimesMatAddMv(const double alpha, const oomph::DoubleMultiVector &A, const Teuchos::SerialDenseMatrix< int, double > &B, const double beta, oomph::DoubleMultiVector &mv)
Update mv with .
Definition: trilinos_eigen_solver.h:154
static void MvPrint(const oomph::DoubleMultiVector &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
Definition: trilinos_eigen_solver.h:425
static Teuchos::RCP< oomph::DoubleMultiVector > CloneView(oomph::DoubleMultiVector &mv, const Teuchos::Range1D &index)
Creates a new oomph::DoubleMultiVector that contains shallow copies of selected entries of the oomph:...
Definition: trilinos_eigen_solver.h:135
static void SetBlock(const oomph::DoubleMultiVector &A, const Teuchos::Range1D &index, oomph::DoubleMultiVector &mv)
Deep copy of A into specified columns of mv.
Definition: trilinos_eigen_solver.h:363
static Teuchos::RCP< oomph::DoubleMultiVector > CloneViewNonConst(oomph::DoubleMultiVector &mv, const std::vector< int > &index)
Creates a new oomph::DoubleMultiVector that contains shallow copies of selected entries of the oomph:...
Definition: trilinos_eigen_solver.h:92
static void MvScale(oomph::DoubleMultiVector &mv, const std::vector< double > &alpha)
Scale each element of the i-th vector in mv with alpha[i].
Definition: trilinos_eigen_solver.h:216
static void MvScale(oomph::DoubleMultiVector &mv, const double alpha)
Scale each element of the vectors in mv with alpha.
Definition: trilinos_eigen_solver.h:208
static Teuchos::RCP< const oomph::DoubleMultiVector > CloneView(const oomph::DoubleMultiVector &mv, const std::vector< int > &index)
Creates a new oomph::DoubleMultiVector that contains shallow copies of selected entries of the oomph:...
Definition: trilinos_eigen_solver.h:113
static void MvAddMv(const double alpha, const oomph::DoubleMultiVector &A, const double beta, const oomph::DoubleMultiVector &B, oomph::DoubleMultiVector &mv)
Replace mv with .
Definition: trilinos_eigen_solver.h:189
static Teuchos::RCP< oomph::DoubleMultiVector > Clone(const oomph::DoubleMultiVector &mv, const int numvecs)
Creates a new empty DoubleMultiVector containing numvecs columns. Return a reference-counted pointer ...
Definition: trilinos_eigen_solver.h:56
static int GetNumberVecs(const oomph::DoubleMultiVector &mv)
Obtain the number of vectors in the multivector.
Definition: trilinos_eigen_solver.h:148
static void SetBlock(const oomph::DoubleMultiVector &A, const std::vector< int > &index, oomph::DoubleMultiVector &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index.
Definition: trilinos_eigen_solver.h:331
static Teuchos::RCP< oomph::DoubleMultiVector > CloneViewNonConst(oomph::DoubleMultiVector &mv, const Teuchos::Range1D &index)
Creates a new oomph::DoubleMultiVector that contains shallow copies of selected entries of the oomph:...
Definition: trilinos_eigen_solver.h:102
static void MvNorm(const oomph::DoubleMultiVector &mv, std::vector< double > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ,...
Definition: trilinos_eigen_solver.h:314
static Teuchos::RCP< oomph::DoubleMultiVector > CloneView(oomph::DoubleMultiVector &mv, const std::vector< int > &index)
Creates a new oomph::DoubleMultiVector that contains shallow copies of selected entries of the oomph:...
Definition: trilinos_eigen_solver.h:124
static void MvDot(const oomph::DoubleMultiVector &mv, const oomph::DoubleMultiVector &A, std::vector< double > &b)
Compute a vector b where the components are the individual dot-products of the i-th columns of A and ...
Definition: trilinos_eigen_solver.h:302
static void MvRandom(oomph::DoubleMultiVector &mv)
Replace the vectors in mv with random vectors.
Definition: trilinos_eigen_solver.h:396
static Teuchos::RCP< oomph::DoubleMultiVector > CloneCopy(const oomph::DoubleMultiVector &mv, const Teuchos::Range1D &index)
Deep copy of specified columns of oomph::DoubleMultiVector return Reference-counted pointer to the ne...
Definition: trilinos_eigen_solver.h:82
static void MvInit(oomph::DoubleMultiVector &mv, const double alpha=Teuchos::ScalarTraits< double >::zero())
Replace each element of the vectors in mv with alpha.
Definition: trilinos_eigen_solver.h:411
static void Assign(const oomph::DoubleMultiVector &A, oomph::DoubleMultiVector &mv)
mv := A
Definition: trilinos_eigen_solver.h:388
static void Apply(const oomph::DoubleMultiVectorOperator &Op, const oomph::DoubleMultiVector &x, oomph::DoubleMultiVector &y)
Matrix operator application method.
Definition: trilinos_eigen_solver.h:471
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
Class for the Anasazi eigensolver.
Definition: trilinos_eigen_solver.h:571
void track_eigenvalue_magnitude()
Set the magnitude to be the quantity of interest.
Definition: trilinos_eigen_solver.h:793
LinearSolver * Default_linear_solver_pt
Pointer to a default linear solver.
Definition: trilinos_eigen_solver.h:588
Anasazi::OutputManager< ST > * Output_manager_pt
Pointer to output manager.
Definition: trilinos_eigen_solver.h:582
Teuchos::ScalarTraits< ST > SCT
Definition: trilinos_eigen_solver.h:574
void get_eigenvalues_right_of_shift()
Set the desired eigenvalues to be right of the shift.
Definition: trilinos_eigen_solver.h:775
int Spectrum
Definition: trilinos_eigen_solver.h:593
Anasazi::OperatorTraits< ST, MV, OP > OPT
Definition: trilinos_eigen_solver.h:579
virtual ~ANASAZI()
Destructor, delete the linear solver.
Definition: trilinos_eigen_solver.h:635
bool Compute_eigenvectors
Boolean to indicate whether or not to compute the eigenvectors.
Definition: trilinos_eigen_solver.h:606
int NArnoldi
Number of Arnoldi vectors to compute.
Definition: trilinos_eigen_solver.h:596
LinearSolver * Linear_solver_pt
Pointer to a linear solver.
Definition: trilinos_eigen_solver.h:585
int & narnoldi()
Access function for the number of Arnoldi vectors.
Definition: trilinos_eigen_solver.h:638
const int & narnoldi() const
Access function for the number of Arnoldi vectors (const version)
Definition: trilinos_eigen_solver.h:644
double ST
Definition: trilinos_eigen_solver.h:573
double Sigma
Set the shifted value.
Definition: trilinos_eigen_solver.h:599
void disable_compute_eigenvectors()
Set to disable the computation of the eigenvectors.
Definition: trilinos_eigen_solver.h:656
LinearSolver *const & linear_solver_pt() const
Return a pointer to the linear solver object (const version)
Definition: trilinos_eigen_solver.h:805
void track_eigenvalue_real_part()
Set the real part to be the quantity of interest (default)
Definition: trilinos_eigen_solver.h:781
SCT::magnitudeType MT
Definition: trilinos_eigen_solver.h:575
void get_eigenvalues_left_of_shift()
Set the desired eigenvalues to be left of the shift.
Definition: trilinos_eigen_solver.h:769
Anasazi::MultiVec< ST > MV
Definition: trilinos_eigen_solver.h:576
void enable_compute_eigenvectors()
Set to enable the computation of the eigenvectors (default)
Definition: trilinos_eigen_solver.h:650
void track_eigenvalue_imaginary_part()
Set the imaginary part fo the quantity of interest.
Definition: trilinos_eigen_solver.h:787
Anasazi::MultiVecTraits< ST, MV > MVT
Definition: trilinos_eigen_solver.h:578
bool Small
Definition: trilinos_eigen_solver.h:603
ANASAZI(const ANASAZI &)
Empty copy constructor.
Definition: trilinos_eigen_solver.h:632
Anasazi::Operator< ST > OP
Definition: trilinos_eigen_solver.h:577
LinearSolver *& linear_solver_pt()
Return a pointer to the linear solver object.
Definition: trilinos_eigen_solver.h:799
void solve_eigenproblem(Problem *const &problem_pt, const int &n_eval, Vector< std::complex< double >> &eigenvalue, Vector< DoubleVector > &eigenvector)
Solve the eigen problem.
Definition: trilinos_eigen_solver.h:662
ANASAZI()
Constructor.
Definition: trilinos_eigen_solver.h:611
Definition: matrices.h:888
void multiply(const DoubleVector &x, DoubleVector &soln) const
Multiply the matrix by the vector x: soln=Ax.
Definition: matrices.cc:1782
unsigned nrow() const
access function to the number of global rows.
Definition: linear_algebra_distribution.h:463
unsigned nrow_local() const
access function for the num of local rows on this processor.
Definition: linear_algebra_distribution.h:469
Definition: trilinos_eigen_solver.h:443
DoubleMultiVectorOperator()
Empty constructor.
Definition: trilinos_eigen_solver.h:446
virtual ~DoubleMultiVectorOperator()
virtual destructor
Definition: trilinos_eigen_solver.h:449
virtual void apply(const DoubleMultiVector &x, DoubleMultiVector &y) const =0
The apply interface.
Definition: double_multi_vector.h:56
void output(std::ostream &outfile) const
output the contents of the vector
Definition: double_multi_vector.h:704
void initialise(const double &initial_value)
initialise the whole vector with value v
Definition: double_multi_vector.h:364
void dot(const DoubleMultiVector &vec, std::vector< double > &result) const
compute the 2 norm of this vector
Definition: double_multi_vector.h:809
void norm(std::vector< double > &result) const
compute the 2 norm of this vector
Definition: double_multi_vector.h:889
unsigned nvector() const
Return the number of vectors.
Definition: double_multi_vector.h:211
Definition: double_vector.h:58
Definition: eigen_solver.h:61
double Sigma_real
Definition: eigen_solver.h:65
Definition: linear_solver.h:68
virtual void solve(Problem *const &problem_pt, DoubleVector &result)=0
virtual void enable_resolve()
Definition: linear_solver.h:135
virtual void resolve(const DoubleVector &rhs, DoubleVector &result)
Definition: linear_solver.h:225
void disable_doc_time()
Disable documentation of solve times.
Definition: linear_solver.h:116
Definition: matrices.h:74
Class for the shift invert operation.
Definition: trilinos_eigen_solver.h:489
double Sigma
Definition: trilinos_eigen_solver.h:498
void apply(const DoubleMultiVector &x, DoubleMultiVector &y) const
The apply interface.
Definition: trilinos_eigen_solver.h:524
ProblemBasedShiftInvertOperator(Problem *const &problem_pt, LinearSolver *const &linear_solver_pt, const double &sigma=0.0)
Definition: trilinos_eigen_solver.h:504
CRDoubleMatrix * AsigmaM_pt
Definition: trilinos_eigen_solver.h:501
LinearSolver * Linear_solver_pt
Definition: trilinos_eigen_solver.h:495
CRDoubleMatrix * M_pt
Definition: trilinos_eigen_solver.h:501
Problem * Problem_pt
Definition: trilinos_eigen_solver.h:492
Definition: problem.h:151
LinearAlgebraDistribution *const & dof_distribution_pt() const
Return the pointer to the dof distribution (read-only)
Definition: problem.h:1668
virtual void get_eigenproblem_matrices(CRDoubleMatrix &mass_matrix, CRDoubleMatrix &main_matrix, const double &shift=0.0)
Definition: problem.cc:8368
LinearSolver *& linear_solver_pt()
Return a pointer to the linear solver object.
Definition: problem.h:1466
Definition: oomph-lib/src/generic/Vector.h:58
#define X
Definition: icosphere.cpp:20
Scalar * y
Definition: level1_cplx_impl.h:128
Eigen::DenseIndex ret
Definition: level1_cplx_impl.h:43
RealScalar alpha
Definition: level1_cplx_impl.h:151
const Scalar * a
Definition: level2_cplx_impl.h:32
Scalar beta
Definition: level2_cplx_impl.h:36
char char char int int * k
Definition: level2_impl.h:374
Definition: trilinos_eigen_solver.h:45
int sigma
Definition: calibrate.py:179
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
list x
Definition: plotDoE.py:28
EIGEN_DONT_INLINE Scalar zero()
Definition: svd_common.h:232
const char Y
Definition: test/EulerAngles.cpp:32
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2