ESYS13
Revision_
|
00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2012 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 00015 /**************************************************************/ 00016 00017 /* Paso: SystemMatrix and SystemVector */ 00018 00019 /**************************************************************/ 00020 00021 /* Copyrights by ACcESS Australia 2003,2004,2005,2006 */ 00022 /* Author: Lutz Gross, l.gross@uq.edu.au */ 00023 00024 /**************************************************************/ 00025 00026 #ifndef INC_PASO_SYSTEMMATRIX 00027 #define INC_PASO_SYSTEMMATRIX 00028 00029 #include "Common.h" 00030 #include "SparseMatrix.h" 00031 #include "SystemMatrixPattern.h" 00032 #include "Options.h" 00033 #include "esysUtils/Esys_MPI.h" 00034 #include "Paso.h" 00035 #include "Coupler.h" 00036 00037 00038 /**************************************************************/ 00039 00040 /* this struct holds a stiffness matrix: */ 00041 00042 typedef int Paso_SystemMatrixType; 00043 00044 typedef struct Paso_SystemMatrix { 00045 Paso_SystemMatrixType type; 00046 Paso_SystemMatrixPattern *pattern; 00047 00048 dim_t reference_counter; 00049 00050 dim_t logical_row_block_size; 00051 dim_t logical_col_block_size; 00052 00053 dim_t row_block_size; 00054 dim_t col_block_size; 00055 dim_t block_size; 00056 00057 Paso_Distribution *row_distribution; 00058 Paso_Distribution *col_distribution; 00059 Esys_MPIInfo *mpi_info; 00060 00061 Paso_Coupler* col_coupler; 00062 Paso_Coupler* row_coupler; 00063 00064 /* this comes into play when PASO is used */ 00065 Paso_SparseMatrix* mainBlock; /* main block */ 00066 Paso_SparseMatrix* col_coupleBlock; /* coupling to neighbouring processors (row - col) */ 00067 Paso_SparseMatrix* row_coupleBlock; /* coupling to neighbouring processors (col - row) */ 00068 Paso_SparseMatrix* remote_coupleBlock; /* coupling of rows-cols on neighbouring processors 00069 don't assume that this is set */ 00070 00071 bool_t is_balanced; 00072 double *balance_vector; /* matrix may be balanced by a diagonal matrix D=diagonal(balance_vector) 00073 if is_balanced is set, the matrix stored is D*A*D where A is the original matrix. 00074 When the system of linear equations is solved we solve D*A*D*y=c. 00075 So to solve A*x=b one needs to set c=D*b and x=D*y. */ 00076 00077 index_t *global_id; /* store the global ids for all cols in col_couplerBlock */ 00078 00079 00080 00081 index_t solver_package; /* package controlling the solver pointer */ 00082 void* solver_p; /* pointer to data needed by a solver */ 00083 00084 /* this is only used for a trilinos matrix */ 00085 void *trilinos_data; 00086 00087 } Paso_SystemMatrix; 00088 00089 /* interfaces: */ 00090 00091 PASO_DLL_API 00092 Paso_SystemMatrix* Paso_SystemMatrix_alloc(Paso_SystemMatrixType,Paso_SystemMatrixPattern*,dim_t,dim_t, const bool_t patternIsUnrolled); 00093 00094 PASO_DLL_API 00095 Paso_SystemMatrix* Paso_SystemMatrix_getReference(Paso_SystemMatrix*); 00096 00097 PASO_DLL_API 00098 void Paso_SystemMatrix_free(Paso_SystemMatrix*); 00099 00100 00101 PASO_DLL_API 00102 void Paso_SystemMatrix_MatrixVector(const double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out); 00103 00104 PASO_DLL_API 00105 void Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(double alpha, Paso_SystemMatrix* A, const double* in, const double beta, double* out); 00106 00107 PASO_DLL_API 00108 void Paso_SystemMatrix_nullifyRowsAndCols(Paso_SystemMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); 00109 00110 PASO_DLL_API 00111 void Paso_SystemMatrix_applyBalanceInPlace(const Paso_SystemMatrix* A, double* x, const bool_t RHS); 00112 00113 PASO_DLL_API 00114 void Paso_SystemMatrix_applyBalance(const Paso_SystemMatrix* A, double* x_out, const double* x, const bool_t RHS); 00115 00116 PASO_DLL_API 00117 void Paso_SystemMatrix_balance(Paso_SystemMatrix* A); 00118 00119 00120 PASO_DLL_API 00121 void Paso_solve(Paso_SystemMatrix* A, double* out, double* in, Paso_Options* options); 00122 00123 PASO_DLL_API 00124 void Paso_solve_free(Paso_SystemMatrix* in); 00125 00126 PASO_DLL_API 00127 void Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A,const double* in); 00128 00129 PASO_DLL_API 00130 double* Paso_SystemMatrix_finishCollect(Paso_SystemMatrix* A); 00131 00132 PASO_DLL_API 00133 void Paso_SystemMatrix_startColCollect(Paso_SystemMatrix* A,const double* in); 00134 00135 PASO_DLL_API 00136 double* Paso_SystemMatrix_finishColCollect(Paso_SystemMatrix* A); 00137 00138 PASO_DLL_API 00139 void Paso_SystemMatrix_startRowCollect(Paso_SystemMatrix* A,const double* in); 00140 00141 PASO_DLL_API 00142 double* Paso_SystemMatrix_finishRowCollect(Paso_SystemMatrix* A); 00143 00144 PASO_DLL_API 00145 dim_t Paso_SystemMatrix_getTotalNumRows(const Paso_SystemMatrix* A); 00146 00147 PASO_DLL_API 00148 dim_t Paso_SystemMatrix_getTotalNumCols(const Paso_SystemMatrix*); 00149 00150 PASO_DLL_API 00151 dim_t Paso_SystemMatrix_getGlobalNumRows(const Paso_SystemMatrix*); 00152 00153 PASO_DLL_API 00154 dim_t Paso_SystemMatrix_getGlobalNumCols(const Paso_SystemMatrix*); 00155 00156 PASO_DLL_API 00157 dim_t Paso_SystemMatrix_getGlobalTotalNumRows(const Paso_SystemMatrix* A); 00158 00159 PASO_DLL_API 00160 dim_t Paso_SystemMatrix_getGlobalTotalNumCols(const Paso_SystemMatrix* A); 00161 00162 PASO_DLL_API 00163 double Paso_SystemMatrix_getGlobalSize(const Paso_SystemMatrix*A); 00164 00165 PASO_DLL_API 00166 double Paso_SystemMatrix_getSparsity(const Paso_SystemMatrix*A); 00167 00168 PASO_DLL_API 00169 dim_t Paso_SystemMatrix_getNumRows(const Paso_SystemMatrix* A); 00170 00171 PASO_DLL_API 00172 dim_t Paso_SystemMatrix_getNumCols(const Paso_SystemMatrix* A); 00173 00174 PASO_DLL_API 00175 dim_t Paso_SystemMatrix_getRowOverlap(const Paso_SystemMatrix* A); 00176 00177 PASO_DLL_API 00178 dim_t Paso_SystemMatrix_getColOverlap(const Paso_SystemMatrix* A); 00179 00180 00181 00182 00183 PASO_DLL_API 00184 void Paso_SystemMatrix_saveMM(Paso_SystemMatrix *, char *); 00185 00186 PASO_DLL_API 00187 void Paso_SystemMatrix_saveHB(Paso_SystemMatrix *, char *); 00188 00189 PASO_DLL_API 00190 Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSR(char *); 00191 00192 PASO_DLL_API 00193 Paso_SystemMatrix* Paso_SystemMatrix_loadMM_toCSC(char *); 00194 00195 PASO_DLL_API 00196 void Paso_RHS_loadMM_toCSR( char *fileName_p, double *b, dim_t size); 00197 00198 00199 PASO_DLL_API 00200 int Paso_SystemMatrix_getSystemMatrixTypeId(const index_t solver,const index_t preconditioner, const index_t package,const bool_t symmetry, Esys_MPIInfo *mpi_info); 00201 00202 PASO_DLL_API 00203 dim_t Paso_SystemMatrix_getNumOutput(Paso_SystemMatrix* A); 00204 00205 00206 PASO_DLL_API 00207 void Paso_SystemMatrix_setValues(Paso_SystemMatrix*,double); 00208 00209 PASO_DLL_API 00210 void Paso_SystemMatrix_add(Paso_SystemMatrix*,dim_t,index_t*, dim_t,dim_t,index_t*,dim_t, double*); 00211 00212 PASO_DLL_API 00213 void Paso_SystemMatrix_rowSum(Paso_SystemMatrix* A, double* row_sum); 00214 00215 PASO_DLL_API 00216 void Paso_SystemMatrix_nullifyRows(Paso_SystemMatrix* A, double* mask_row, double main_diagonal_value); 00217 00218 00219 PASO_DLL_API 00220 void Paso_SystemMatrix_makeZeroRowSums(Paso_SystemMatrix * A_p, double* left_over); 00221 00222 00223 PASO_DLL_API 00224 void Paso_SystemMatrix_copyBlockFromMainDiagonal(Paso_SystemMatrix * A_p, double* out); 00225 00226 PASO_DLL_API 00227 void Paso_SystemMatrix_copyBlockToMainDiagonal(Paso_SystemMatrix * A_p, const double* in); 00228 00229 PASO_DLL_API 00230 void Paso_SystemMatrix_copyFromMainDiagonal(Paso_SystemMatrix * A_p, double* out); 00231 00232 PASO_DLL_API 00233 void Paso_SystemMatrix_copyToMainDiagonal(Paso_SystemMatrix * A_p, const double* in); 00234 00235 00236 PASO_DLL_API 00237 void Paso_SystemMatrix_solvePreconditioner(Paso_SystemMatrix* A,double* x,double* b); 00238 00239 PASO_DLL_API 00240 void Paso_SystemMatrix_setPreconditioner(Paso_SystemMatrix* A,Paso_Options* options); 00241 00242 PASO_DLL_API 00243 void Paso_SystemMatrix_freePreconditioner(Paso_SystemMatrix* A); 00244 00245 PASO_DLL_API 00246 void Paso_SystemMatrix_copyColCoupleBlock(Paso_SystemMatrix *A); 00247 00248 PASO_DLL_API 00249 void Paso_SystemMatrix_copyRemoteCoupleBlock(Paso_SystemMatrix *A, const bool_t recreatePattern); 00250 00251 PASO_DLL_API 00252 void Paso_SystemMatrix_fillWithGlobalCoordinates(Paso_SystemMatrix *A, const double f1); 00253 00254 PASO_DLL_API 00255 void Paso_SystemMatrix_print(Paso_SystemMatrix *A); 00256 00257 00258 PASO_DLL_API 00259 void Paso_SystemMatrix_mergeMainAndCouple(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val); 00260 00261 PASO_DLL_API 00262 void Paso_SystemMatrix_mergeMainAndCouple_CSR_OFFSET0(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val); 00263 void Paso_SystemMatrix_mergeMainAndCouple_CSR_OFFSET0_Block(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val); 00264 00265 PASO_DLL_API 00266 void Paso_SystemMatrix_mergeMainAndCouple_CSC_OFFSET1(Paso_SystemMatrix *A, index_t **p_ptr, index_t **p_idx, double **p_val); 00267 00268 PASO_DLL_API 00269 void Paso_SystemMatrix_copyMain_CSC_OFFSET1(Paso_SystemMatrix* A, index_t** p_ptr, index_t** p_idx, double** p_val); 00270 00271 void Paso_SystemMatrix_extendedRowsForST(Paso_SystemMatrix* A, dim_t* degree_ST, index_t* offset_ST, index_t* ST); 00272 00273 00274 #endif /* #ifndef INC_PASO_SYSTEMMATRIX */ 00275