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
38namespace paso {
39
40struct Options;
41template <class T> class SystemMatrix;
42template <typename T> using SystemMatrix_ptr = boost::shared_ptr<SystemMatrix<T> >;
43template <typename T> using const_SystemMatrix_ptr = boost::shared_ptr<const SystemMatrix<T> >;
44
45typedef int SystemMatrixType;
46
48template <class T>
50{
51public:
54
56 dim_t rowBlockSize, dim_t columnBlockSize,
57 bool patternIsUnrolled, const escript::FunctionSpace& rowFS,
58 const escript::FunctionSpace& colFS);
59
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
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
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 {
235 }
236
238 {
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
345
348
351
353 void* solver_p;
354
355private:
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
365void 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
375namespace paso {
376
377template <>
379template <>
381template <>
382void PASO_DLL_API SystemMatrix<double>::MatrixVector(double alpha, const double* in, double beta,
383 double* out) const;
384template <>
385void PASO_DLL_API SystemMatrix<cplx_t>::MatrixVector(double alpha, const cplx_t* in, double beta,
386 cplx_t* out) const;
387template <>
388void PASO_DLL_API SystemMatrix<double>::solve(double* out, double* in, Options* options) const;
389template <>
391
392template <class T>
394{
395 throw PasoException("SystemMatrix: Illegal to generate default SystemMatrix.");
396}
397
403template <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
495template <class T>
497{
498 solve_free(this);
499 delete[] balance_vector;
500 delete[] global_id;
501}
502
503template <class T>
504int 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),
511 symmetry, mpi_info);
512
513 switch(true_package) {
514 case PASO_PASO:
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)
541 return out;
542}
543
544template <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
607template <class T>
608void SystemMatrix<T>::resetValues(bool preserveSolverData)
609{
610 setValues(0.);
611 if (!preserveSolverData)
612 solve_free(this);
613}
614
615template <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
646template <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
#define PASO_MUMPS
Definition Options.h:57
#define PASO_UMFPACK
Definition Options.h:51
#define PASO_PASO
Definition Options.h:56
#define PASO_MKL
Definition Options.h:50
#define MATRIX_FORMAT_BLK1
Definition Paso.h:63
#define MATRIX_FORMAT_DEFAULT
Definition Paso.h:61
#define MATRIX_FORMAT_OFFSET1
Definition Paso.h:64
#define MATRIX_FORMAT_CSC
Definition Paso.h:62
#define MATRIX_FORMAT_DIAGONAL_BLOCK
Definition Paso.h:65
#define MATRIX_FORMAT_COMPLEX
Definition Paso.h:66
Base class for escript system matrices.
Definition AbstractSystemMatrix.h:44
ElementType * data()
Definition DataVectorAlt.h:200
Data represents a collection of datapoints.
Definition Data.h:64
const FunctionSpace & getFunctionSpace() const
Return the function space.
Definition Data.h:463
int getDataPointSize() const
Return the size of the data point. It is the product of the data point shape dimensions.
Definition Data.cpp:1360
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
void expand()
Whatever the current Data type make this into a DataExpanded.
Definition Data.cpp:1180
bool isComplex() const
True if components of this data are stored as complex.
Definition Data.cpp:1160
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
Definition FunctionSpace.h:36
PasoException exception class.
Definition PasoException.h:34
this class holds a (distributed) stiffness matrix
Definition SystemMatrix.h:50
SparseMatrix_ptr< T > col_coupleBlock
coupling to neighbouring processors (row - col)
Definition SystemMatrix.h:331
void print() const
void * solver_p
pointer to data needed by a solver
Definition SystemMatrix.h:353
dim_t getGlobalTotalNumRows() const
Definition SystemMatrix.h:232
SystemMatrixType type
Definition SystemMatrix.h:311
SparseMatrix_ptr< T > row_coupleBlock
coupling to neighbouring processors (col - row)
Definition SystemMatrix.h:333
dim_t getGlobalNumCols() const
Definition SystemMatrix.h:224
escript::Distribution_ptr col_distribution
Definition SystemMatrix.h:322
void copyBlockToMainDiagonal(const double *in)
Definition SystemMatrix.h:258
static SystemMatrix_ptr< double > loadMM_toCSR(const char *filename)
dim_t getColOverlap() const
Definition SystemMatrix.h:211
virtual void saveHB(const std::string &filename) const
writes the matrix to a file using the Harwell-Boeing file format
Definition SystemMatrix.h:82
void applyBalance(double *x_out, const double *x, bool RHS) const
void mergeMainAndCouple_CSR_OFFSET0(index_t **p_ptr, index_t **p_idx, double **p_val) const
static int getSystemMatrixTypeId(int solver, int preconditioner, int package, bool is_complex, bool symmetry, const escript::JMPI &mpi_info)
Definition SystemMatrix.h:504
void copyBlockFromMainDiagonal(double *out) const
Definition SystemMatrix.h:253
void add(dim_t, index_t *, dim_t, dim_t, index_t *, dim_t, double *)
SparseMatrix_ptr< T > mergeSystemMatrix() const
void mergeMainAndCouple_CSR_OFFSET0_Block(index_t **p_ptr, index_t **p_idx, double **p_val) const
void solve(T *out, T *in, Options *options) const
void MatrixVector_CSR_OFFSET0(double alpha, const double *in, double beta, double *out) const
SystemMatrixPattern_ptr pattern
Definition SystemMatrix.h:312
escript::Distribution_ptr row_distribution
Definition SystemMatrix.h:321
static SystemMatrix_ptr< double > loadMM_toCSC(const char *filename)
void extendedRowsForST(dim_t *degree_ST, index_t *offset_ST, index_t *ST)
dim_t getNumCols() const
Definition SystemMatrix.h:191
escript::JMPI mpi_info
Definition SystemMatrix.h:323
SparseMatrix_ptr< T > remote_coupleBlock
coupling of rows-cols on neighbouring processors (may not be valid)
Definition SystemMatrix.h:335
void applyBalanceInPlace(double *x, bool RHS) const
void startColCollect(const double *in) const
Definition SystemMatrix.h:166
void MatrixVector(double alpha, const T *in, double beta, T *out) const
void fillWithGlobalCoordinates(double f1)
dim_t col_block_size
Definition SystemMatrix.h:318
index_t * borrowMainDiagonalPointer() const
index_t solver_package
package code controlling the solver pointer
Definition SystemMatrix.h:350
void nullifyRows(double *mask_row, double main_diagonal_value)
dim_t getGlobalNumRows() const
Definition SystemMatrix.h:216
dim_t getRowOverlap() const
Definition SystemMatrix.h:206
void startCollect(const double *in) const
Definition SystemMatrix.h:156
dim_t logical_row_block_size
Definition SystemMatrix.h:314
void copyFromMainDiagonal(double *out) const
Definition SystemMatrix.h:263
dim_t getGlobalTotalNumCols() const
Definition SystemMatrix.h:237
SystemMatrix()
default constructor - throws exception.
Definition SystemMatrix.h:393
void startRowCollect(const double *in)
Definition SystemMatrix.h:176
dim_t getTotalNumCols() const
Definition SystemMatrix.h:201
dim_t getNumRows() const
Definition SystemMatrix.h:186
SparseMatrix_ptr< T > mainBlock
main block
Definition SystemMatrix.h:329
void copyToMainDiagonal(const double *in)
Definition SystemMatrix.h:268
double getGlobalSize() const
void makeZeroRowSums(double *left_over)
dim_t getNumOutput() const
Definition SystemMatrix.h:248
void mergeMainAndCouple_CSC_OFFSET1(index_t **p_ptr, index_t **p_idx, double **p_val) const
void copyMain_CSC_OFFSET1(index_t **p_ptr, index_t **p_idx, double **p_val)
virtual void ypAx(escript::Data &y, escript::Data &x) const
performs y+=this*x
Definition SystemMatrix.h:647
index_t * global_id
stores the global ids for all cols in col_coupleBlock
Definition SystemMatrix.h:347
double * balance_vector
Definition SystemMatrix.h:344
virtual void resetValues(bool preserveSolverData=false)
resets the matrix entries
Definition SystemMatrix.h:608
~SystemMatrix()
Definition SystemMatrix.h:496
void copyRemoteCoupleBlock(bool recreatePattern)
dim_t row_block_size
Definition SystemMatrix.h:317
void setPreconditioner(Options *options)
dim_t block_size
Definition SystemMatrix.h:319
dim_t getTotalNumRows() const
Definition SystemMatrix.h:196
double * finishColCollect() const
Definition SystemMatrix.h:171
Coupler_ptr< real_t > col_coupler
Definition SystemMatrix.h:325
virtual void setToSolution(escript::Data &out, escript::Data &in, boost::python::object &options) const
solves the linear system this*out=in
Definition SystemMatrix.h:616
virtual void nullifyRowsAndCols(escript::Data &mask_row, escript::Data &mask_col, double main_diagonal_value)
Definition SystemMatrix.h:545
double * finishRowCollect()
Definition SystemMatrix.h:181
dim_t logical_col_block_size
Definition SystemMatrix.h:315
bool is_balanced
Definition SystemMatrix.h:337
double * finishCollect() const
Definition SystemMatrix.h:161
Coupler_ptr< real_t > row_coupler
Definition SystemMatrix.h:326
void rowSum(double *row_sum) const
Definition SystemMatrix.h:281
virtual void saveMM(const std::string &filename) const
writes the matrix to a file using the Matrix Market file format
Definition SystemMatrix.h:70
void solvePreconditioner(double *x, double *b)
void mergeMainAndCouple(index_t **p_ptr, index_t **p_idx, double **p_val) const
void setValues(double value)
Definition SystemMatrix.h:273
double getSparsity() const
Definition SystemMatrix.h:242
std::complex< real_t > cplx_t
complex data type
Definition DataTypes.h:55
double real_t
type of all real-valued scalars in escript
Definition DataTypes.h:52
index_t dim_t
Definition DataTypes.h:66
int index_t
type for array/matrix indices used both globally and on each rank
Definition DataTypes.h:61
Definition AbstractContinuousDomain.cpp:23
boost::shared_ptr< Distribution > Distribution_ptr
Definition Distribution.h:26
boost::shared_ptr< JMPI_ > JMPI
Definition EsysMPI.h:76
Definition BiCGStab.cpp:25
boost::shared_ptr< Coupler< T > > Coupler_ptr
Definition Coupler.h:43
boost::shared_ptr< SystemMatrix< T > > SystemMatrix_ptr
Definition SystemMatrix.h:42
boost::shared_ptr< SystemMatrixPattern > SystemMatrixPattern_ptr
Definition SystemMatrixPattern.h:41
boost::shared_ptr< const SystemMatrix< T > > const_SystemMatrix_ptr
Definition SystemMatrix.h:43
void RHS_loadMM_toCSR(const char *filename, double *b, dim_t size)
Definition SystemMatrix_loadMM.cpp:301
void solve_free(SystemMatrix< T > *A)
Definition Solver.h:79
boost::shared_ptr< SparseMatrix< T > > SparseMatrix_ptr
Definition SparseMatrix.h:37
int SystemMatrixType
Definition SystemMatrix.h:45
#define PASO_DLL_API
Definition paso/src/system_dep.h:29
Definition Coupler.h:100
Definition Options.h:80
static int getPackage(int solver, int package, bool symmetry, const escript::JMPI &mpi_info)
Definition Options.cpp:315
void updateEscriptDiagnostics(boost::python::object &options) const
updates SolverBuddy diagnostics from this
Definition Options.cpp:441
static int mapEscriptOption(int escriptOption)
returns the corresponding paso option code for an escript option code
Definition Options.cpp:360
Definition SparseMatrix.h:45