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

Diff of /trunk/paso/src/SystemMatrix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3258 by gross, Tue Sep 21 06:56:44 2010 UTC revision 3259 by jfenwick, Mon Oct 11 01:48:14 2010 UTC
# Line 42  Paso_SystemMatrix* Paso_SystemMatrix_all Line 42  Paso_SystemMatrix* Paso_SystemMatrix_all
42    bool_t unroll=FALSE;    bool_t unroll=FALSE;
43    
44    pattern_format_out= (type & MATRIX_FORMAT_OFFSET1)? PATTERN_FORMAT_OFFSET1:  PATTERN_FORMAT_DEFAULT;    pattern_format_out= (type & MATRIX_FORMAT_OFFSET1)? PATTERN_FORMAT_OFFSET1:  PATTERN_FORMAT_DEFAULT;
45    Paso_resetError();    Esys_resetError();
46    if (type & MATRIX_FORMAT_SYM) {    if (type & MATRIX_FORMAT_SYM) {
47        Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_alloc: Symmetric matrix patterns are not supported.");        Esys_setError(TYPE_ERROR,"Paso_SystemMatrix_alloc: Symmetric matrix patterns are not supported.");
48        return NULL;        return NULL;
49    }    }
50    if (patternIsUnrolled) {    if (patternIsUnrolled) {
51       if ( ! XNOR(type & MATRIX_FORMAT_OFFSET1, pattern->type & PATTERN_FORMAT_OFFSET1) ) {       if ( ! XNOR(type & MATRIX_FORMAT_OFFSET1, pattern->type & PATTERN_FORMAT_OFFSET1) ) {
52           Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_alloc: requested offset and pattern offset does not match.");           Esys_setError(TYPE_ERROR,"Paso_SystemMatrix_alloc: requested offset and pattern offset does not match.");
53           return NULL;           return NULL;
54       }       }
55    }    }
# Line 65  Paso_SystemMatrix* Paso_SystemMatrix_all Line 65  Paso_SystemMatrix* Paso_SystemMatrix_all
65      ||  ((type & MATRIX_FORMAT_OFFSET1) != ( pattern->type & PATTERN_FORMAT_OFFSET1));      ||  ((type & MATRIX_FORMAT_OFFSET1) != ( pattern->type & PATTERN_FORMAT_OFFSET1));
66        
67    out=MEMALLOC(1,Paso_SystemMatrix);    out=MEMALLOC(1,Paso_SystemMatrix);
68    if (! Paso_checkPtr(out)) {      if (! Esys_checkPtr(out)) {  
69       out->type=type;       out->type=type;
70       out->pattern=NULL;         out->pattern=NULL;  
71       out->row_distribution=NULL;       out->row_distribution=NULL;
72       out->col_distribution=NULL;       out->col_distribution=NULL;
73       out->mpi_info=Paso_MPIInfo_getReference(pattern->mpi_info);       out->mpi_info=Esys_MPIInfo_getReference(pattern->mpi_info);
74       out->row_coupler=NULL;       out->row_coupler=NULL;
75       out->col_coupler=NULL;       out->col_coupler=NULL;
76       out->mainBlock=NULL;       out->mainBlock=NULL;
# Line 100  Paso_SystemMatrix* Paso_SystemMatrix_all Line 100  Paso_SystemMatrix* Paso_SystemMatrix_all
100                out->row_block_size=row_block_size;                out->row_block_size=row_block_size;
101                out->col_block_size=col_block_size;                out->col_block_size=col_block_size;
102           }           }
103           if (Paso_noError()) {           if (Esys_noError()) {
104             out->row_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);             out->row_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);
105             out->col_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);             out->col_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);
106           }           }
# Line 118  Paso_SystemMatrix* Paso_SystemMatrix_all Line 118  Paso_SystemMatrix* Paso_SystemMatrix_all
118                out->row_block_size=row_block_size;                out->row_block_size=row_block_size;
119                out->col_block_size=col_block_size;                out->col_block_size=col_block_size;
120           }           }
121           if (Paso_noError()) {           if (Esys_noError()) {
122                out->row_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);                out->row_distribution=Paso_Distribution_getReference(out->pattern->output_distribution);
123                out->col_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);                out->col_distribution=Paso_Distribution_getReference(out->pattern->input_distribution);
124           }           }
125       }       }
126       if (Paso_noError()) {       if (Esys_noError()) {
127          out->block_size=out->row_block_size*out->col_block_size;          out->block_size=out->row_block_size*out->col_block_size;
128          out->col_coupler=Paso_Coupler_alloc(pattern->col_connector,out->col_block_size);          out->col_coupler=Paso_Coupler_alloc(pattern->col_connector,out->col_block_size);
129          out->row_coupler=Paso_Coupler_alloc(pattern->row_connector,out->row_block_size);          out->row_coupler=Paso_Coupler_alloc(pattern->row_connector,out->row_block_size);
# Line 137  Paso_SystemMatrix* Paso_SystemMatrix_all Line 137  Paso_SystemMatrix* Paso_SystemMatrix_all
137             out->mainBlock=Paso_SparseMatrix_alloc(type,out->pattern->mainPattern,row_block_size,col_block_size,TRUE);             out->mainBlock=Paso_SparseMatrix_alloc(type,out->pattern->mainPattern,row_block_size,col_block_size,TRUE);
138             out->col_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->col_couplePattern,row_block_size,col_block_size,TRUE);             out->col_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->col_couplePattern,row_block_size,col_block_size,TRUE);
139             out->row_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->row_couplePattern,row_block_size,col_block_size,TRUE);             out->row_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->row_couplePattern,row_block_size,col_block_size,TRUE);
140             if (Paso_noError()) {             if (Esys_noError()) {
141                /* allocate memory for matrix entries */                /* allocate memory for matrix entries */
142                if (type & MATRIX_FORMAT_CSC) {                if (type & MATRIX_FORMAT_CSC) {
143                   n_norm = out->mainBlock->numCols * out->col_block_size;                   n_norm = out->mainBlock->numCols * out->col_block_size;
# Line 146  Paso_SystemMatrix* Paso_SystemMatrix_all Line 146  Paso_SystemMatrix* Paso_SystemMatrix_all
146                }                }
147                out->normalizer=MEMALLOC(n_norm,double);                out->normalizer=MEMALLOC(n_norm,double);
148                out->normalizer_is_valid=FALSE;                out->normalizer_is_valid=FALSE;
149                if (! Paso_checkPtr(out->normalizer)) {                if (! Esys_checkPtr(out->normalizer)) {
150                   #pragma omp parallel for private(i) schedule(static)                   #pragma omp parallel for private(i) schedule(static)
151                   for (i=0;i<n_norm;++i) out->normalizer[i]=0.;                   for (i=0;i<n_norm;++i) out->normalizer[i]=0.;
152                }                }
# Line 155  Paso_SystemMatrix* Paso_SystemMatrix_all Line 155  Paso_SystemMatrix* Paso_SystemMatrix_all
155       }       }
156    }    }
157    /* all done: */    /* all done: */
158    if (! Paso_noError()) {    if (! Esys_noError()) {
159      Paso_SystemMatrix_free(out);      Paso_SystemMatrix_free(out);
160      return NULL;      return NULL;
161    } else {    } else {
# Line 179  void Paso_SystemMatrix_free(Paso_SystemM Line 179  void Paso_SystemMatrix_free(Paso_SystemM
179          Paso_SystemMatrixPattern_free(in->pattern);          Paso_SystemMatrixPattern_free(in->pattern);
180          Paso_Distribution_free(in->row_distribution);          Paso_Distribution_free(in->row_distribution);
181          Paso_Distribution_free(in->col_distribution);          Paso_Distribution_free(in->col_distribution);
182          Paso_MPIInfo_free(in->mpi_info);          Esys_MPIInfo_free(in->mpi_info);
183          Paso_Coupler_free(in->row_coupler);          Paso_Coupler_free(in->row_coupler);
184          Paso_Coupler_free(in->col_coupler);          Paso_Coupler_free(in->col_coupler);
185          Paso_SparseMatrix_free(in->mainBlock);          Paso_SparseMatrix_free(in->mainBlock);
# Line 257  index_t* Paso_SystemMatrix_borrowMainDia Line 257  index_t* Paso_SystemMatrix_borrowMainDia
257      int fail=0;      int fail=0;
258      out=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p->mainBlock);      out=Paso_SparseMatrix_borrowMainDiagonalPointer(A_p->mainBlock);
259      if (out==NULL) fail=1;      if (out==NULL) fail=1;
260      #ifdef PASO_MPI      #ifdef ESYS_MPI
261      {      {
262           int fail_loc = fail;           int fail_loc = fail;
263           MPI_Allreduce(&fail_loc, &fail, 1, MPI_INT, MPI_MAX, A_p->mpi_info->comm);           MPI_Allreduce(&fail_loc, &fail, 1, MPI_INT, MPI_MAX, A_p->mpi_info->comm);
264      }      }
265      #endif      #endif
266      if (fail>0) Paso_setError(VALUE_ERROR, "Paso_SystemMatrix_borrowMainDiagonalPointer: no main diagonal");      if (fail>0) Esys_setError(VALUE_ERROR, "Paso_SystemMatrix_borrowMainDiagonalPointer: no main diagonal");
267      return out;      return out;
268  }  }
269    

Legend:
Removed from v.3258  
changed lines
  Added in v.3259

  ViewVC Help
Powered by ViewVC 1.1.26