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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26