/[escript]/trunk-mpi-branch/paso/src/SystemMatrix.c
ViewVC logotype

Annotation of /trunk-mpi-branch/paso/src/SystemMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (hide annotations)
Thu Mar 8 06:31:28 2007 UTC (14 years, 6 months ago) by gross
File MIME type: text/plain
File size: 8099 byte(s)
MPI version compiles and starts to run now. 
Important:

   * the mpi library needs to be shared.
   * the path needs to be added to LD_LIBRARY path.

The program stucks in the matrix assemblage.


1 jgs 150 /* $Id$ */
2    
3 dhawcroft 631
4     /*
5     ********************************************************************************
6 dhawcroft 633 * Copyright 2006 by ACcESS MNRF *
7 dhawcroft 631 * *
8     * http://www.access.edu.au *
9     * Primary Business: Queensland, Australia *
10     * Licensed under the Open Software License version 3.0 *
11     * http://www.opensource.org/licenses/osl-3.0.php *
12     ********************************************************************************
13     */
14    
15 jgs 150 /**************************************************************/
16    
17     /* Paso: SystemMatrix */
18    
19     /**************************************************************/
20    
21     /* Copyrights by ACcESS Australia 2003, 2004,2005 */
22     /* Author: gross@access.edu.au */
23    
24     /**************************************************************/
25    
26     #include "Paso.h"
27 gross 1011 #include "Paso_MPI.h"
28 jgs 150 #include "SystemMatrix.h"
29 gross 1011 #include "TRILINOS.h"
30 jgs 150
31     /**************************************************************/
32    
33     /* allocates a SystemMatrix of type type using the given matrix pattern
34     if type is UNKOWN CSR is used.
35     if CSC or CSC_BLK1 is used pattern has to give the CSC pattern.
36     if CSR or CSR_BLK1 is used pattern has to give the CSR pattern.
37     Values are initialized by zero. */
38    
39     Paso_SystemMatrix* Paso_SystemMatrix_alloc(Paso_SystemMatrixType type,Paso_SystemMatrixPattern *pattern, int row_block_size, int col_block_size) {
40 gross 432
41 jgs 150 double time0;
42     Paso_SystemMatrix*out=NULL;
43     Paso_resetError();
44     time0=Paso_timer();
45     dim_t n_norm,i;
46     out=MEMALLOC(1,Paso_SystemMatrix);
47     if (! Paso_checkPtr(out)) {
48     out->pattern=NULL;
49 gross 425 out->solver_package=PASO_PASO;
50     out->solver=NULL;
51 jgs 150 out->val=NULL;
52 gross 1011 out->trilinos_data=NULL;
53 jgs 150 out->reference_counter=1;
54 gross 415 out->type=type;
55 gross 1011 /* ====== compressed sparse columns === */
56 gross 415 if (type & MATRIX_FORMAT_CSC) {
57     if (type & MATRIX_FORMAT_SYM) {
58     Paso_setError(TYPE_ERROR,"Generation of matrix pattern for symmetric CSC is not implemented yet.");
59     return NULL;
60     } else {
61 gross 425 if ((type & MATRIX_FORMAT_BLK1) || row_block_size!=col_block_size || col_block_size>3) {
62 gross 415 if (type & MATRIX_FORMAT_OFFSET1) {
63     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,PATTERN_FORMAT_OFFSET1,col_block_size,row_block_size);
64     } else {
65     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,PATTERN_FORMAT_DEFAULT,col_block_size,row_block_size);
66     }
67 jgs 150 out->row_block_size=1;
68     out->col_block_size=1;
69 gross 415 } else {
70     if ( (type & MATRIX_FORMAT_OFFSET1) ==(pattern->type & PATTERN_FORMAT_OFFSET1)) {
71     out->pattern=Paso_SystemMatrixPattern_reference(pattern);
72     } else {
73     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,(type & MATRIX_FORMAT_OFFSET1)? PATTERN_FORMAT_OFFSET1: PATTERN_FORMAT_DEFAULT,1,1);
74     }
75 jgs 150 out->row_block_size=row_block_size;
76     out->col_block_size=col_block_size;
77 gross 415 }
78     }
79 gross 1011 out->row_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);
80     out->col_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);
81 gross 415 } else {
82 gross 1011 /* ====== compressed sparse row === */
83 gross 415 if (type & MATRIX_FORMAT_SYM) {
84     Paso_setError(TYPE_ERROR,"Generation of matrix pattern for symmetric CSR is not implemented yet.");
85     return NULL;
86     } else {
87 gross 425 if ((type & MATRIX_FORMAT_BLK1) || row_block_size!=col_block_size || col_block_size>3) {
88 gross 415 if (type & MATRIX_FORMAT_OFFSET1) {
89     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,PATTERN_FORMAT_OFFSET1,row_block_size,col_block_size);
90     } else {
91     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,PATTERN_FORMAT_DEFAULT,row_block_size,col_block_size);
92     }
93     out->row_block_size=1;
94     out->col_block_size=1;
95     } else {
96     if ((type & MATRIX_FORMAT_OFFSET1)==(pattern->type & PATTERN_FORMAT_OFFSET1)) {
97     out->pattern=Paso_SystemMatrixPattern_reference(pattern);
98     } else {
99     out->pattern=Paso_SystemMatrixPattern_unrollBlocks(pattern,(type & MATRIX_FORMAT_OFFSET1)? PATTERN_FORMAT_OFFSET1: PATTERN_FORMAT_DEFAULT,1,1);
100     }
101     out->row_block_size=row_block_size;
102     out->col_block_size=col_block_size;
103     }
104     }
105 gross 1011 out->row_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);
106     out->col_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);
107 jgs 150 }
108     out->logical_row_block_size=row_block_size;
109     out->logical_col_block_size=col_block_size;
110     out->logical_block_size=out->logical_row_block_size*out->logical_block_size;
111     out->block_size=out->row_block_size*out->col_block_size;
112 gross 1011 out->myLen=(size_t)(out->pattern->myLen)*(size_t)(out->block_size);
113    
114     out->numRows = out->row_distribution->myNumComponents;
115     out->myNumRows = out->row_distribution->numComponents;
116     out->numCols = out->col_distribution->myNumComponents;
117     out->myNumCols = out->col_distribution->numComponents;
118     out->mpi_info = Paso_MPIInfo_getReference(out->pattern->mpi_info);
119 jgs 150 /* allocate memory for matrix entries */
120 gross 1011 if (type & MATRIX_FORMAT_TRILINOS_CRS) {
121     Paso_TRILINOS_alloc(out->trilinos_data, out->pattern,out->row_block_size,out->col_block_size);
122     } else {
123     if (type & MATRIX_FORMAT_CSC) {
124     n_norm = out->myNumCols * out->col_block_size;
125     } else {
126     n_norm = out->myNumRows * out->row_block_size;
127     }
128     out->val=MEMALLOC(out->myLen,double);
129     out->normalizer=MEMALLOC(n_norm,double);
130     out->normalizer_is_valid=FALSE;
131     if (! Paso_checkPtr(out->val)) Paso_SystemMatrix_setValues(out,DBLE(0));
132     if (! Paso_checkPtr(out->normalizer)) {
133     #pragma omp parallel for private(i) schedule(static)
134     for (i=0;i<n_norm;++i) out->normalizer[i]=0.;
135     }
136 jgs 150 }
137     }
138     /* all done: */
139     if (! Paso_noError()) {
140     Paso_SystemMatrix_dealloc(out);
141     return NULL;
142     } else {
143     #ifdef Paso_TRACE
144     printf("timing: system matrix %.4e sec\n",Paso_timer()-time0);
145 gross 1011 printf("Paso_SystemMatrix_alloc: %ld x %ld system matrix has been allocated.\n",(long)out->numRows,(long)out->numCols);
146 jgs 150 #endif
147     return out;
148     }
149     }
150    
151     /* returns a reference to Paso_SystemMatrix in */
152    
153     Paso_SystemMatrix* Paso_SystemMatrix_reference(Paso_SystemMatrix* in) {
154     if (in!=NULL) ++(in->reference_counter);
155     return NULL;
156     }
157    
158     /* deallocates a SystemMatrix: */
159    
160     void Paso_SystemMatrix_dealloc(Paso_SystemMatrix* in) {
161     if (in!=NULL) {
162     in->reference_counter--;
163     if (in->reference_counter<=0) {
164 gross 1011 Paso_SystemMatrixPattern_dealloc(in->pattern);
165 gross 1016 Paso_Distribution_free(in->row_distribution);
166     Paso_Distribution_free(in->col_distribution);
167 gross 1011 Paso_MPIInfo_dealloc(in->mpi_info);
168 jgs 150 MEMFREE(in->val);
169     MEMFREE(in->normalizer);
170 gross 1011 Paso_TRILINOS_free(in->trilinos_data);
171 jgs 150 Paso_solve_free(in);
172     MEMFREE(in);
173     #ifdef Paso_TRACE
174     printf("Paso_SystemMatrix_dealloc: system matrix as been deallocated.\n");
175     #endif
176     }
177     }
178     }
179     /*
180     * $Log$
181     * Revision 1.2 2005/09/15 03:44:38 jgs
182     * Merge of development branch dev-02 back to main trunk on 2005-09-15
183     *
184     * Revision 1.1.2.2 2005/09/07 00:59:08 gross
185     * some inconsistent renaming fixed to make the linking work.
186     *
187     * Revision 1.1.2.1 2005/09/05 06:29:47 gross
188     * These files have been extracted from finley to define a stand alone libray for iterative
189     * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
190     * has not been tested yet.
191     *
192     *
193     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26