/[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 1361 by gross, Fri Dec 14 09:26:51 2007 UTC revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2009 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  /**************************************************************/  /**************************************************************/
16    
# Line 49  Paso_SystemMatrix* Paso_SystemMatrix_all Line 48  Paso_SystemMatrix* Paso_SystemMatrix_all
48       out->row_distribution=NULL;       out->row_distribution=NULL;
49       out->col_distribution=NULL;       out->col_distribution=NULL;
50       out->mpi_info=Paso_MPIInfo_getReference(pattern->mpi_info);       out->mpi_info=Paso_MPIInfo_getReference(pattern->mpi_info);
51         out->row_coupler=NULL;
52         out->col_coupler=NULL;
53       out->mainBlock=NULL;       out->mainBlock=NULL;
54       out->coupleBlock=NULL;       out->row_coupleBlock=NULL;
55         out->col_coupleBlock=NULL;
56       out->normalizer_is_valid=FALSE;       out->normalizer_is_valid=FALSE;
57       out->normalizer=NULL;       out->normalizer=NULL;
58       out->solver_package=PASO_PASO;         out->solver_package=PASO_PASO;  
# Line 58  Paso_SystemMatrix* Paso_SystemMatrix_all Line 60  Paso_SystemMatrix* Paso_SystemMatrix_all
60       out->trilinos_data=NULL;       out->trilinos_data=NULL;
61       out->reference_counter=1;       out->reference_counter=1;
62    
63    
64       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;
65       /* ====== compressed sparse columns === */       /* ====== compressed sparse columns === */
66       if (type & MATRIX_FORMAT_CSC) {       if (type & MATRIX_FORMAT_CSC) {
# Line 96  Paso_SystemMatrix* Paso_SystemMatrix_all Line 99  Paso_SystemMatrix* Paso_SystemMatrix_all
99       }       }
100       out->logical_row_block_size=row_block_size;       out->logical_row_block_size=row_block_size;
101       out->logical_col_block_size=col_block_size;       out->logical_col_block_size=col_block_size;
102       out->logical_block_size=out->logical_row_block_size*out->logical_block_size;       out->logical_block_size=out->logical_row_block_size*out->logical_col_block_size;
103       out->block_size=out->row_block_size*out->col_block_size;       out->block_size=out->row_block_size*out->col_block_size;
104         out->col_coupler=Paso_Coupler_alloc(pattern->col_connector,out->col_block_size);
105         out->row_coupler=Paso_Coupler_alloc(pattern->row_connector,out->row_block_size);
106       /* this should be bypassed if trilinos is used */       /* this should be bypassed if trilinos is used */
107       if (type & MATRIX_FORMAT_TRILINOS_CRS) {       if (type & MATRIX_FORMAT_TRILINOS_CRS) {
108          #ifdef TRILINOS          #ifdef TRILINOS
# Line 106  Paso_SystemMatrix* Paso_SystemMatrix_all Line 111  Paso_SystemMatrix* Paso_SystemMatrix_all
111       } else {       } else {
112          out->solver_package=PASO_PASO;            out->solver_package=PASO_PASO;  
113          out->mainBlock=Paso_SparseMatrix_alloc(type,out->pattern->mainPattern,row_block_size,col_block_size);          out->mainBlock=Paso_SparseMatrix_alloc(type,out->pattern->mainPattern,row_block_size,col_block_size);
114          out->coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->couplePattern,row_block_size,col_block_size);          out->col_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->col_couplePattern,row_block_size,col_block_size);
115            out->row_coupleBlock=Paso_SparseMatrix_alloc(type,out->pattern->row_couplePattern,row_block_size,col_block_size);
116          /* allocate memory for matrix entries */          /* allocate memory for matrix entries */
117          if (type & MATRIX_FORMAT_CSC) {          if (type & MATRIX_FORMAT_CSC) {
118             n_norm = out->mainBlock->numCols * out->col_block_size;             n_norm = out->mainBlock->numCols * out->col_block_size;
# Line 138  Paso_SystemMatrix* Paso_SystemMatrix_all Line 144  Paso_SystemMatrix* Paso_SystemMatrix_all
144    
145  Paso_SystemMatrix* Paso_SystemMatrix_reference(Paso_SystemMatrix* in) {  Paso_SystemMatrix* Paso_SystemMatrix_reference(Paso_SystemMatrix* in) {
146     if (in!=NULL) ++(in->reference_counter);     if (in!=NULL) ++(in->reference_counter);
147     return NULL;     return in;
148  }  }
149    
150  /* deallocates a SystemMatrix: */  /* deallocates a SystemMatrix: */
# Line 151  void Paso_SystemMatrix_free(Paso_SystemM Line 157  void Paso_SystemMatrix_free(Paso_SystemM
157          Paso_Distribution_free(in->row_distribution);          Paso_Distribution_free(in->row_distribution);
158          Paso_Distribution_free(in->col_distribution);          Paso_Distribution_free(in->col_distribution);
159          Paso_MPIInfo_free(in->mpi_info);          Paso_MPIInfo_free(in->mpi_info);
160            Paso_Coupler_free(in->row_coupler);
161            Paso_Coupler_free(in->col_coupler);
162          Paso_SparseMatrix_free(in->mainBlock);          Paso_SparseMatrix_free(in->mainBlock);
163          Paso_SparseMatrix_free(in->coupleBlock);          Paso_SparseMatrix_free(in->col_coupleBlock);
164            Paso_SparseMatrix_free(in->row_coupleBlock);
165          MEMFREE(in->normalizer);          MEMFREE(in->normalizer);
166          Paso_solve_free(in);          Paso_solve_free(in);
167          #ifdef TRILINOS          #ifdef TRILINOS
# Line 165  void Paso_SystemMatrix_free(Paso_SystemM Line 174  void Paso_SystemMatrix_free(Paso_SystemM
174       }       }
175     }     }
176  }  }
177  void Paso_SystemMatrix_allocBuffer(Paso_SystemMatrix* A) {  void  Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A,const double* in)
178      Paso_Coupler_allocBuffer(A->pattern->coupler,A->col_block_size);  {
179      Paso_SystemMatrix_startColCollect(A,in);
180    }
181    double* Paso_SystemMatrix_finishCollect(Paso_SystemMatrix* A)
182    {
183     return Paso_SystemMatrix_finishColCollect(A);
184    }
185    
186    void  Paso_SystemMatrix_startColCollect(Paso_SystemMatrix* A,const double* in)
187    {
188      Paso_Coupler_startCollect(A->col_coupler, in);
189  }  }
190  void Paso_SystemMatrix_freeBuffer(Paso_SystemMatrix* A) {  double* Paso_SystemMatrix_finishColCollect(Paso_SystemMatrix* A)
191      Paso_Coupler_freeBuffer(A->pattern->coupler);  {
192     Paso_Coupler_finishCollect(A->col_coupler);
193     return A->col_coupler->recv_buffer;
194  }  }
195  void  Paso_SystemMatrix_startCollect(Paso_SystemMatrix* A, double* in)  void  Paso_SystemMatrix_startRowCollect(Paso_SystemMatrix* A,const double* in)
196  {  {
197    Paso_Coupler_startCollect(A->pattern->coupler, in);    Paso_Coupler_startCollect(A->row_coupler, in);
198  }  }
199  double* Paso_SystemMatrix_finishCollect(Paso_SystemMatrix* A)  double* Paso_SystemMatrix_finishRowCollect(Paso_SystemMatrix* A)
200  {  {
201   Paso_Coupler_finishCollect(A->pattern->coupler);   Paso_Coupler_finishCollect(A->row_coupler);
202   return A->pattern->coupler->recv_buffer;   return A->row_coupler->recv_buffer;
203  }  }
204    
205  dim_t Paso_SystemMatrix_getTotalNumRows(Paso_SystemMatrix* A){  dim_t Paso_SystemMatrix_getTotalNumRows(const Paso_SystemMatrix* A){
206    return A->mainBlock->numRows * A->row_block_size;    return A->mainBlock->numRows * A->row_block_size;
207  }  }
208    
209  dim_t Paso_SystemMatrix_getTotalNumCols(Paso_SystemMatrix* A){  dim_t Paso_SystemMatrix_getTotalNumCols(const Paso_SystemMatrix* A){
210    return A->mainBlock->numCols * A->col_block_size;    return A->mainBlock->numCols * A->col_block_size;
211  }  }
212  dim_t Paso_SystemMatrix_getGlobalNumRows(Paso_SystemMatrix* A) {  dim_t Paso_SystemMatrix_getGlobalNumRows(Paso_SystemMatrix* A) {

Legend:
Removed from v.1361  
changed lines
  Added in v.2548

  ViewVC Help
Powered by ViewVC 1.1.26