escript  Revision_
SystemMatrix.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 
19 /****************************************************************************/
20 
21 /* Paso: SystemMatrix */
22 
23 /****************************************************************************/
24 
25 /* Copyrights by ACcESS Australia 2003,2004,2005,2006 */
26 /* Author: Lutz Gross, l.gross@uq.edu.au */
27 
28 /****************************************************************************/
29 
30 #ifndef __PASO_SYSTEMMATRIX_H__
31 #define __PASO_SYSTEMMATRIX_H__
32 
33 #include "SparseMatrix.h"
34 #include "SystemMatrixPattern.h"
35 
36 #include <escript/AbstractSystemMatrix.h>
37 
38 namespace paso {
39 
40 struct Options;
41 template <class T> class SystemMatrix;
42 template <typename T> using SystemMatrix_ptr = boost::shared_ptr<SystemMatrix<T> >;
43 template <typename T> using const_SystemMatrix_ptr = boost::shared_ptr<const SystemMatrix<T> >;
44 
45 typedef int SystemMatrixType;
46 
48 template <class T>
50 {
51 public:
53  SystemMatrix();
54 
56  dim_t rowBlockSize, dim_t columnBlockSize,
57  bool patternIsUnrolled, const escript::FunctionSpace& rowFS,
58  const escript::FunctionSpace& colFS);
59 
60  ~SystemMatrix();
61 
66  virtual void nullifyRowsAndCols(escript::Data& mask_row,
67  escript::Data& mask_col,
68  double main_diagonal_value);
69 
70  virtual inline void saveMM(const std::string& filename) const
71  {
72  if (mpi_info->size > 1) {
73  //throw PasoException("SystemMatrix::saveMM: Only single rank supported.");
75  if (mpi_info->rank == 0)
76  merged->saveMM(filename.c_str());
77  } else {
78  mainBlock->saveMM(filename.c_str());
79  }
80  }
81 
82  virtual inline void saveHB(const std::string& filename) const
83  {
84  if (mpi_info->size > 1) {
85  throw PasoException("SystemMatrix::saveHB: Only single rank supported.");
86  } else if (!(type & MATRIX_FORMAT_CSC)) {
87  throw PasoException("SystemMatrix::saveHB: Only CSC format supported.");
88  } else {
89  mainBlock->saveHB_CSC(filename.c_str());
90  }
91  }
92 
93  virtual void resetValues(bool preserveSolverData = false);
94 
99  void nullifyRows(double* mask_row, double main_diagonal_value);
100 
101  void add(dim_t, index_t*, dim_t, dim_t, index_t*, dim_t, double*);
102 
103  void makeZeroRowSums(double* left_over);
104 
114 
115  void copyRemoteCoupleBlock(bool recreatePattern);
116 
117  void fillWithGlobalCoordinates(double f1);
118 
119  void print() const;
120 
124 
125  void mergeMainAndCouple(index_t** p_ptr, index_t** p_idx, double** p_val) const;
126 
127  void mergeMainAndCouple_CSR_OFFSET0(index_t** p_ptr, index_t** p_idx, double** p_val) const;
128  void mergeMainAndCouple_CSR_OFFSET0_Block(index_t** p_ptr, index_t** p_idx, double** p_val) const;
129 
130  void mergeMainAndCouple_CSC_OFFSET1(index_t** p_ptr, index_t** p_idx, double** p_val) const;
131 
132  void copyMain_CSC_OFFSET1(index_t** p_ptr, index_t** p_idx, double** p_val);
133 
134  void extendedRowsForST(dim_t* degree_ST, index_t* offset_ST, index_t* ST);
135 
136  void applyBalanceInPlace(double* x, bool RHS) const;
137 
138  void applyBalance(double* x_out, const double* x, bool RHS) const;
139 
140  void balance();
141 
142  double getGlobalSize() const;
143 
144  void setPreconditioner(Options* options);
145 
150  void solvePreconditioner(double* x, double* b);
151 
153 
155 
156  inline void startCollect(const double* in) const
157  {
158  startColCollect(in);
159  }
160 
161  inline double* finishCollect() const
162  {
163  return finishColCollect();
164  }
165 
166  inline void startColCollect(const double* in) const
167  {
168  col_coupler->startCollect(in);
169  }
170 
171  inline double* finishColCollect() const
172  {
173  return col_coupler->finishCollect();
174  }
175 
176  inline void startRowCollect(const double* in)
177  {
178  row_coupler->startCollect(in);
179  }
180 
181  inline double* finishRowCollect()
182  {
183  return row_coupler->finishCollect();
184  }
185 
186  inline dim_t getNumRows() const
187  {
188  return mainBlock->numRows;
189  }
190 
191  inline dim_t getNumCols() const
192  {
193  return mainBlock->numCols;
194  }
195 
196  inline dim_t getTotalNumRows() const
197  {
198  return getNumRows() * row_block_size;
199  }
200 
201  inline dim_t getTotalNumCols() const
202  {
203  return getNumCols() * col_block_size;
204  }
205 
206  inline dim_t getRowOverlap() const
207  {
208  return row_coupler->getNumOverlapComponents();
209  }
210 
211  inline dim_t getColOverlap() const
212  {
213  return col_coupler->getNumOverlapComponents();
214  }
215 
216  inline dim_t getGlobalNumRows() const
217  {
218  if (type & MATRIX_FORMAT_CSC) {
219  return pattern->input_distribution->getGlobalNumComponents();
220  }
221  return pattern->output_distribution->getGlobalNumComponents();
222  }
223 
224  inline dim_t getGlobalNumCols() const
225  {
226  if (type & MATRIX_FORMAT_CSC) {
227  return pattern->output_distribution->getGlobalNumComponents();
228  }
229  return pattern->input_distribution->getGlobalNumComponents();
230  }
231 
233  {
234  return getGlobalNumRows() * row_block_size;
235  }
236 
238  {
239  return getGlobalNumCols() * col_block_size;
240  }
241 
242  inline double getSparsity() const
243  {
244  return getGlobalSize() /
246  }
247 
248  inline dim_t getNumOutput() const
249  {
250  return pattern->getNumOutput();
251  }
252 
253  inline void copyBlockFromMainDiagonal(double* out) const
254  {
255  mainBlock->copyBlockFromMainDiagonal(out);
256  }
257 
258  inline void copyBlockToMainDiagonal(const double* in)
259  {
260  mainBlock->copyBlockToMainDiagonal(in);
261  }
262 
263  inline void copyFromMainDiagonal(double* out) const
264  {
265  mainBlock->copyFromMainDiagonal(out);
266  }
267 
268  inline void copyToMainDiagonal(const double* in)
269  {
270  mainBlock->copyToMainDiagonal(in);
271  }
272 
273  inline void setValues(double value)
274  {
275  mainBlock->setValues(value);
276  col_coupleBlock->setValues(value);
277  row_coupleBlock->setValues(value);
278  is_balanced = false;
279  }
280 
281  inline void rowSum(double* row_sum) const
282  {
284  throw PasoException("SystemMatrix::rowSum: No normalization "
285  "available for compressed sparse column or index offset 1.");
286  } else {
287  const dim_t nrow = mainBlock->numRows*row_block_size;
288 #pragma omp parallel for
289  for (index_t irow=0; irow<nrow; ++irow) {
290  row_sum[irow]=0.;
291  }
292  mainBlock->addRow_CSR_OFFSET0(row_sum);
293  col_coupleBlock->addRow_CSR_OFFSET0(row_sum);
294  }
295  }
296 
297  void MatrixVector(double alpha, const T* in, double beta,
298  T* out) const;
299 
300  void MatrixVector_CSR_OFFSET0(double alpha, const double* in, double beta,
301  double* out) const;
302 
303  static SystemMatrix_ptr<double> loadMM_toCSR(const char* filename);
304 
305  static SystemMatrix_ptr<double> loadMM_toCSC(const char* filename);
306 
307  static int getSystemMatrixTypeId(int solver, int preconditioner,
308  int package, bool is_complex, bool symmetry,
309  const escript::JMPI& mpi_info);
310 
313 
316 
320 
324 
327 
336 
338 
344  double* balance_vector;
345 
347  mutable index_t* global_id;
348 
351 
353  void* solver_p;
354 
355 private:
356  virtual void setToSolution(escript::Data& out, escript::Data& in,
357  boost::python::object& options) const;
358 
359  virtual void ypAx(escript::Data& y, escript::Data& x) const;
360 
361  void solve(T* out, T* in, Options* options) const;
362 };
363 
364 
365 void RHS_loadMM_toCSR(const char* filename, double* b, dim_t size);
366 
367 
368 } // namespace paso
369 
370 #include "Options.h"
371 #include "Solver.h"
372 
373 #include <escript/Data.h>
374 
375 namespace paso {
376 
377 template <>
379 template <>
381 template <>
382 void PASO_DLL_API SystemMatrix<double>::MatrixVector(double alpha, const double* in, double beta,
383  double* out) const;
384 template <>
385 void PASO_DLL_API SystemMatrix<cplx_t>::MatrixVector(double alpha, const cplx_t* in, double beta,
386  cplx_t* out) const;
387 template <>
388 void PASO_DLL_API SystemMatrix<double>::solve(double* out, double* in, Options* options) const;
389 template <>
391 
392 template <class T>
394 {
395  throw PasoException("SystemMatrix: Illegal to generate default SystemMatrix.");
396 }
397 
403 template <class T>
405  SystemMatrixPattern_ptr npattern, dim_t rowBlockSize,
406  dim_t colBlockSize, bool patternIsUnrolled,
407  const escript::FunctionSpace& rowFS,
408  const escript::FunctionSpace& colFS) :
409  escript::AbstractSystemMatrix(rowBlockSize, rowFS, colBlockSize, colFS),
410  type(ntype),
411  logical_row_block_size(rowBlockSize),
412  logical_col_block_size(colBlockSize),
413  is_balanced(false),
414  balance_vector(NULL),
415  global_id(NULL),
416  solver_package(PASO_PASO),
417  solver_p(NULL)
418 {
419  if (patternIsUnrolled) {
420  if ((ntype & MATRIX_FORMAT_OFFSET1) != (npattern->type & MATRIX_FORMAT_OFFSET1)) {
421  throw PasoException("SystemMatrix: requested offset and pattern offset do not match.");
422  }
423  }
424  // do we need to apply unrolling?
425  bool unroll
426  // we don't like non-square blocks
427  = (rowBlockSize != colBlockSize)
428 #ifndef ESYS_HAVE_LAPACK
429  // or any block size bigger than 3
430  || (colBlockSize > 3)
431 #endif
432  // or if block size one requested and the block size is not 1
433  || ((ntype & MATRIX_FORMAT_BLK1) && colBlockSize > 1)
434  // or the offsets don't match
435  || ((ntype & MATRIX_FORMAT_OFFSET1) != (npattern->type & MATRIX_FORMAT_OFFSET1));
436 
437  SystemMatrixType pattern_format_out = (ntype & MATRIX_FORMAT_OFFSET1)
439 
440  mpi_info = npattern->mpi_info;
441 
442  if (ntype & MATRIX_FORMAT_CSC) {
443  if (unroll) {
444  if (patternIsUnrolled) {
445  pattern=npattern;
446  } else {
447  pattern = npattern->unrollBlocks(pattern_format_out,
448  colBlockSize, rowBlockSize);
449  }
450  row_block_size = 1;
451  col_block_size = 1;
452  } else {
453  pattern = npattern->unrollBlocks(pattern_format_out, 1, 1);
454  row_block_size = rowBlockSize;
455  col_block_size = colBlockSize;
456  }
457  row_distribution = pattern->input_distribution;
458  col_distribution = pattern->output_distribution;
459  } else {
460  if (unroll) {
461  if (patternIsUnrolled) {
462  pattern = npattern;
463  } else {
464  pattern = npattern->unrollBlocks(pattern_format_out,
465  rowBlockSize, colBlockSize);
466  }
467  row_block_size = 1;
468  col_block_size = 1;
469  } else {
470  pattern = npattern->unrollBlocks(pattern_format_out, 1, 1);
471  row_block_size = rowBlockSize;
472  col_block_size = colBlockSize;
473  }
474  row_distribution = pattern->output_distribution;
475  col_distribution = pattern->input_distribution;
476  }
477  if (ntype & MATRIX_FORMAT_DIAGONAL_BLOCK) {
479  } else {
481  }
482  col_coupler.reset(new Coupler<real_t>(pattern->col_connector, col_block_size, mpi_info));
483  row_coupler.reset(new Coupler<real_t>(pattern->row_connector, row_block_size, mpi_info));
484  mainBlock.reset(new SparseMatrix<T>(type, pattern->mainPattern, row_block_size, col_block_size, true));
485  col_coupleBlock.reset(new SparseMatrix<T>(type, pattern->col_couplePattern, row_block_size, col_block_size, true));
486  row_coupleBlock.reset(new SparseMatrix<T>(type, pattern->row_couplePattern, row_block_size, col_block_size, true));
487  const dim_t n_norm = std::max(mainBlock->numCols*col_block_size, mainBlock->numRows*row_block_size);
488  balance_vector = new double[n_norm];
489 #pragma omp parallel for
490  for (dim_t i=0; i<n_norm; ++i)
491  balance_vector[i] = 1.;
492 }
493 
494 // deallocates a SystemMatrix
495 template <class T>
497 {
498  solve_free(this);
499  delete[] balance_vector;
500  delete[] global_id;
501 }
502 
503 template <class T>
504 int SystemMatrix<T>::getSystemMatrixTypeId(int solver, int preconditioner,
505  int package, bool is_complex, bool symmetry,
506  const escript::JMPI& mpi_info)
507 {
508  int out = -1;
509  int true_package = Options::getPackage(Options::mapEscriptOption(solver),
510  Options::mapEscriptOption(package),
511  symmetry, mpi_info);
512 
513  switch(true_package) {
514  case PASO_PASO:
515  out = MATRIX_FORMAT_DEFAULT;
516  break;
517 
518  case PASO_MKL:
520  break;
521 
522  case PASO_UMFPACK:
523  if (mpi_info->size > 1) {
524  throw PasoException("The selected solver UMFPACK "
525  "requires CSC format which is not supported with "
526  "more than one rank.");
527  } else {
529  }
530  break;
531 
532  case PASO_MUMPS:
534  break;
535 
536  default:
537  throw PasoException("unknown package code");
538  }
539  if (out > 0 && is_complex)
540  out |= MATRIX_FORMAT_COMPLEX;
541  return out;
542 }
543 
544 template <class T>
546  escript::Data& col_q,
547  double main_diagonal_value)
548 {
549  if (row_q.isComplex() || col_q.isComplex())
550  {
551  throw PasoException("SystemMatrix::nullifyRowsAndCols: complex arguments not supported");
552  }
553  if (col_q.getDataPointSize() != getColumnBlockSize()) {
554  throw PasoException("nullifyRowsAndCols: column block size does not match the number of components of column mask.");
555  } else if (row_q.getDataPointSize() != getRowBlockSize()) {
556  throw PasoException("nullifyRowsAndCols: row block size does not match the number of components of row mask.");
557  } else if (col_q.getFunctionSpace() != getColumnFunctionSpace()) {
558  throw PasoException("nullifyRowsAndCols: column function space and function space of column mask don't match.");
559  } else if (row_q.getFunctionSpace() != getRowFunctionSpace()) {
560  throw PasoException("nullifyRowsAndCols: row function space and function space of row mask don't match.");
561  }
562  row_q.expand();
563  col_q.expand();
564  row_q.requireWrite();
565  col_q.requireWrite();
566  double* mask_row = row_q.getExpandedVectorReference(static_cast<escript::DataTypes::real_t>(0)).data();
567  double* mask_col = col_q.getExpandedVectorReference(static_cast<escript::DataTypes::real_t>(0)).data();
568 
569  if (mpi_info->size > 1) {
570  if (type & MATRIX_FORMAT_CSC) {
571  throw PasoException("SystemMatrix::nullifyRowsAndCols: "
572  "CSC is not supported with MPI.");
573  }
574 
575  startColCollect(mask_col);
576  startRowCollect(mask_row);
577  if (col_block_size==1 && row_block_size==1) {
578  mainBlock->nullifyRowsAndCols_CSR_BLK1(mask_row, mask_col, main_diagonal_value);
579  double* remote_values = finishColCollect();
580  col_coupleBlock->nullifyRowsAndCols_CSR_BLK1(mask_row, remote_values, 0.);
581  remote_values = finishRowCollect();
582  row_coupleBlock->nullifyRowsAndCols_CSR_BLK1(remote_values, mask_col, 0.);
583  } else {
584  mainBlock->nullifyRowsAndCols_CSR(mask_row, mask_col, main_diagonal_value);
585  double* remote_values = finishColCollect();
586  col_coupleBlock->nullifyRowsAndCols_CSR(mask_row, remote_values, 0.);
587  remote_values = finishRowCollect();
588  row_coupleBlock->nullifyRowsAndCols_CSR(remote_values, mask_col, 0.);
589  }
590  } else {
591  if (col_block_size==1 && row_block_size==1) {
592  if (type & MATRIX_FORMAT_CSC) {
593  mainBlock->nullifyRowsAndCols_CSC_BLK1(mask_row, mask_col, main_diagonal_value);
594  } else {
595  mainBlock->nullifyRowsAndCols_CSR_BLK1(mask_row, mask_col, main_diagonal_value);
596  }
597  } else {
598  if (type & MATRIX_FORMAT_CSC) {
599  mainBlock->nullifyRowsAndCols_CSC(mask_row, mask_col, main_diagonal_value);
600  } else {
601  mainBlock->nullifyRowsAndCols_CSR(mask_row, mask_col, main_diagonal_value);
602  }
603  }
604  }
605 }
606 
607 template <class T>
608 void SystemMatrix<T>::resetValues(bool preserveSolverData)
609 {
610  setValues(0.);
611  if (!preserveSolverData)
612  solve_free(this);
613 }
614 
615 template <class T>
617  boost::python::object& options) const
618 {
619 #if !defined(ESYS_HAVE_MUMPS)
620  if (in.isComplex() || out.isComplex())
621  {
622  throw PasoException("SystemMatrix::setToSolution: complex arguments not supported.");
623  }
624 #endif
625  options.attr("resetDiagnostics")();
626  Options paso_options(options);
627  if (out.getDataPointSize() != getColumnBlockSize()) {
628  throw PasoException("solve: column block size does not match the number of components of solution.");
629  } else if (in.getDataPointSize() != getRowBlockSize()) {
630  throw PasoException("solve: row block size does not match the number of components of right hand side.");
631  } else if (out.getFunctionSpace() != getColumnFunctionSpace()) {
632  throw PasoException("solve: column function space and function space of solution don't match.");
633  } else if (in.getFunctionSpace() != getRowFunctionSpace()) {
634  throw PasoException("solve: row function space and function space of right hand side don't match.");
635  }
636  out.expand();
637  in.expand();
638  out.requireWrite();
639  in.requireWrite();
640  T* out_dp = out.getExpandedVectorReference(static_cast<T>(0)).data();
641  T* in_dp = in.getExpandedVectorReference(static_cast<T>(0)).data();
642  solve(out_dp, in_dp, &paso_options);
643  paso_options.updateEscriptDiagnostics(options);
644 }
645 
646 template <class T>
648 {
649 #if !defined(ESYS_HAVE_MUMPS)
650  if (x.isComplex() || y.isComplex())
651  {
652  throw PasoException("SystemMatrix::ypAx: complex arguments not supported.");
653  }
654 #endif
655  if (x.getDataPointSize() != getColumnBlockSize()) {
656  throw PasoException("matrix vector product: column block size does not match the number of components in input.");
657  } else if (y.getDataPointSize() != getRowBlockSize()) {
658  throw PasoException("matrix vector product: row block size does not match the number of components in output.");
659  } else if (x.getFunctionSpace() != getColumnFunctionSpace()) {
660  throw PasoException("matrix vector product: column function space and function space of input don't match.");
661  } else if (y.getFunctionSpace() != getRowFunctionSpace()) {
662  throw PasoException("matrix vector product: row function space and function space of output don't match.");
663  }
664  x.expand();
665  y.expand();
666  x.requireWrite();
667  y.requireWrite();
668  T* x_dp = x.getExpandedVectorReference(static_cast<T>(0)).data();
669  T* y_dp = y.getExpandedVectorReference(static_cast<T>(0)).data();
670  MatrixVector(1., x_dp, 1., y_dp);
671 }
672 
673 } // namespace paso
674 
675 #endif // __PASO_SYSTEMMATRIX_H__
676 
MATRIX_FORMAT_BLK1
#define MATRIX_FORMAT_BLK1
Definition: Paso.h:63
paso::SystemMatrix::mergeMainAndCouple_CSR_OFFSET0
void mergeMainAndCouple_CSR_OFFSET0(index_t **p_ptr, index_t **p_idx, double **p_val) const
paso::SystemMatrix::saveMM
virtual void saveMM(const std::string &filename) const
Definition: SystemMatrix.h:70
escript::Data::isComplex
bool isComplex() const
True if components of this data are stored as complex.
Definition: Data.cpp:1160
paso::SystemMatrix::setToSolution
virtual void setToSolution(escript::Data &out, escript::Data &in, boost::python::object &options) const
Definition: SystemMatrix.h:616
PASO_DLL_API
#define PASO_DLL_API
Definition: paso/src/system_dep.h:29
paso::SystemMatrix::getTotalNumRows
dim_t getTotalNumRows() const
Definition: SystemMatrix.h:196
paso::SystemMatrix::saveHB
virtual void saveHB(const std::string &filename) const
Definition: SystemMatrix.h:82
paso::SystemMatrix::row_coupleBlock
SparseMatrix_ptr< T > row_coupleBlock
coupling to neighbouring processors (col - row)
Definition: SystemMatrix.h:333
escript::DataTypes::real_t
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:52
paso::SystemMatrix::mergeMainAndCouple_CSR_OFFSET0_Block
void mergeMainAndCouple_CSR_OFFSET0_Block(index_t **p_ptr, index_t **p_idx, double **p_val) const
paso::SystemMatrix::balance_vector
double * balance_vector
Definition: SystemMatrix.h:344
paso::SparseMatrix_ptr
boost::shared_ptr< SparseMatrix< T > > SparseMatrix_ptr
Definition: SparseMatrix.h:37
escript::Data::requireWrite
void requireWrite()
Ensures data is ready for write access. This means that the data will be resolved if lazy and will be...
Definition: Data.cpp:1239
paso::SystemMatrix
this class holds a (distributed) stiffness matrix
Definition: SystemMatrix.h:50
escript::Distribution_ptr
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:25
MATRIX_FORMAT_CSC
#define MATRIX_FORMAT_CSC
Definition: Paso.h:62
paso::SystemMatrix::getGlobalTotalNumCols
dim_t getGlobalTotalNumCols() const
Definition: SystemMatrix.h:237
paso::RHS_loadMM_toCSR
void RHS_loadMM_toCSR(const char *filename, double *b, dim_t size)
Definition: SystemMatrix_loadMM.cpp:301
paso::SystemMatrix::copyBlockToMainDiagonal
void copyBlockToMainDiagonal(const double *in)
Definition: SystemMatrix.h:258
paso::SystemMatrix::getGlobalNumCols
dim_t getGlobalNumCols() const
Definition: SystemMatrix.h:224
paso::SystemMatrix::solvePreconditioner
void solvePreconditioner(double *x, double *b)
paso::SystemMatrix::nullifyRowsAndCols
virtual void nullifyRowsAndCols(escript::Data &mask_row, escript::Data &mask_col, double main_diagonal_value)
Definition: SystemMatrix.h:545
paso::SystemMatrix::loadMM_toCSC
static SystemMatrix_ptr< double > loadMM_toCSC(const char *filename)
paso::SystemMatrix::balance
void balance()
paso::Coupler
Definition: Coupler.h:100
paso::SystemMatrix::copyColCoupleBlock
void copyColCoupleBlock()
paso::SystemMatrix::row_coupler
Coupler_ptr< real_t > row_coupler
Definition: SystemMatrix.h:326
paso::Options::getPackage
static int getPackage(int solver, int package, bool symmetry, const escript::JMPI &mpi_info)
Definition: Options.cpp:315
escript::DataTypes::DataVectorAlt::data
ElementType * data()
Definition: DataVectorAlt.h:200
MPI_SUM
#define MPI_SUM
Definition: EsysMPI.h:54
paso::SystemMatrix::pattern
SystemMatrixPattern_ptr pattern
Definition: SystemMatrix.h:312
paso::SystemMatrixPattern_ptr
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition: SystemMatrixPattern.h:40
paso::Options::mapEscriptOption
static int mapEscriptOption(int escriptOption)
returns the corresponding paso option code for an escript option code
Definition: Options.cpp:360
MATRIX_FORMAT_COMPLEX
#define MATRIX_FORMAT_COMPLEX
Definition: Paso.h:66
paso::SystemMatrix::col_coupleBlock
SparseMatrix_ptr< T > col_coupleBlock
coupling to neighbouring processors (row - col)
Definition: SystemMatrix.h:331
paso::SystemMatrix::copyRemoteCoupleBlock
void copyRemoteCoupleBlock(bool recreatePattern)
paso::SystemMatrix::finishColCollect
double * finishColCollect() const
Definition: SystemMatrix.h:171
paso::SystemMatrix::applyBalanceInPlace
void applyBalanceInPlace(double *x, bool RHS) const
paso::SystemMatrix::finishCollect
double * finishCollect() const
Definition: SystemMatrix.h:161
paso::SystemMatrix::is_balanced
bool is_balanced
Definition: SystemMatrix.h:337
escript::Data::getDataPointSize
int getDataPointSize() const
Return the size of the data point. It is the product of the data point shape dimensions.
Definition: Data.cpp:1360
paso::SystemMatrix::block_size
dim_t block_size
Definition: SystemMatrix.h:319
paso::SystemMatrix::applyBalance
void applyBalance(double *x_out, const double *x, bool RHS) const
escript::FunctionSpace
Definition: FunctionSpace.h:36
paso::SystemMatrix::mpi_info
escript::JMPI mpi_info
Definition: SystemMatrix.h:323
paso::SystemMatrix::getRowOverlap
dim_t getRowOverlap() const
Definition: SystemMatrix.h:206
escript::Data::getFunctionSpace
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition: Data.h:463
paso::SystemMatrix::remote_coupleBlock
SparseMatrix_ptr< T > remote_coupleBlock
coupling of rows-cols on neighbouring processors (may not be valid)
Definition: SystemMatrix.h:335
PASO_MKL
#define PASO_MKL
Definition: Options.h:50
MATRIX_FORMAT_OFFSET1
#define MATRIX_FORMAT_OFFSET1
Definition: Paso.h:64
SparseMatrix.h
MPI_INT
#define MPI_INT
Definition: EsysMPI.h:48
paso::SystemMatrix::type
SystemMatrixType type
Definition: SystemMatrix.h:311
Options.h
paso::SystemMatrix_ptr
boost::shared_ptr< SystemMatrix< T > > SystemMatrix_ptr
Definition: SystemMatrix.h:42
paso::Pattern
Definition: Pattern.h:44
MPI_MAX
#define MPI_MAX
Definition: EsysMPI.h:56
Solver.h
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
paso::SystemMatrix::makeZeroRowSums
void makeZeroRowSums(double *left_over)
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:66
paso::SystemMatrix::getColOverlap
dim_t getColOverlap() const
Definition: SystemMatrix.h:211
paso::SystemMatrix::startRowCollect
void startRowCollect(const double *in)
Definition: SystemMatrix.h:176
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:74
escript::AbstractSystemMatrix
Base class for escript system matrices.
Definition: AbstractSystemMatrix.h:44
paso::SystemMatrix::startColCollect
void startColCollect(const double *in) const
Definition: SystemMatrix.h:166
paso::Coupler_ptr
boost::shared_ptr< Coupler< T > > Coupler_ptr
Definition: Coupler.h:43
paso::SystemMatrix::loadMM_toCSR
static SystemMatrix_ptr< double > loadMM_toCSR(const char *filename)
SystemMatrixPattern.h
paso::SystemMatrix::getTotalNumCols
dim_t getTotalNumCols() const
Definition: SystemMatrix.h:201
SystemMatrix.h
paso::SystemMatrix::getNumRows
dim_t getNumRows() const
Definition: SystemMatrix.h:186
paso::SystemMatrix::borrowMainDiagonalPointer
index_t * borrowMainDiagonalPointer() const
paso::SystemMatrix::getGlobalNumRows
dim_t getGlobalNumRows() const
Definition: SystemMatrix.h:216
paso::Options::updateEscriptDiagnostics
void updateEscriptDiagnostics(boost::python::object &options) const
updates SolverBuddy diagnostics from this
Definition: Options.cpp:441
paso::SystemMatrix::resetValues
virtual void resetValues(bool preserveSolverData=false)
Definition: SystemMatrix.h:608
paso::SystemMatrix::copyFromMainDiagonal
void copyFromMainDiagonal(double *out) const
Definition: SystemMatrix.h:263
paso::SystemMatrix::row_block_size
dim_t row_block_size
Definition: SystemMatrix.h:317
paso::solve_free
void solve_free(SystemMatrix< T > *A)
Definition: Solver.h:79
paso::Preconditioner_solve
void Preconditioner_solve(Preconditioner *prec, SystemMatrix_ptr< double > A, double *x, double *b)
Definition: Preconditioner.cpp:111
paso::SystemMatrix::ypAx
virtual void ypAx(escript::Data &y, escript::Data &x) const
Definition: SystemMatrix.h:647
paso::SystemMatrix::getNumOutput
dim_t getNumOutput() const
Definition: SystemMatrix.h:248
paso::SystemMatrix::MatrixVector
void MatrixVector(double alpha, const T *in, double beta, T *out) const
PASO_PASO
#define PASO_PASO
Definition: Options.h:56
PASO_UMFPACK
#define PASO_UMFPACK
Definition: Options.h:51
paso::SystemMatrix::mainBlock
SparseMatrix_ptr< T > mainBlock
main block
Definition: SystemMatrix.h:329
paso::SystemMatrix::~SystemMatrix
~SystemMatrix()
Definition: SystemMatrix.h:496
paso::SystemMatrix::col_distribution
escript::Distribution_ptr col_distribution
Definition: SystemMatrix.h:322
paso::SystemMatrix::solver_p
void * solver_p
pointer to data needed by a solver
Definition: SystemMatrix.h:353
paso::SystemMatrix::global_id
index_t * global_id
stores the global ids for all cols in col_coupleBlock
Definition: SystemMatrix.h:347
paso::SystemMatrix::logical_col_block_size
dim_t logical_col_block_size
Definition: SystemMatrix.h:315
paso::SystemMatrix::getSystemMatrixTypeId
static int getSystemMatrixTypeId(int solver, int preconditioner, int package, bool is_complex, bool symmetry, const escript::JMPI &mpi_info)
Definition: SystemMatrix.h:504
paso::SystemMatrix::col_block_size
dim_t col_block_size
Definition: SystemMatrix.h:318
paso::SystemMatrix::mergeMainAndCouple_CSC_OFFSET1
void mergeMainAndCouple_CSC_OFFSET1(index_t **p_ptr, index_t **p_idx, double **p_val) const
MPI_DOUBLE
#define MPI_DOUBLE
Definition: EsysMPI.h:49
paso::SystemMatrix::finishRowCollect
double * finishRowCollect()
Definition: SystemMatrix.h:181
paso::SystemMatrix::logical_row_block_size
dim_t logical_row_block_size
Definition: SystemMatrix.h:314
paso::Preconditioner
Definition: Preconditioner.h:37
paso::PasoException
PasoException exception class.
Definition: PasoException.h:34
paso::SystemMatrix::row_distribution
escript::Distribution_ptr row_distribution
Definition: SystemMatrix.h:321
paso::SystemMatrix::freePreconditioner
void freePreconditioner()
paso::SystemMatrix::rowSum
void rowSum(double *row_sum) const
Definition: SystemMatrix.h:281
paso::SystemMatrixType
int SystemMatrixType
Definition: SystemMatrix.h:45
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:61
paso::SystemMatrix::copyToMainDiagonal
void copyToMainDiagonal(const double *in)
Definition: SystemMatrix.h:268
escript
Definition: AbstractContinuousDomain.cpp:23
paso::SystemMatrix::col_coupler
Coupler_ptr< real_t > col_coupler
Definition: SystemMatrix.h:325
PASO_MUMPS
#define PASO_MUMPS
Definition: Options.h:57
Preconditioner.h
paso::SystemMatrix::add
void add(dim_t, index_t *, dim_t, dim_t, index_t *, dim_t, double *)
paso::SystemMatrix::mergeMainAndCouple
void mergeMainAndCouple(index_t **p_ptr, index_t **p_idx, double **p_val) const
paso::Preconditioner_alloc
Preconditioner * Preconditioner_alloc(SystemMatrix_ptr< double > A, Options *options)
Definition: Preconditioner.cpp:46
paso::SystemMatrix::setValues
void setValues(double value)
Definition: SystemMatrix.h:273
paso::SystemMatrix::startCollect
void startCollect(const double *in) const
Definition: SystemMatrix.h:156
PasoException.h
paso::Pattern_ptr
boost::shared_ptr< Pattern > Pattern_ptr
Definition: Pattern.h:39
paso::SystemMatrix::extendedRowsForST
void extendedRowsForST(dim_t *degree_ST, index_t *offset_ST, index_t *ST)
paso::SystemMatrix::getGlobalTotalNumRows
dim_t getGlobalTotalNumRows() const
Definition: SystemMatrix.h:232
paso::SystemMatrix::fillWithGlobalCoordinates
void fillWithGlobalCoordinates(double f1)
escript::Data::getExpandedVectorReference
DataTypes::RealVectorType & getExpandedVectorReference(DataTypes::real_t dummy=0)
Ensures that the Data is expanded and returns its underlying vector Does not check for exclusive writ...
Definition: Data.cpp:5837
paso::SystemMatrix::setPreconditioner
void setPreconditioner(Options *options)
paso::SystemMatrix::print
void print() const
paso
Definition: BiCGStab.cpp:25
escript::DataTypes::cplx_t
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:55
paso::Preconditioner_free
void Preconditioner_free(Preconditioner *in)
Definition: Preconditioner.cpp:35
paso::SystemMatrix::MatrixVector_CSR_OFFSET0
void MatrixVector_CSR_OFFSET0(double alpha, const double *in, double beta, double *out) const
paso::SystemMatrix::copyMain_CSC_OFFSET1
void copyMain_CSC_OFFSET1(index_t **p_ptr, index_t **p_idx, double **p_val)
escript::Data::expand
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition: Data.cpp:1180
paso::SystemMatrix::solver_package
index_t solver_package
package code controlling the solver pointer
Definition: SystemMatrix.h:350
paso::SystemMatrix::getNumCols
dim_t getNumCols() const
Definition: SystemMatrix.h:191
paso::const_SystemMatrix_ptr
boost::shared_ptr< const SystemMatrix< T > > const_SystemMatrix_ptr
Definition: SystemMatrix.h:43
paso::SystemMatrix::getGlobalSize
double getGlobalSize() const
paso::SystemMatrix::getSparsity
double getSparsity() const
Definition: SystemMatrix.h:242
paso::SparseMatrix
Definition: SparseMatrix.h:45
paso::Options
Definition: Options.h:80
paso::SystemMatrix::SystemMatrix
SystemMatrix()
default constructor - throws exception.
Definition: SystemMatrix.h:393
MATRIX_FORMAT_DEFAULT
#define MATRIX_FORMAT_DEFAULT
Definition: Paso.h:61
paso::SystemMatrix::copyBlockFromMainDiagonal
void copyBlockFromMainDiagonal(double *out) const
Definition: SystemMatrix.h:253
paso::SystemMatrix::mergeSystemMatrix
SparseMatrix_ptr< T > mergeSystemMatrix() const
paso::SystemMatrix::solve
void solve(T *out, T *in, Options *options) const
MATRIX_FORMAT_DIAGONAL_BLOCK
#define MATRIX_FORMAT_DIAGONAL_BLOCK
Definition: Paso.h:65
paso::SystemMatrix::nullifyRows
void nullifyRows(double *mask_row, double main_diagonal_value)