/[escript]/trunk/paso/src/SystemMatrix_debug.cpp
ViewVC logotype

Contents of /trunk/paso/src/SystemMatrix_debug.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4873 - (show annotations)
Wed Apr 16 06:38:51 2014 UTC (5 years, 5 months ago) by caltinay
File size: 6658 byte(s)
whitespace only changes.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************
19
20 Paso: SystemMatrix: debugging tools
21
22 *****************************************************************************
23
24 Author: Lutz Gross, l.gross@uq.edu.au
25
26 *****************************************************************************/
27
28 #include "SystemMatrix.h"
29
30 #include <cstring> // strcat
31
32 namespace paso {
33
34 // fills the matrix with values i+f1*j where i and j are the global row
35 // and column indices of the matrix entry
36 void SystemMatrix::fillWithGlobalCoordinates(double f1)
37 {
38 const dim_t n = getNumRows();
39 const dim_t m = getNumCols();
40 const index_t me = mpi_info->rank;
41 const index_t row_offset = row_distribution->first_component[me];
42 const index_t col_offset = col_distribution->first_component[me];
43 double* cols = new double[m];
44 double* rows = new double[n];
45 Coupler_ptr col_couple(new Coupler(col_coupler->connector, 1));
46 Coupler_ptr row_couple(new Coupler(col_coupler->connector, 1));
47
48 #pragma omp parallel for
49 for (dim_t i=0; i<n; ++i)
50 rows[i]=row_offset+i;
51
52 col_couple->startCollect(rows);
53
54 #pragma omp parallel for
55 for (dim_t i=0; i<m; ++i)
56 cols[i]=col_offset+i;
57
58 row_couple->startCollect(cols);
59
60 // main block
61 for (dim_t q=0; q<n; ++q) {
62 for (dim_t iPtr = mainBlock->pattern->ptr[q];
63 iPtr < mainBlock->pattern->ptr[q+1]; ++iPtr) {
64 const dim_t p = mainBlock->pattern->index[iPtr];
65 for (dim_t ib=0; ib<block_size; ib++)
66 mainBlock->val[iPtr*block_size+ib]=f1*rows[q]+cols[p];
67 }
68 }
69
70 col_couple->finishCollect();
71 if (col_coupleBlock != NULL) {
72 for (dim_t q=0; q<col_coupleBlock->pattern->numOutput; ++q) {
73 for (dim_t iPtr = col_coupleBlock->pattern->ptr[q];
74 iPtr < col_coupleBlock->pattern->ptr[q+1]; ++iPtr) {
75 const dim_t p = col_coupleBlock->pattern->index[iPtr];
76 for (dim_t ib=0; ib<block_size; ib++)
77 col_coupleBlock->val[iPtr*block_size+ib] =
78 f1*rows[q]+col_couple->recv_buffer[p];
79 }
80 }
81 }
82
83 row_couple->finishCollect();
84 if (row_coupleBlock != NULL) {
85 for (dim_t p=0; p<row_coupleBlock->pattern->numOutput; ++p) {
86 for (dim_t iPtr = row_coupleBlock->pattern->ptr[p];
87 iPtr < row_coupleBlock->pattern->ptr[p+1]; ++iPtr) {
88 const dim_t q = row_coupleBlock->pattern->index[iPtr];
89 for (dim_t ib=0; ib<block_size; ib++)
90 row_coupleBlock->val[iPtr*block_size+ib] =
91 row_couple->recv_buffer[p]*f1+cols[q];
92 }
93 }
94 }
95
96 delete[] cols;
97 delete[] rows;
98 }
99
100 void SystemMatrix::print() const
101 {
102 dim_t iPtr, q, p, ib;
103 const dim_t n = getNumRows();
104 const index_t rank = mpi_info->rank;
105 char *str1, *str2;
106 str1 = new char[n*n*block_size*30+100];
107 str2 = new char[30];
108
109 sprintf(str1, "rank %d Main Block:\n-----------\n", rank);
110 for (q=0; q<n; ++q){
111 sprintf(str2, "Row %d: ",q);
112 strcat(str1, str2);
113 for (iPtr=mainBlock->pattern->ptr[q]; iPtr<mainBlock->pattern->ptr[q+1]; ++iPtr) {
114 sprintf(str2, "(%d ",mainBlock->pattern->index[iPtr]);
115 strcat(str1, str2);
116 for (ib=0; ib<block_size; ib++){
117 sprintf(str2, "%f ", mainBlock->val[iPtr*block_size+ib]);
118 strcat(str1, str2);
119 }
120 sprintf(str2, "),");
121 strcat(str1, str2);
122 }
123 sprintf(str1, "%s\n", str1);
124 }
125 fprintf(stderr, "%s", str1);
126 if (col_coupleBlock != NULL && mpi_info->size>1) {
127 sprintf(str1, "rank %d Column Couple Block:\n------------------\n", rank);
128 for (q=0; q<col_coupleBlock->pattern->numOutput; ++q) {
129 sprintf(str2, "Row %d: ", q);
130 strcat(str1, str2);
131 for (iPtr=col_coupleBlock->pattern->ptr[q]; iPtr<col_coupleBlock->pattern->ptr[q+1]; ++iPtr) {
132 if (global_id)
133 sprintf(str2, "(%d %f),", global_id[col_coupleBlock->pattern->index[iPtr]], col_coupleBlock->val[iPtr*block_size]);
134 else
135 sprintf(str2, "(%d %f),", col_coupleBlock->pattern->index[iPtr], col_coupleBlock->val[iPtr*block_size]);
136 strcat(str1, str2);
137 }
138 sprintf(str1, "%s\n", str1);
139 }
140 fprintf(stderr, "%s", str1);
141 }
142 if (row_coupleBlock != NULL && mpi_info->size>1) {
143 sprintf(str1, "rank %d Row Couple Block:\n--------------------\n", rank);
144 for (p=0; p<row_coupleBlock->pattern->numOutput; ++p) {
145 sprintf(str2, "Row %d:", p);
146 strcat(str1, str2);
147 for (iPtr=row_coupleBlock->pattern->ptr[p]; iPtr<row_coupleBlock->pattern->ptr[p+1]; ++iPtr) {
148 sprintf(str2, "(%d %f),", row_coupleBlock->pattern->index[iPtr], row_coupleBlock->val[iPtr*block_size]);
149 strcat(str1, str2);
150 }
151 sprintf(str1, "%s\n", str1);
152 }
153 fprintf(stderr, "%s", str1);
154 }
155 if (remote_coupleBlock != NULL && mpi_info->size>1) {
156 sprintf(str1, "rank %d Remote Couple Block:\n--------------------\n", rank);
157 for (p=0; p<remote_coupleBlock->pattern->numOutput; ++p) {
158 sprintf(str2, "Row %d:", p);
159 strcat(str1, str2);
160 for (iPtr=remote_coupleBlock->pattern->ptr[p]; iPtr<remote_coupleBlock->pattern->ptr[p+1]; ++iPtr) {
161 sprintf(str2, "(%d %f),", remote_coupleBlock->pattern->index[iPtr], remote_coupleBlock->val[iPtr*block_size]);
162 strcat(str1, str2);
163 }
164 sprintf(str1, "%s\n", str1);
165 }
166 fprintf(stderr, "%s", str1);
167 }
168 delete[] str1;
169 delete[] str2;
170 }
171
172 } // namespace paso
173

Properties

Name Value
svn:mergeinfo /branches/amg_from_3530/paso/src/SystemMatrix_debug.cpp:3531-3826 /branches/lapack2681/paso/src/SystemMatrix_debug.cpp:2682-2741 /branches/pasowrap/paso/src/SystemMatrix_debug.cpp:3661-3674 /branches/py3_attempt2/paso/src/SystemMatrix_debug.cpp:3871-3891 /branches/restext/paso/src/SystemMatrix_debug.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/SystemMatrix_debug.cpp:3669-3791 /branches/stage3.0/paso/src/SystemMatrix_debug.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/SystemMatrix_debug.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/SystemMatrix_debug.cpp:3517-3974 /release/3.0/paso/src/SystemMatrix_debug.cpp:2591-2601 /trunk/paso/src/SystemMatrix_debug.cpp:4257-4344 /trunk/ripley/test/python/paso/src/SystemMatrix_debug.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26