/[escript]/trunk/finley/src/Mesh_getPattern.c
ViewVC logotype

Annotation of /trunk/finley/src/Mesh_getPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 6759 byte(s)
Don't panic.
Updating copyright stamps

1 jgs 102
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 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 jgs 102
14 ksteube 1811
15 jgs 102 /**************************************************************/
16    
17 ksteube 1312 /* Finley: Mesh */
18 jgs 102
19     /**************************************************************/
20    
21 jgs 150 #include "Mesh.h"
22 jgs 102 #include "IndexList.h"
23    
24     /**************************************************************/
25    
26     /* returns a reference to the matrix pattern */
27    
28 jgs 150 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
29     Paso_SystemMatrixPattern *out=NULL;
30     Finley_resetError();
31 jgs 102 /* make sure that the requested pattern is available */
32     if (reduce_row_order) {
33     if (reduce_col_order) {
34     if (mesh->ReducedReducedPattern==NULL) mesh->ReducedReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
35     } else {
36     if (mesh->ReducedFullPattern==NULL) mesh->ReducedFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
37     }
38     } else {
39     if (reduce_col_order) {
40     if (mesh->FullReducedPattern==NULL) mesh->FullReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
41     } else {
42     if (mesh->FullFullPattern==NULL) mesh->FullFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
43     }
44     }
45 jgs 150 if (Finley_noError()) {
46 jgs 102 if (reduce_row_order) {
47     if (reduce_col_order) {
48 gross 2551 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
49 jgs 102 } else {
50 gross 2551 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
51 jgs 102 }
52     } else {
53     if (reduce_col_order) {
54 gross 2551 out=Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
55 jgs 102 } else {
56 gross 2551 out=Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
57 jgs 102 }
58     }
59     }
60     return out;
61     }
62 jgs 150 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
63 jgs 102 double time0;
64 ksteube 1312 Paso_SystemMatrixPattern* out=NULL;
65 gross 1552 Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
66     Paso_Connector *col_connector, *row_connector;
67 jgs 102 Finley_IndexList* index_list=NULL;
68 ksteube 1312 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
69     Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
70    
71 phornby 1628 index_t i;
72 jgs 150 Finley_resetError();
73 jgs 102 time0=Finley_timer();
74 ksteube 1312
75 jgs 102 if (reduce_col_order) {
76 ksteube 1312 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
77     colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
78 gross 1552 col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
79 ksteube 1312
80 jgs 102 } else {
81 ksteube 1312 colMap=mesh->Nodes->degreesOfFreedomMapping;
82     colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
83 gross 1552 col_connector=mesh->Nodes->degreesOfFreedomConnector;
84 jgs 102 }
85    
86     if (reduce_row_order) {
87 ksteube 1312 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
88     rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
89 gross 1552 row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
90 jgs 102 } else {
91 ksteube 1312 rowMap=mesh->Nodes->degreesOfFreedomMapping;
92     rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93 gross 1552 row_connector=mesh->Nodes->degreesOfFreedomConnector;
94 jgs 102 }
95    
96 ksteube 1312 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
97     if (! Finley_checkPtr(index_list)) {
98    
99     #pragma omp parallel private(i)
100 jgs 102 {
101     #pragma omp for schedule(static)
102 ksteube 1312 for(i=0;i<rowMap->numTargets;++i) {
103 jgs 102 index_list[i].extension=NULL;
104     index_list[i].n=0;
105     }
106     /* insert contributions from element matrices into colums index index_list: */
107 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->Elements,
108 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
109 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
110 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
111 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
112 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
113 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->Points,
114 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
115    
116 jgs 102 }
117 ksteube 1312
118     /* create pattern */
119 gross 1552 main_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
120     0,Paso_Distribution_getMyNumComponents(colDistribution),
121     0);
122     col_couple_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
123     Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,
124     -Paso_Distribution_getMyNumComponents(colDistribution));
125     row_couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),rowMap->numTargets,index_list,
126     0,Paso_Distribution_getMyNumComponents(colDistribution),
127     0);
128    
129 ksteube 1312 /* if everthing is in order we can create the return value */
130     if (Finley_noError()) {
131     out=Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT,
132     rowDistribution,
133     colDistribution,
134     main_pattern,
135 gross 1552 col_couple_pattern,
136     row_couple_pattern,
137     col_connector,
138     row_connector);
139 ksteube 1312 }
140     /* clean up */
141     if (index_list!=NULL) {
142     #pragma omp parallel for private(i)
143     for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
144     }
145     TMPMEMFREE(index_list);
146     Paso_Pattern_free(main_pattern);
147 gross 1552 Paso_Pattern_free(col_couple_pattern);
148     Paso_Pattern_free(row_couple_pattern);
149 jgs 102 }
150 jgs 149 #ifdef Finley_TRACE
151 jgs 102 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
152 jgs 149 #endif
153 ksteube 1312 Paso_MPIInfo_noError(mesh->MPIInfo);
154     return out;
155 jgs 102 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26