/[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 5863 - (show annotations)
Wed Jan 13 02:25:48 2016 UTC (3 years, 4 months ago) by jfenwick
File size: 6247 byte(s)
Copyright dates updated.
\version for doxygen to read

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The 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 #include <iostream>
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 const dim_t n = getNumRows();
103 const int rank = mpi_info->rank;
104
105 std::cerr << "rank " << rank << " Main Block:\n-----------\n";
106
107 for (dim_t q=0; q<n; ++q) {
108 std::cerr << "Row " << q << ": ";
109 for (dim_t iPtr=mainBlock->pattern->ptr[q]; iPtr<mainBlock->pattern->ptr[q+1]; ++iPtr) {
110 std::cerr << "(" << mainBlock->pattern->index[iPtr] << " ";
111 for (dim_t ib=0; ib<block_size; ib++) {
112 std::cerr << mainBlock->val[iPtr*block_size+ib] << " ";
113 }
114 std::cerr << "),";
115 }
116 std::cerr << std::endl;
117 }
118 if (col_coupleBlock != NULL && mpi_info->size>1) {
119 std::cerr << "rank " << rank
120 << " Column Couple Block:\n------------------\n";
121 for (dim_t q=0; q<col_coupleBlock->pattern->numOutput; ++q) {
122 std::cerr << "Row " << q << ": ";
123 for (dim_t iPtr=col_coupleBlock->pattern->ptr[q]; iPtr<col_coupleBlock->pattern->ptr[q+1]; ++iPtr) {
124 if (global_id) {
125 std::cerr << "("
126 << global_id[col_coupleBlock->pattern->index[iPtr]]
127 << " " << col_coupleBlock->val[iPtr*block_size]
128 << "),";
129 } else {
130 std::cerr << "("
131 << col_coupleBlock->pattern->index[iPtr]
132 << " " << col_coupleBlock->val[iPtr*block_size]
133 << "),";
134 }
135 }
136 std::cerr << std::endl;
137 }
138 }
139 if (row_coupleBlock != NULL && mpi_info->size>1) {
140 std::cerr << "rank " << rank
141 << " Row Couple Block:\n--------------------\n";
142 for (dim_t p=0; p<row_coupleBlock->pattern->numOutput; ++p) {
143 std::cerr << "Row " << p << ": ";
144 for (dim_t iPtr=row_coupleBlock->pattern->ptr[p]; iPtr<row_coupleBlock->pattern->ptr[p+1]; ++iPtr) {
145 std::cerr << "(" << row_coupleBlock->pattern->index[iPtr]
146 << " " << row_coupleBlock->val[iPtr*block_size] << "),";
147 }
148 std::cerr << std::endl;
149 }
150 }
151 if (remote_coupleBlock != NULL && mpi_info->size>1) {
152 std::cerr << "rank " << rank
153 << " Remote Couple Block:\n--------------------\n";
154 for (dim_t p=0; p<remote_coupleBlock->pattern->numOutput; ++p) {
155 std::cerr << "Row " << p << ": ";
156 for (dim_t iPtr=remote_coupleBlock->pattern->ptr[p]; iPtr<remote_coupleBlock->pattern->ptr[p+1]; ++iPtr) {
157 std::cerr << "(" << remote_coupleBlock->pattern->index[iPtr]
158 << " " << remote_coupleBlock->val[iPtr*block_size] << "),";
159 }
160 std::cerr << std::endl;
161 }
162 }
163 }
164
165 } // namespace paso
166

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/paso/src/SystemMatrix_debug.cpp:5567-5588 /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 /release/4.0/paso/src/SystemMatrix_debug.cpp:5380-5406 /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