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

Contents of /trunk-mpi-branch/finley/src/Mesh_getPattern.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1258 - (show annotations)
Mon Aug 20 03:56:05 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/plain
File size: 6132 byte(s)
solver starts now but there still seems to be a problem in the MVM
1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* Finley: Mesh */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "Mesh.h"
25 #include "IndexList.h"
26
27 /**************************************************************/
28
29 /* returns a reference to the matrix pattern */
30
31 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
32 Paso_SystemMatrixPattern *out=NULL;
33 Finley_resetError();
34 /* make sure that the requested pattern is available */
35 if (reduce_row_order) {
36 if (reduce_col_order) {
37 if (mesh->ReducedReducedPattern==NULL) mesh->ReducedReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
38 } else {
39 if (mesh->ReducedFullPattern==NULL) mesh->ReducedFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
40 }
41 } else {
42 if (reduce_col_order) {
43 if (mesh->FullReducedPattern==NULL) mesh->FullReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
44 } else {
45 if (mesh->FullFullPattern==NULL) mesh->FullFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
46 }
47 }
48 if (Finley_noError()) {
49 if (reduce_row_order) {
50 if (reduce_col_order) {
51 out=Paso_SystemMatrixPattern_reference(mesh->ReducedReducedPattern);
52 } else {
53 out=Paso_SystemMatrixPattern_reference(mesh->ReducedFullPattern);
54 }
55 } else {
56 if (reduce_col_order) {
57 out=Paso_SystemMatrixPattern_reference(mesh->FullReducedPattern);
58 } else {
59 out=Paso_SystemMatrixPattern_reference(mesh->FullFullPattern);
60 }
61 }
62 }
63 return out;
64 }
65 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
66 double time0;
67 Paso_SystemMatrixPattern* out=NULL;
68 Paso_Pattern *main_pattern = NULL, *couple_pattern=NULL;
69 Paso_Coupler *coupler;
70 Finley_IndexList* index_list=NULL;
71 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
72 Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
73
74 index_t i,j;
75 Finley_resetError();
76 time0=Finley_timer();
77
78 if (reduce_col_order) {
79 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
80 colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
81 coupler=mesh->Nodes->reducedDegreesOfFreedomCoupler;
82
83 } else {
84 colMap=mesh->Nodes->degreesOfFreedomMapping;
85 colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
86 coupler=mesh->Nodes->degreesOfFreedomCoupler;
87 }
88
89 if (reduce_row_order) {
90 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
91 rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
92 } else {
93 rowMap=mesh->Nodes->degreesOfFreedomMapping;
94 rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
95 }
96
97 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
98 if (! Finley_checkPtr(index_list)) {
99
100 #pragma omp parallel private(i)
101 {
102 #pragma omp for schedule(static)
103 for(i=0;i<rowMap->numTargets;++i) {
104 index_list[i].extension=NULL;
105 index_list[i].n=0;
106 }
107 /* insert contributions from element matrices into colums index index_list: */
108 Finley_IndexList_insertElements(index_list,mesh->Elements,
109 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
110 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
111 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
112 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
113 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
114 Finley_IndexList_insertElements(index_list,mesh->Points,
115 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
116
117 }
118
119 /* create pattern */
120 main_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),index_list,0,Paso_Distribution_getMyNumComponents(colDistribution),0);
121 couple_pattern=Finley_IndexList_createPattern(Paso_Distribution_getMyNumComponents(rowDistribution),index_list,Paso_Distribution_getMyNumComponents(colDistribution),colMap->numTargets,-Paso_Distribution_getMyNumComponents(colDistribution));
122 /* if everthing is in order we can create the return value */
123 if (Finley_noError()) {
124 out=Paso_SystemMatrixPattern_alloc(PATTERN_FORMAT_DEFAULT,
125 rowDistribution,
126 colDistribution,
127 main_pattern,
128 couple_pattern,
129 coupler);
130 }
131 /* clean up */
132 if (index_list!=NULL) {
133 #pragma omp parallel for private(i)
134 for(i=0;i<rowMap->numTargets;++i) Finley_IndexList_free(index_list[i].extension);
135 }
136 TMPMEMFREE(index_list);
137 Paso_Pattern_free(main_pattern);
138 Paso_Pattern_free(couple_pattern);
139 }
140 #ifdef Finley_TRACE
141 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
142 #endif
143 Paso_MPIInfo_noError(mesh->MPIInfo);
144 return out;
145 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26