ESScript  Revision_4488
SystemMatrix.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 
17 /************************************************************************************/
18 
19 /* Paso: SystemMatrix and SystemVector */
20 
21 /************************************************************************************/
22 
23 /* Copyrights by ACcESS Australia 2003,2004,2005,2006 */
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25 
26 /************************************************************************************/
27 
28 #ifndef INC_PASO_SYSTEMMATRIX
29 #define INC_PASO_SYSTEMMATRIX
30 
31 #include "Common.h"
32 #include "SparseMatrix.h"
33 #include "SystemMatrixPattern.h"
34 #include "Options.h"
35 #include "esysUtils/Esys_MPI.h"
36 #include "Paso.h"
37 #include "Coupler.h"
38 
39 
40 /************************************************************************************/
41 
42 /* this struct holds a stiffness matrix: */
43 
45 
46 typedef struct Paso_SystemMatrix {
49 
51 
54 
58 
62 
65 
66  /* this comes into play when PASO is used */
67  Paso_SparseMatrix* mainBlock; /* main block */
68  Paso_SparseMatrix* col_coupleBlock; /* coupling to neighbouring processors (row - col) */
69  Paso_SparseMatrix* row_coupleBlock; /* coupling to neighbouring processors (col - row) */
70  Paso_SparseMatrix* remote_coupleBlock; /* coupling of rows-cols on neighbouring processors
71  don't assume that this is set */
72 
74  double *balance_vector; /* matrix may be balanced by a diagonal matrix D=diagonal(balance_vector)
75  if is_balanced is set, the matrix stored is D*A*D where A is the original matrix.
76  When the system of linear equations is solved we solve D*A*D*y=c.
77  So to solve A*x=b one needs to set c=D*b and x=D*y. */
78 
79  index_t *global_id; /* store the global ids for all cols in col_couplerBlock */
80 
81 
82 
83  index_t solver_package; /* package controlling the solver pointer */
84  void* solver_p; /* pointer to data needed by a solver */
85 
86  /* this is only used for a trilinos matrix */
87  void *trilinos_data;
88 
90 
91 /* interfaces: */
92 
95 
98 
101 
102 
104 void Paso_SystemMatrix_MatrixVector(const double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out);
105 
107 void Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out);
108 
110 void Paso_SystemMatrix_nullifyRowsAndCols(Paso_SystemMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
111 
113 void Paso_SystemMatrix_applyBalanceInPlace(const Paso_SystemMatrix* A, double* x, const bool_t RHS);
114 
116 void Paso_SystemMatrix_applyBalance(const Paso_SystemMatrix* A, double* x_out, const double* x, const bool_t RHS);
117 
120 
121 
123 void Paso_solve(Paso_SystemMatrix* A, double* out, double* in, Paso_Options* options);
124 
127 
129 void Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A,const double* in);
130 
133 
135 void Paso_SystemMatrix_startColCollect(Paso_SystemMatrix* A,const double* in);
136 
139 
141 void Paso_SystemMatrix_startRowCollect(Paso_SystemMatrix* A,const double* in);
142 
145 
148 
151 
154 
157 
160 
163 
166 
169 
172 
175 
178 
181 
182 
183 
184 
187 
190 
193 
196 
198 void Paso_RHS_loadMM_toCSR( char *fileName_p, double *b, dim_t size);
199 
200 
202 int Paso_SystemMatrix_getSystemMatrixTypeId(const index_t solver,const index_t preconditioner, const index_t package,const bool_t symmetry, Esys_MPIInfo *mpi_info);
203 
206 
207 
210 
213 
215 void Paso_SystemMatrix_rowSum(Paso_SystemMatrix* A, double* row_sum);
216 
218 void Paso_SystemMatrix_nullifyRows(Paso_SystemMatrix* A, double* mask_row, double main_diagonal_value);
219 
220 
222 void Paso_SystemMatrix_makeZeroRowSums(Paso_SystemMatrix * A_p, double* left_over);
223 
224 
227 
229 void Paso_SystemMatrix_copyBlockToMainDiagonal(Paso_SystemMatrix * A_p, const double* in);
230 
233 
235 void Paso_SystemMatrix_copyToMainDiagonal(Paso_SystemMatrix * A_p, const double* in);
236 
237 
239 void Paso_SystemMatrix_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b);
240 
243 
246 
249 
252 
255 
258 
259 
261 void Paso_SystemMatrix_mergeMainAndCouple(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val);
262 
264 void Paso_SystemMatrix_mergeMainAndCouple_CSR_OFFSET0(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val);
266 
268 void Paso_SystemMatrix_mergeMainAndCouple_CSC_OFFSET1(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val);
269 
271 void Paso_SystemMatrix_copyMain_CSC_OFFSET1(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val);
272 
273 void Paso_SystemMatrix_extendedRowsForST(Paso_SystemMatrix* A, dim_t* degree_ST, index_t* offset_ST, index_t* ST);
274 
275 
276 #endif /* #ifndef INC_PASO_SYSTEMMATRIX */
277