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 |
|
|
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 */ |