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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3490 - (show annotations)
Wed Mar 30 02:24:33 2011 UTC (8 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 6610 byte(s)
More gcc-4.6 fixes (mostly initialized-but-unused-var warnings)

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
17 /* Finley: Mesh */
18
19 /**************************************************************/
20
21 #include "Mesh.h"
22 #include "IndexList.h"
23
24 /**************************************************************/
25
26 /* returns a reference to the matrix pattern */
27
28 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 /* 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 if (Finley_noError()) {
46 if (reduce_row_order) {
47 if (reduce_col_order) {
48 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedReducedPattern);
49 } else {
50 out=Paso_SystemMatrixPattern_getReference(mesh->ReducedFullPattern);
51 }
52 } else {
53 if (reduce_col_order) {
54 out=Paso_SystemMatrixPattern_getReference(mesh->FullReducedPattern);
55 } else {
56 out=Paso_SystemMatrixPattern_getReference(mesh->FullFullPattern);
57 }
58 }
59 }
60 return out;
61 }
62 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
63 Paso_SystemMatrixPattern* out=NULL;
64 Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
65 Paso_Connector *col_connector, *row_connector;
66 Finley_IndexList* index_list=NULL;
67 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
68 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
69
70 index_t i;
71 Finley_resetError();
72
73 if (reduce_col_order) {
74 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
75 colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
76 col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
77
78 } else {
79 colMap=mesh->Nodes->degreesOfFreedomMapping;
80 colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
81 col_connector=mesh->Nodes->degreesOfFreedomConnector;
82 }
83
84 if (reduce_row_order) {
85 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
86 rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
87 row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
88 } else {
89 rowMap=mesh->Nodes->degreesOfFreedomMapping;
90 rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
91 row_connector=mesh->Nodes->degreesOfFreedomConnector;
92 }
93
94 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
95 if (! Finley_checkPtr(index_list)) {
96
97 #pragma omp parallel private(i)
98 {
99 #pragma omp for schedule(static)
100 for(i=0;i<rowMap->numTargets;++i) {
101 index_list[i].extension=NULL;
102 index_list[i].n=0;
103 }
104 /* insert contributions from element matrices into colums index index_list: */
105 Finley_IndexList_insertElements(index_list,mesh->Elements,
106 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
107 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
108 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
109 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
110 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
111 Finley_IndexList_insertElements(index_list,mesh->Points,
112 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
113
114 }
115
116 /* create pattern */
117 main_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
118 0,Paso_Distribution_getMyNumComponents(colDistribution),
119 0);
120 col_couple_pattern=Finley_IndexList_createPattern(0,Paso_Distribution_getMyNumComponents(rowDistribution),index_list,
121 Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,
122 -Paso_Distribution_getMyNumComponents(colDistribution));
123 row_couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),rowMap->numTargets,index_list,
124 0,Paso_Distribution_getMyNumComponents(colDistribution),
125 0);
126
127 /* if everthing is in order we can create the return value */
128 if (Finley_noError()) {
129 out=Paso_SystemMatrixPattern_alloc(MATRIX_FORMAT_DEFAULT,
130 rowDistribution,
131 colDistribution,
132 main_pattern,
133 col_couple_pattern,
134 row_couple_pattern,
135 col_connector,
136 row_connector);
137 }
138 /* clean up */
139 if (index_list!=NULL) {
140 #pragma omp parallel for private(i)
141 for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
142 }
143 TMPMEMFREE(index_list);
144 Paso_Pattern_free(main_pattern);
145 Paso_Pattern_free(col_couple_pattern);
146 Paso_Pattern_free(row_couple_pattern);
147 }
148 Esys_MPIInfo_noError(mesh->MPIInfo);
149 return out;
150 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26