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

Contents of /trunk/dudley/src/Mesh_getPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3312 - (show annotations)
Tue Oct 26 07:54:58 2010 UTC (8 years, 11 months ago) by gross
File MIME type: text/plain
File size: 5774 byte(s)
last step for a clean up version of the AMG
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * 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
14 /**************************************************************/
15
16 /* Dudley: Mesh */
17
18 /**************************************************************/
19
20 #include "Mesh.h"
21 #include "IndexList.h"
22
23 /**************************************************************/
24
25 /* returns a reference to the matrix pattern */
26
27 Paso_SystemMatrixPattern *Dudley_getPattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order)
28 {
29 Paso_SystemMatrixPattern *out = NULL;
30 Dudley_resetError();
31 /* make sure that the requested pattern is available */
32 if (reduce_row_order)
33 {
34 if (reduce_col_order)
35 {
36 if (mesh->ReducedReducedPattern == NULL)
37 mesh->ReducedReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
38 }
39 else
40 {
41 if (mesh->ReducedFullPattern == NULL)
42 mesh->ReducedFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
43 }
44 }
45 else
46 {
47 if (reduce_col_order)
48 {
49 if (mesh->FullReducedPattern == NULL)
50 mesh->FullReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
51 }
52 else
53 {
54 if (mesh->FullFullPattern == NULL)
55 mesh->FullFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
56 }
57 }
58 if (Dudley_noError())
59 {
60 if (reduce_row_order)
61 {
62 if (reduce_col_order)
63 {
64 out = Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
65 }
66 else
67 {
68 out = Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
69 }
70 }
71 else
72 {
73 if (reduce_col_order)
74 {
75 out = Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
76 }
77 else
78 {
79 out = Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
80 }
81 }
82 }
83 return out;
84 }
85
86 Paso_SystemMatrixPattern *Dudley_makePattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order)
87 {
88 double time0;
89 Paso_SystemMatrixPattern *out = NULL;
90 Paso_Pattern *main_pattern = NULL, *col_couple_pattern = NULL, *row_couple_pattern = NULL;
91 Paso_Connector *col_connector, *row_connector;
92 Dudley_IndexList *index_list = NULL;
93 Dudley_NodeMapping *colMap = NULL, *rowMap = NULL;
94 Paso_Distribution *colDistribution = NULL, *rowDistribution = NULL;
95
96 index_t i;
97 Dudley_resetError();
98 time0 = Dudley_timer();
99
100 if (reduce_col_order)
101 {
102 colMap = mesh->Nodes->reducedDegreesOfFreedomMapping;
103 colDistribution = mesh->Nodes->reducedDegreesOfFreedomDistribution;
104 col_connector = mesh->Nodes->reducedDegreesOfFreedomConnector;
105
106 }
107 else
108 {
109 colMap = mesh->Nodes->degreesOfFreedomMapping;
110 colDistribution = mesh->Nodes->degreesOfFreedomDistribution;
111 col_connector = mesh->Nodes->degreesOfFreedomConnector;
112 }
113
114 if (reduce_row_order)
115 {
116 rowMap = mesh->Nodes->reducedDegreesOfFreedomMapping;
117 rowDistribution = mesh->Nodes->reducedDegreesOfFreedomDistribution;
118 row_connector = mesh->Nodes->reducedDegreesOfFreedomConnector;
119 }
120 else
121 {
122 rowMap = mesh->Nodes->degreesOfFreedomMapping;
123 rowDistribution = mesh->Nodes->degreesOfFreedomDistribution;
124 row_connector = mesh->Nodes->degreesOfFreedomConnector;
125 }
126
127 index_list = TMPMEMALLOC(rowMap->numTargets, Dudley_IndexList);
128 if (!Dudley_checkPtr(index_list))
129 {
130
131 #pragma omp parallel private(i)
132 {
133 #pragma omp for schedule(static)
134 for (i = 0; i < rowMap->numTargets; ++i)
135 {
136 index_list[i].extension = NULL;
137 index_list[i].n = 0;
138 }
139 /* insert contributions from element matrices into colums index index_list: */
140 Dudley_IndexList_insertElements(index_list, mesh->Elements,
141 reduce_row_order, rowMap->target, reduce_col_order, colMap->target);
142 Dudley_IndexList_insertElements(index_list, mesh->FaceElements,
143 reduce_row_order, rowMap->target, reduce_col_order, colMap->target);
144 Dudley_IndexList_insertElements(index_list, mesh->Points,
145 reduce_row_order, rowMap->target, reduce_col_order, colMap->target);
146
147 }
148
149 /* create pattern */
150 main_pattern =
151 Dudley_IndexList_createPattern(0, Paso_Distribution_getMyNumComponents(rowDistribution), index_list, 0,
152 Paso_Distribution_getMyNumComponents(colDistribution), 0);
153 col_couple_pattern =
154 Dudley_IndexList_createPattern(0, Paso_Distribution_getMyNumComponents(rowDistribution), index_list,
155 Paso_Distribution_getMyNumComponents(colDistribution), colMap->numTargets,
156 -Paso_Distribution_getMyNumComponents(colDistribution));
157 row_couple_pattern =
158 Dudley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution), rowMap->numTargets,
159 index_list, 0, Paso_Distribution_getMyNumComponents(colDistribution), 0);
160
161 /* if everthing is in order we can create the return value */
162 if (Dudley_noError())
163 {
164 out = Paso_SystemMatrixPattern_alloc(MATRIX_FORMAT_DEFAULT,
165 rowDistribution,
166 colDistribution,
167 main_pattern,
168 col_couple_pattern, row_couple_pattern, col_connector, row_connector);
169 }
170 /* clean up */
171 if (index_list != NULL)
172 {
173 #pragma omp parallel for private(i)
174 for (i = 0; i < rowMap->numTargets; ++i)
175 Dudley_IndexList_free(index_list[i].extension);
176 }
177 TMPMEMFREE(index_list);
178 Paso_Pattern_free(main_pattern);
179 Paso_Pattern_free(col_couple_pattern);
180 Paso_Pattern_free(row_couple_pattern);
181 }
182 Esys_MPIInfo_noError(mesh->MPIInfo);
183 return out;
184 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26