/[escript]/branches/doubleplusgood/dudley/src/Mesh_getPattern.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/dudley/src/Mesh_getPattern.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4332 - (show annotations)
Thu Mar 21 04:21:14 2013 UTC (5 years, 11 months ago) by jfenwick
File size: 5902 byte(s)
like sand though the hourglass
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 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 since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16 /************************************************************************************/
17
18 /* Dudley: Mesh */
19
20 /************************************************************************************/
21
22 #include "Mesh.h"
23 #include "IndexList.h"
24
25 /************************************************************************************/
26
27 /* returns a reference to the matrix pattern */
28
29 Paso_SystemMatrixPattern *Dudley_getPattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order)
30 {
31 Paso_SystemMatrixPattern *out = NULL;
32 Dudley_resetError();
33 /* make sure that the requested pattern is available */
34 if (reduce_row_order)
35 {
36 if (reduce_col_order)
37 {
38 if (mesh->ReducedReducedPattern == NULL)
39 mesh->ReducedReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
40 }
41 else
42 {
43 if (mesh->ReducedFullPattern == NULL)
44 mesh->ReducedFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
45 }
46 }
47 else
48 {
49 if (reduce_col_order)
50 {
51 if (mesh->FullReducedPattern == NULL)
52 mesh->FullReducedPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
53 }
54 else
55 {
56 if (mesh->FullFullPattern == NULL)
57 mesh->FullFullPattern = Dudley_makePattern(mesh, reduce_row_order, reduce_col_order);
58 }
59 }
60 if (Dudley_noError())
61 {
62 if (reduce_row_order)
63 {
64 if (reduce_col_order)
65 {
66 out = Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
67 }
68 else
69 {
70 out = Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
71 }
72 }
73 else
74 {
75 if (reduce_col_order)
76 {
77 out = Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
78 }
79 else
80 {
81 out = Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
82 }
83 }
84 }
85 return out;
86 }
87
88 Paso_SystemMatrixPattern *Dudley_makePattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order)
89 {
90 Paso_SystemMatrixPattern *out = NULL;
91 Paso_Pattern *main_pattern = NULL, *col_couple_pattern = NULL, *row_couple_pattern = NULL;
92 Paso_Connector *col_connector, *row_connector;
93 Dudley_IndexList *index_list = NULL;
94 Dudley_NodeMapping *colMap = NULL, *rowMap = NULL;
95 Paso_Distribution *colDistribution = NULL, *rowDistribution = NULL;
96
97 index_t i;
98 Dudley_resetError();
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 = new Dudley_IndexList[rowMap->numTargets];
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 delete[] 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