1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2010 by University of Queensland |
5 |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* http://www.uq.edu.au/esscc |
7 |
* |
8 |
* Primary Business: Queensland, Australia |
9 |
* Licensed under the Open Software License version 3.0 |
10 |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
* |
12 |
*******************************************************/ |
13 |
|
14 |
|
15 |
/**************************************************************/ |
16 |
|
17 |
/* Paso: SystemMatrix and SystemVector */ |
18 |
|
19 |
/**************************************************************/ |
20 |
|
21 |
/* Copyrights by ACcESS Australia 2003,2004,2005,2006 */ |
22 |
/* Author: Lutz Gross, l.gross@uq.edu.au */ |
23 |
|
24 |
/**************************************************************/ |
25 |
|
26 |
#ifndef INC_PASO_SYSTEMMATRIX |
27 |
#define INC_PASO_SYSTEMMATRIX |
28 |
|
29 |
#include "Common.h" |
30 |
#include "SparseMatrix.h" |
31 |
#include "SystemMatrixPattern.h" |
32 |
#include "Options.h" |
33 |
#include "esysUtils/Esys_MPI.h" |
34 |
#include "Paso.h" |
35 |
#include "Coupler.h" |
36 |
|
37 |
|
38 |
/**************************************************************/ |
39 |
|
40 |
/* this struct holds a stiffness matrix: */ |
41 |
|
42 |
#define MATRIX_FORMAT_DEFAULT 0 |
43 |
#define MATRIX_FORMAT_CSC 1 |
44 |
#define MATRIX_FORMAT_SYM 2 |
45 |
#define MATRIX_FORMAT_BLK1 4 |
46 |
#define MATRIX_FORMAT_OFFSET1 8 |
47 |
#define MATRIX_FORMAT_TRILINOS_CRS 16 |
48 |
|
49 |
typedef int Paso_SystemMatrixType; |
50 |
|
51 |
typedef struct Paso_SystemMatrix { |
52 |
Paso_SystemMatrixType type; |
53 |
Paso_SystemMatrixPattern *pattern; |
54 |
|
55 |
dim_t reference_counter; |
56 |
|
57 |
dim_t logical_row_block_size; |
58 |
dim_t logical_col_block_size; |
59 |
|
60 |
dim_t row_block_size; |
61 |
dim_t col_block_size; |
62 |
dim_t block_size; |
63 |
|
64 |
Paso_Distribution *row_distribution; |
65 |
Paso_Distribution *col_distribution; |
66 |
Esys_MPIInfo *mpi_info; |
67 |
|
68 |
Paso_Coupler* col_coupler; |
69 |
Paso_Coupler* row_coupler; |
70 |
|
71 |
/* this comes into play when PASO is used */ |
72 |
Paso_SparseMatrix* mainBlock; /* main block */ |
73 |
Paso_SparseMatrix* col_coupleBlock; /* coupling to naighbouring processors (row - col) */ |
74 |
Paso_SparseMatrix* row_coupleBlock; /* coupling to naighbouring processors (col - row) */ |
75 |
bool_t normalizer_is_valid; |
76 |
double *normalizer; /* vector with a inverse of the absolute row/col sum (set by Solver.c)*/ |
77 |
index_t solver_package; /* package controling the solver pointer */ |
78 |
void* solver_p; /* pointer to data needed by a solver */ |
79 |
|
80 |
/* this is only used for a trilinos matrix */ |
81 |
void *trilinos_data; |
82 |
|
83 |
} Paso_SystemMatrix; |
84 |
|
85 |
/* interfaces: */ |
86 |
|
87 |
Paso_SystemMatrix* Paso_SystemMatrix_alloc(Paso_SystemMatrixType,Paso_SystemMatrixPattern*,dim_t,dim_t, const bool_t patternIsUnrolled); |
88 |
Paso_SystemMatrix* Paso_SystemMatrix_getReference(Paso_SystemMatrix*); |
89 |
void Paso_SystemMatrix_free(Paso_SystemMatrix*); |
90 |
|
91 |
void Paso_SystemMatrix_MatrixVector(const double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out); |
92 |
void Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out); |
93 |
void Paso_solve(Paso_SystemMatrix* A, double* out, double* in, Paso_Options* options); |
94 |
void Paso_solve_free(Paso_SystemMatrix* in); |
95 |
void Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A,const double* in); |
96 |
double* Paso_SystemMatrix_finishCollect(Paso_SystemMatrix* A); |
97 |
void Paso_SystemMatrix_startColCollect(Paso_SystemMatrix* A,const double* in); |
98 |
double* Paso_SystemMatrix_finishColCollect(Paso_SystemMatrix* A); |
99 |
void Paso_SystemMatrix_startRowCollect(Paso_SystemMatrix* A,const double* in); |
100 |
double* Paso_SystemMatrix_finishRowCollect(Paso_SystemMatrix* A); |
101 |
void Paso_SystemMatrix_nullifyRowsAndCols(Paso_SystemMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); |
102 |
double* Paso_SystemMatrix_borrowNormalization(Paso_SystemMatrix* A); |
103 |
dim_t Paso_SystemMatrix_getTotalNumRows(const Paso_SystemMatrix* A); |
104 |
dim_t Paso_SystemMatrix_getTotalNumCols(const Paso_SystemMatrix*); |
105 |
dim_t Paso_SystemMatrix_getGlobalNumRows(Paso_SystemMatrix*); |
106 |
dim_t Paso_SystemMatrix_getGlobalNumCols(Paso_SystemMatrix*); |
107 |
|
108 |
void Paso_SystemMatrix_saveMM(Paso_SystemMatrix *, char *); |
109 |
void Paso_SystemMatrix_saveHB(Paso_SystemMatrix *, char *); |
110 |
Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSR(char *); |
111 |
Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSC(char *); |
112 |
void Paso_RHS_loadMM_toCSR( char *fileName_p, double *b, dim_t size); |
113 |
void Paso_SystemMatrix_setDefaults(Paso_Options*); |
114 |
int Paso_SystemMatrix_getSystemMatrixTypeId(const index_t solver,const index_t preconditioner, const index_t package,const bool_t symmetry, Esys_MPIInfo *mpi_info); |
115 |
dim_t Paso_SystemMatrix_getNumOutput(Paso_SystemMatrix* A); |
116 |
void Paso_SystemMatrix_setValues(Paso_SystemMatrix*,double); |
117 |
void Paso_SystemMatrix_add(Paso_SystemMatrix*,dim_t,index_t*, dim_t,dim_t,index_t*,dim_t, double*); |
118 |
void Paso_SystemMatrix_rowSum(Paso_SystemMatrix* A, double* row_sum); |
119 |
void Paso_SystemMatrix_nullifyRows(Paso_SystemMatrix* A, double* mask_row, double main_diagonal_value); |
120 |
|
121 |
void Paso_SystemMatrix_makeZeroRowSums(Paso_SystemMatrix * A_p, double* left_over); |
122 |
void Paso_SystemMatrix_copyBlockFromMainDiagonal(Paso_SystemMatrix * A_p, double* out); |
123 |
void Paso_SystemMatrix_copyBlockToMainDiagonal(Paso_SystemMatrix * A_p, const double* in); |
124 |
void Paso_SystemMatrix_copyFromMainDiagonal(Paso_SystemMatrix * A_p, double* out); |
125 |
void Paso_SystemMatrix_copyToMainDiagonal(Paso_SystemMatrix * A_p, const double* in); |
126 |
|
127 |
void Paso_SystemMatrix_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b); |
128 |
void Paso_SystemMatrix_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options); |
129 |
void Paso_SystemMatrix_freePreconditioner(Paso_SystemMatrix* A); |
130 |
|
131 |
|
132 |
#endif /* #ifndef INC_PASO_SYSTEMMATRIX */ |
133 |
|