/[escript]/trunk/finley/src/IndexList.cpp
ViewVC logotype

Contents of /trunk/finley/src/IndexList.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (show annotations)
Mon Sep 15 01:25:23 2014 UTC (4 years, 11 months ago) by caltinay
File size: 4578 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

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 Finley: Converting an element list into a matrix shape
21
22 *****************************************************************************/
23
24 #include "IndexList.h"
25 #include "ElementFile.h"
26
27 /* Translate from distributed/local array indices to global indices */
28
29 /****************************************************************************/
30 /* inserts the contributions from the element matrices of elements
31 into the row index col. If symmetric is set, only the upper
32 triangle of the matrix is stored.
33 */
34
35 namespace finley {
36
37 void IndexList_insertElements(IndexList* index_list, ElementFile* elements,
38 bool reduce_row_order, const int* row_map,
39 bool reduce_col_order, const int* col_map)
40 {
41 // index_list is an array of linked lists. Each entry is a row (DOF) and
42 // contains the indices to the non-zero columns
43 if (!elements)
44 return;
45
46 const int NN=elements->numNodes;
47 const_ReferenceElement_ptr refElement(elements->referenceElementSet->
48 borrowReferenceElement(false));
49
50 int NN_row, NN_col, numSub;
51 const int *row_node=NULL, *col_node=NULL;
52 if (reduce_col_order) {
53 numSub=1;
54 col_node=refElement->Type->linearNodes;
55 NN_col=refElement->LinearBasisFunctions->Type->numShapes * refElement->Type->numSides;
56 } else {
57 numSub=refElement->Type->numSubElements;
58 col_node=refElement->Type->subElementNodes;
59 NN_col=refElement->BasisFunctions->Type->numShapes * refElement->Type->numSides;
60 }
61
62 if (reduce_row_order) {
63 numSub=1;
64 row_node=refElement->Type->linearNodes;
65 NN_row=refElement->LinearBasisFunctions->Type->numShapes * refElement->Type->numSides;
66 } else {
67 numSub=refElement->Type->numSubElements;
68 row_node=refElement->Type->subElementNodes;
69 NN_row=refElement->BasisFunctions->Type->numShapes * refElement->Type->numSides;
70 }
71
72 for (int color=elements->minColor; color<=elements->maxColor; color++) {
73 #pragma omp for
74 for (int e=0; e<elements->numElements; e++) {
75 if (elements->Color[e]==color) {
76 for (int isub=0; isub<numSub; isub++) {
77 for (int kr=0; kr<NN_row; kr++) {
78 const int irow=row_map[elements->Nodes[INDEX2(row_node[INDEX2(kr,isub,NN_row)],e,NN)]];
79 for (int kc=0; kc<NN_col; kc++) {
80 const int icol=col_map[elements->Nodes[INDEX2(col_node[INDEX2(kc,isub,NN_col)],e,NN)]];
81 index_list[irow].insertIndex(icol);
82 }
83 }
84 }
85 }
86 }
87 }
88 }
89
90 void IndexList_insertElementsWithRowRangeNoMainDiagonal(
91 IndexList* index_list, int firstRow,
92 int lastRow, ElementFile* elements,
93 int* row_map, int* col_map)
94 {
95 if (!elements)
96 return;
97
98 // this does not resolve macro elements
99 const int NN=elements->numNodes;
100 for (int color=elements->minColor; color<=elements->maxColor; color++) {
101 #pragma omp for
102 for (int e=0; e<elements->numElements; e++) {
103 if (elements->Color[e]==color) {
104 for (int kr=0; kr<NN; kr++) {
105 const int irow=row_map[elements->Nodes[INDEX2(kr,e,NN)]];
106 if (firstRow<=irow && irow<lastRow) {
107 const int irow_loc=irow-firstRow;
108 for (int kc=0; kc<NN; kc++) {
109 const int icol=col_map[elements->Nodes[INDEX2(kc,e,NN)]];
110 if (icol != irow)
111 index_list[irow_loc].insertIndex(icol);
112 }
113 }
114 }
115 }
116 }
117 }
118 }
119
120
121 } // namespace finley
122

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/diaplayground/finley/src/IndexList.cpp:4940-5147 /branches/lapack2681/finley/src/IndexList.cpp:2682-2741 /branches/pasowrap/finley/src/IndexList.cpp:3661-3674 /branches/py3_attempt2/finley/src/IndexList.cpp:3871-3891 /branches/restext/finley/src/IndexList.cpp:2610-2624 /branches/ripleygmg_from_3668/finley/src/IndexList.cpp:3669-3791 /branches/stage3.0/finley/src/IndexList.cpp:2569-2590 /branches/symbolic_from_3470/finley/src/IndexList.cpp:3471-3974 /release/3.0/finley/src/IndexList.cpp:2591-2601 /trunk/finley/src/IndexList.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26