/[escript]/trunk/paso/src/SystemMatrix.h
ViewVC logotype

Contents of /trunk/paso/src/SystemMatrix.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4829 - (show annotations)
Thu Apr 3 04:02:53 2014 UTC (5 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 8602 byte(s)
checkpointing some SparseMatrix cleanup.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 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 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************/
19
20 /* Paso: SystemMatrix and SystemVector */
21
22 /****************************************************************************/
23
24 /* Copyrights by ACcESS Australia 2003,2004,2005,2006 */
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #ifndef INC_PASO_SYSTEMMATRIX
30 #define INC_PASO_SYSTEMMATRIX
31
32 #include "Common.h"
33 #include "SparseMatrix.h"
34 #include "SystemMatrixPattern.h"
35 #include "Options.h"
36 #include "esysUtils/Esys_MPI.h"
37 #include "Paso.h"
38 #include "Coupler.h"
39
40
41 typedef int Paso_SystemMatrixType;
42
43 // this struct holds a stiffness matrix
44 struct Paso_SystemMatrix
45 {
46 Paso_SystemMatrixType type;
47 paso::SystemMatrixPattern_ptr pattern;
48
49 dim_t reference_counter;
50
51 dim_t logical_row_block_size;
52 dim_t logical_col_block_size;
53
54 dim_t row_block_size;
55 dim_t col_block_size;
56 dim_t block_size;
57
58 paso::Distribution_ptr row_distribution;
59 paso::Distribution_ptr col_distribution;
60 Esys_MPIInfo *mpi_info;
61
62 paso::Coupler_ptr col_coupler;
63 paso::Coupler_ptr row_coupler;
64
65 /* this comes into play when PASO is used */
66 /// main block
67 paso::SparseMatrix_ptr mainBlock;
68 /// coupling to neighbouring processors (row - col)
69 paso::SparseMatrix_ptr col_coupleBlock;
70 /// coupling to neighbouring processors (col - row)
71 paso::SparseMatrix_ptr row_coupleBlock;
72 /// coupling of rows-cols on neighbouring processors,
73 /// don't assume that this is set
74 paso::SparseMatrix_ptr remote_coupleBlock;
75
76 bool is_balanced;
77 double *balance_vector; /* matrix may be balanced by a diagonal matrix D=diagonal(balance_vector)
78 if is_balanced is set, the matrix stored is D*A*D where A is the original matrix.
79 When the system of linear equations is solved we solve D*A*D*y=c.
80 So to solve A*x=b one needs to set c=D*b and x=D*y. */
81
82 index_t *global_id; /* store the global ids for all cols in col_couplerBlock */
83
84
85
86 index_t solver_package; /* package controlling the solver pointer */
87 void* solver_p; /* pointer to data needed by a solver */
88
89 /* this is only used for a trilinos matrix */
90 void *trilinos_data;
91 };
92
93 /* interfaces: */
94
95 PASO_DLL_API
96 Paso_SystemMatrix* Paso_SystemMatrix_alloc(Paso_SystemMatrixType, paso::SystemMatrixPattern_ptr, dim_t, dim_t, bool patternIsUnrolled);
97
98 PASO_DLL_API
99 Paso_SystemMatrix* Paso_SystemMatrix_getReference(Paso_SystemMatrix*);
100
101 PASO_DLL_API
102 void Paso_SystemMatrix_free(Paso_SystemMatrix*);
103
104
105 PASO_DLL_API
106 void Paso_SystemMatrix_MatrixVector(const double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out);
107
108 PASO_DLL_API
109 void Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out);
110
111 PASO_DLL_API
112 void Paso_SystemMatrix_nullifyRowsAndCols(Paso_SystemMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
113
114 PASO_DLL_API
115 void Paso_SystemMatrix_applyBalanceInPlace(const Paso_SystemMatrix* A, double* x, const bool RHS);
116
117 PASO_DLL_API
118 void Paso_SystemMatrix_applyBalance(const Paso_SystemMatrix* A, double* x_out, const double* x, const bool RHS);
119
120 PASO_DLL_API
121 void Paso_SystemMatrix_balance(Paso_SystemMatrix* A);
122
123
124 PASO_DLL_API
125 void Paso_solve(Paso_SystemMatrix* A, double* out, double* in, Paso_Options* options);
126
127 PASO_DLL_API
128 void Paso_solve_free(Paso_SystemMatrix* in);
129
130 PASO_DLL_API
131 void Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A,const double* in);
132
133 PASO_DLL_API
134 double* Paso_SystemMatrix_finishCollect(Paso_SystemMatrix* A);
135
136 PASO_DLL_API
137 void Paso_SystemMatrix_startColCollect(Paso_SystemMatrix* A,const double* in);
138
139 PASO_DLL_API
140 double* Paso_SystemMatrix_finishColCollect(Paso_SystemMatrix* A);
141
142 PASO_DLL_API
143 void Paso_SystemMatrix_startRowCollect(Paso_SystemMatrix* A,const double* in);
144
145 PASO_DLL_API
146 double* Paso_SystemMatrix_finishRowCollect(Paso_SystemMatrix* A);
147
148 PASO_DLL_API
149 dim_t Paso_SystemMatrix_getTotalNumRows(const Paso_SystemMatrix* A);
150
151 PASO_DLL_API
152 dim_t Paso_SystemMatrix_getTotalNumCols(const Paso_SystemMatrix*);
153
154 PASO_DLL_API
155 dim_t Paso_SystemMatrix_getGlobalNumRows(const Paso_SystemMatrix*);
156
157 PASO_DLL_API
158 dim_t Paso_SystemMatrix_getGlobalNumCols(const Paso_SystemMatrix*);
159
160 PASO_DLL_API
161 dim_t Paso_SystemMatrix_getGlobalTotalNumRows(const Paso_SystemMatrix* A);
162
163 PASO_DLL_API
164 dim_t Paso_SystemMatrix_getGlobalTotalNumCols(const Paso_SystemMatrix* A);
165
166 PASO_DLL_API
167 double Paso_SystemMatrix_getGlobalSize(const Paso_SystemMatrix*A);
168
169 PASO_DLL_API
170 double Paso_SystemMatrix_getSparsity(const Paso_SystemMatrix*A);
171
172 PASO_DLL_API
173 dim_t Paso_SystemMatrix_getNumRows(const Paso_SystemMatrix* A);
174
175 PASO_DLL_API
176 dim_t Paso_SystemMatrix_getNumCols(const Paso_SystemMatrix* A);
177
178 PASO_DLL_API
179 dim_t Paso_SystemMatrix_getRowOverlap(const Paso_SystemMatrix* A);
180
181 PASO_DLL_API
182 dim_t Paso_SystemMatrix_getColOverlap(const Paso_SystemMatrix* A);
183
184
185
186
187 PASO_DLL_API
188 void Paso_SystemMatrix_saveMM(Paso_SystemMatrix *, char *);
189
190 PASO_DLL_API
191 void Paso_SystemMatrix_saveHB(Paso_SystemMatrix *, char *);
192
193 PASO_DLL_API
194 Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSR(char *);
195
196 PASO_DLL_API
197 Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSC(char *);
198
199 PASO_DLL_API
200 void Paso_RHS_loadMM_toCSR( char *fileName_p, double *b, dim_t size);
201
202
203 PASO_DLL_API
204 int Paso_SystemMatrix_getSystemMatrixTypeId(const index_t solver,const index_t preconditioner, const index_t package,const bool symmetry, Esys_MPIInfo *mpi_info);
205
206 PASO_DLL_API
207 dim_t Paso_SystemMatrix_getNumOutput(Paso_SystemMatrix* A);
208
209
210 PASO_DLL_API
211 void Paso_SystemMatrix_setValues(Paso_SystemMatrix*,double);
212
213 PASO_DLL_API
214 void Paso_SystemMatrix_add(Paso_SystemMatrix*,dim_t,index_t*, dim_t,dim_t,index_t*,dim_t, double*);
215
216 PASO_DLL_API
217 void Paso_SystemMatrix_rowSum(Paso_SystemMatrix* A, double* row_sum);
218
219 PASO_DLL_API
220 void Paso_SystemMatrix_nullifyRows(Paso_SystemMatrix* A, double* mask_row, double main_diagonal_value);
221
222
223 PASO_DLL_API
224 void Paso_SystemMatrix_makeZeroRowSums(Paso_SystemMatrix * A_p, double* left_over);
225
226
227 PASO_DLL_API
228 void Paso_SystemMatrix_copyBlockFromMainDiagonal(Paso_SystemMatrix * A_p, double* out);
229
230 PASO_DLL_API
231 void Paso_SystemMatrix_copyBlockToMainDiagonal(Paso_SystemMatrix * A_p, const double* in);
232
233 PASO_DLL_API
234 void Paso_SystemMatrix_copyFromMainDiagonal(Paso_SystemMatrix * A_p, double* out);
235
236 PASO_DLL_API
237 void Paso_SystemMatrix_copyToMainDiagonal(Paso_SystemMatrix * A_p, const double* in);
238
239
240 PASO_DLL_API
241 void Paso_SystemMatrix_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b);
242
243 PASO_DLL_API
244 void Paso_SystemMatrix_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options);
245
246 PASO_DLL_API
247 void Paso_SystemMatrix_freePreconditioner(Paso_SystemMatrix* A);
248
249 PASO_DLL_API
250 void Paso_SystemMatrix_copyColCoupleBlock(Paso_SystemMatrix *A);
251
252 PASO_DLL_API
253 void Paso_SystemMatrix_copyRemoteCoupleBlock(Paso_SystemMatrix *A, bool recreatePattern);
254
255 PASO_DLL_API
256 void Paso_SystemMatrix_fillWithGlobalCoordinates(Paso_SystemMatrix *A, const double f1);
257
258 PASO_DLL_API
259 void Paso_SystemMatrix_print(Paso_SystemMatrix *A);
260
261
262 PASO_DLL_API
263 void Paso_SystemMatrix_mergeMainAndCouple(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val);
264
265 PASO_DLL_API
266 void Paso_SystemMatrix_mergeMainAndCouple_CSR_OFFSET0(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val);
267 void Paso_SystemMatrix_mergeMainAndCouple_CSR_OFFSET0_Block(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val);
268
269 PASO_DLL_API
270 void Paso_SystemMatrix_mergeMainAndCouple_CSC_OFFSET1(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val);
271
272 PASO_DLL_API
273 void Paso_SystemMatrix_copyMain_CSC_OFFSET1(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val);
274
275 void Paso_SystemMatrix_extendedRowsForST(Paso_SystemMatrix* A, dim_t* degree_ST, index_t* offset_ST, index_t* ST);
276
277
278 #endif /* #ifndef INC_PASO_SYSTEMMATRIX */
279

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26