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

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

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

revision 1779 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 1780 by artak, Thu Sep 11 04:42:15 2008 UTC
# Line 36  void Paso_SystemMatrix_saveMM(Paso_Syste Line 36  void Paso_SystemMatrix_saveMM(Paso_Syste
36         Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently single processor runs are supported.\n");         Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently single processor runs are supported.\n");
37         return;         return;
38    }    }
39    if (A_p->block_size>1) {    if (A_p->col_block_size !=A_p->row_block_size) {
40         Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently only block size 1 is supported.\n");      Paso_setError(TYPE_ERROR, "Paso_SystemMatrix_saveMM: currently only square blocks are supported.");
41        return;
42      }
43      if (A_p->row_block_size>3) {
44           Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_saveMM: currently only block size 3 is supported.\n");
45         return;         return;
46    }    }
47    
# Line 63  void Paso_SystemMatrix_saveMM(Paso_Syste Line 67  void Paso_SystemMatrix_saveMM(Paso_Syste
67      N= Paso_SystemMatrix_getGlobalNumRows(A_p);      N= Paso_SystemMatrix_getGlobalNumRows(A_p);
68      M=Paso_SystemMatrix_getGlobalNumCols(A_p);      M=Paso_SystemMatrix_getGlobalNumCols(A_p);
69      mm_write_banner(fileHandle_p, matcode);      mm_write_banner(fileHandle_p, matcode);
70      mm_write_mtx_crd_size(fileHandle_p, N, M, A_p->mainBlock->pattern->ptr[N]);      mm_write_mtx_crd_size(fileHandle_p, N*A_p->row_block_size, M*A_p->col_block_size, A_p->mainBlock->pattern->ptr[N]*A_p->block_size);
71        if(A_p->row_block_size==1)
72          for (i=0; i<N; i++)
73            for (iptr_ij=A_p->mainBlock->pattern->ptr[i];iptr_ij<A_p->mainBlock->pattern->ptr[i+1]; ++iptr_ij) {
74              fprintf(fileHandle_p, "%d %d %25.15e\n", i+1, A_p->mainBlock->pattern->index[iptr_ij]+1, A_p->mainBlock->val[iptr_ij]);
75            }
76    
77        if(A_p->row_block_size==2)
78          for (i=0; i<N; i++) {
79            for (iptr_ij=A_p->mainBlock->pattern->ptr[i];iptr_ij<A_p->mainBlock->pattern->ptr[i+1]; ++iptr_ij) {
80              fprintf(fileHandle_p, "%d %d %25.15e\n", i*2+1, 2*(A_p->mainBlock->pattern->index[iptr_ij])+1, A_p->mainBlock->val[iptr_ij*4]);
81              fprintf(fileHandle_p, "%d %d %25.15e\n", i*2+1, 2*(A_p->mainBlock->pattern->index[iptr_ij])+1+1, A_p->mainBlock->val[iptr_ij*4+2]);
82              fprintf(fileHandle_p, "%d %d %25.15e\n", i*2+1+1, 2*(A_p->mainBlock->pattern->index[iptr_ij])+1, A_p->mainBlock->val[iptr_ij*4+1]);
83              fprintf(fileHandle_p, "%d %d %25.15e\n", i*2+1+1, 2*(A_p->mainBlock->pattern->index[iptr_ij])+1+1, A_p->mainBlock->val[iptr_ij*4+3]);
84            }
85          }
86    
87      for (i=0; i<N; i++) {      if(A_p->row_block_size==3)
88          for (i=0; i<N; i++) {
89         for (iptr_ij=A_p->mainBlock->pattern->ptr[i];iptr_ij<A_p->mainBlock->pattern->ptr[i+1]; ++iptr_ij) {         for (iptr_ij=A_p->mainBlock->pattern->ptr[i];iptr_ij<A_p->mainBlock->pattern->ptr[i+1]; ++iptr_ij) {
90          fprintf(fileHandle_p, "%d %d %25.15e\n", i+1, A_p->mainBlock->pattern->index[iptr_ij]+1, A_p->mainBlock->val[iptr_ij]);            fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1, A_p->mainBlock->val[iptr_ij*9]);
91         }            fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1+1, A_p->mainBlock->val[iptr_ij*9+3]);
92       }            fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+2+1, A_p->mainBlock->val[iptr_ij*9+6]);
93              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1, A_p->mainBlock->val[iptr_ij*9+1]);
94              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1+1, A_p->mainBlock->val[iptr_ij*9+4]);
95              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+1+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+2+1, A_p->mainBlock->val[iptr_ij*9+7]);
96              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+2+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1, A_p->mainBlock->val[iptr_ij*9+2]);
97              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+2+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+1+1, A_p->mainBlock->val[iptr_ij*9+5]);
98              fprintf(fileHandle_p, "%d %d %25.15e\n", i*3+2+1, 3*(A_p->mainBlock->pattern->index[iptr_ij])+2+1, A_p->mainBlock->val[iptr_ij*9+8]);
99            }
100          }
101        
102    }    }
103    
104    /* close the file */    /* close the file */

Legend:
Removed from v.1779  
changed lines
  Added in v.1780

  ViewVC Help
Powered by ViewVC 1.1.26