/[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 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 11 months ago) by ksteube
File MIME type: text/plain
File size: 6747 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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_reference(mesh->ReducedReducedPattern);
49 } else {
50 out=Paso_SystemMatrixPattern_reference(mesh->ReducedFullPattern);
51 }
52 } else {
53 if (reduce_col_order) {
54 out=Paso_SystemMatrixPattern_reference(mesh->FullReducedPattern);
55 } else {
56 out=Paso_SystemMatrixPattern_reference(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 double time0;
64 Paso_SystemMatrixPattern* out=NULL;
65 Paso_Pattern *main_pattern = NULL, *col_couple_pattern=NULL, *row_couple_pattern=NULL;
66 Paso_Connector *col_connector, *row_connector;
67 Finley_IndexList* index_list=NULL;
68 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
69 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
70
71 index_t i;
72 Finley_resetError();
73 time0=Finley_timer();
74
75 if (reduce_col_order) {
76 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
77 colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
78 col_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
79
80 } else {
81 colMap=mesh->Nodes->degreesOfFreedomMapping;
82 colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
83 col_connector=mesh->Nodes->degreesOfFreedomConnector;
84 }
85
86 if (reduce_row_order) {
87 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
88 rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
89 row_connector=mesh->Nodes->reducedDegreesOfFreedomConnector;
90 } else {
91 rowMap=mesh->Nodes->degreesOfFreedomMapping;
92 rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93 row_connector=mesh->Nodes->degreesOfFreedomConnector;
94 }
95
96 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
97 if (! Finley_checkPtr(index_list)) {
98
99 #pragma omp parallel private(i)
100 {
101 #pragma omp for schedule(static)
102 for(i=0;i<rowMap->numTargets;++i) {
103 index_list[i].extension=NULL;
104 index_list[i].n=0;
105 }
106 /* insert contributions from element matrices into colums index index_list: */
107 Finley_IndexList_insertElements(index_list,mesh->Elements,
108 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
109 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
110 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
111 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
112 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
113 Finley_IndexList_insertElements(index_list,mesh->Points,
114 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
115
116 }
117
118 /* create pattern */
119 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 /* 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 col_couple_pattern,
136 row_couple_pattern,
137 col_connector,
138 row_connector);
139 }
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 Paso_Pattern_free(col_couple_pattern);
148 Paso_Pattern_free(row_couple_pattern);
149 }
150 #ifdef Finley_TRACE
151 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
152 #endif
153 Paso_MPIInfo_noError(mesh->MPIInfo);
154 return out;
155 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26