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

Annotation of /trunk/paso/src/SystemMatrix_borrowNormalization.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2608 - (hide annotations)
Tue Aug 18 01:25:18 2009 UTC (10 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 3072 byte(s)
Updating Lutz' email

1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 dhawcroft 631
14 ksteube 1811
15 jgs 150 /**************************************************************/
16    
17     /* Paso: SystemMatrix */
18    
19     /* returns a borrowed reference to the matrix normaliztion vector */
20    
21     /* if the vector is in valid a new vector is calculate as the inverse */
22     /* of the sum of the absolute value in each row/column */
23    
24     /**************************************************************/
25    
26     /* Copyrights by ACcESS Australia 2005 */
27 jfenwick 2608 /* Author: Lutz Gross, l.gross@uq.edu.au */
28 jgs 150
29     /**************************************************************/
30    
31     #include "Paso.h"
32     #include "SystemMatrix.h"
33    
34     double* Paso_SystemMatrix_borrowNormalization(Paso_SystemMatrix* A) {
35 ksteube 1312 dim_t irow, nrow;
36     index_t irow_failed, irow_failed_local;
37     register double fac;
38 jgs 150 if (!A->normalizer_is_valid) {
39 gross 415 if ((A->type & MATRIX_FORMAT_CSC) || (A->type & MATRIX_FORMAT_SYM) || (A->type & MATRIX_FORMAT_OFFSET1)) {
40 ksteube 1312 Paso_setError(TYPE_ERROR,"Paso_SystemMatrix_borrowNormalization: No normalization available for compressed sparse column, symmetric storage scheme or index offset 1.");
41 gross 415 } else {
42 ksteube 1312 if (Paso_checkPtr(A->normalizer)) {
43     Paso_setError(SYSTEM_ERROR,"Paso_SystemMatrix_borrowNormalization: no memory alloced for normalizer.");
44    
45     } else {
46     nrow=A->mainBlock->numRows*A->row_block_size;
47     #pragma omp parallel for private(irow) schedule(static)
48     for (irow=0; irow<nrow ; ++irow) {
49     A->normalizer[irow]=0;
50     }
51     Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->mainBlock,A->normalizer);
52 artak 2159 if(A->col_coupleBlock->pattern->ptr!=NULL) {
53     Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(A->col_coupleBlock,A->normalizer);
54     }
55    
56 ksteube 1312 #pragma omp parallel
57     {
58     irow_failed_local=-1;
59     #pragma omp for private(irow,fac) schedule(static)
60     for (irow=0; irow<nrow ; ++irow) {
61     fac=A->normalizer[irow];
62     if (ABS(fac)>0) {
63     A->normalizer[irow]=1./fac;
64     } else {
65     A->normalizer[irow]=1.;
66     irow_failed=irow;
67     }
68     }
69     #pragma omp critical
70     irow_failed=irow_failed_local;
71     }
72     if (irow_failed>=0) {
73     Paso_setError(ZERO_DIVISION_ERROR,"There is a row containing zero entries only.");
74     }
75     A->normalizer_is_valid=TRUE;
76 jgs 150 }
77 gross 415 }
78 ksteube 1312 Paso_MPIInfo_noError(A->mpi_info );
79 jgs 150 }
80     return A->normalizer;
81     }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26