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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (12 years ago) by trankine
File MIME type: text/plain
File size: 5884 byte(s)
And get the *(&(*&(* name right
1 jgs 102
2 ksteube 1312 /* $Id$ */
3 jgs 102
4 ksteube 1312 /*******************************************************
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 jgs 102
16     /**************************************************************/
17    
18 ksteube 1312 /* Finley: Mesh */
19 jgs 102
20     /**************************************************************/
21    
22 jgs 150 #include "Mesh.h"
23 jgs 102 #include "IndexList.h"
24    
25     /**************************************************************/
26    
27     /* returns a reference to the matrix pattern */
28    
29 jgs 150 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 jgs 102 /* 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 jgs 150 if (Finley_noError()) {
47 jgs 102 if (reduce_row_order) {
48     if (reduce_col_order) {
49 jgs 150 out=Paso_SystemMatrixPattern_reference(mesh->ReducedReducedPattern);
50 jgs 102 } else {
51 jgs 150 out=Paso_SystemMatrixPattern_reference(mesh->ReducedFullPattern);
52 jgs 102 }
53     } else {
54     if (reduce_col_order) {
55 jgs 150 out=Paso_SystemMatrixPattern_reference(mesh->FullReducedPattern);
56 jgs 102 } else {
57 jgs 150 out=Paso_SystemMatrixPattern_reference(mesh->FullFullPattern);
58 jgs 102 }
59     }
60     }
61     return out;
62     }
63 jgs 150 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
64 jgs 102 double time0;
65 ksteube 1312 Paso_SystemMatrixPattern* out=NULL;
66     Paso_Pattern *main_pattern = NULL, *couple_pattern=NULL;
67     Paso_Coupler *coupler;
68 jgs 102 Finley_IndexList* index_list=NULL;
69 ksteube 1312 Finley_NodeMapping *colMap=NULL, *rowMap=NULL;
70     Paso_Distribution *colDistribution=NULL, *rowDistribution=NULL;
71    
72     index_t i,j;
73 jgs 150 Finley_resetError();
74 jgs 102 time0=Finley_timer();
75 ksteube 1312
76 jgs 102 if (reduce_col_order) {
77 ksteube 1312 colMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
78     colDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
79     coupler=mesh->Nodes->reducedDegreesOfFreedomCoupler;
80    
81 jgs 102 } else {
82 ksteube 1312 colMap=mesh->Nodes->degreesOfFreedomMapping;
83     colDistribution=mesh->Nodes->degreesOfFreedomDistribution;
84     coupler=mesh->Nodes->degreesOfFreedomCoupler;
85 jgs 102 }
86    
87     if (reduce_row_order) {
88 ksteube 1312 rowMap=mesh->Nodes->reducedDegreesOfFreedomMapping;
89     rowDistribution=mesh->Nodes->reducedDegreesOfFreedomDistribution;
90 jgs 102 } else {
91 ksteube 1312 rowMap=mesh->Nodes->degreesOfFreedomMapping;
92     rowDistribution=mesh->Nodes->degreesOfFreedomDistribution;
93 jgs 102 }
94    
95 ksteube 1312 index_list=TMPMEMALLOC(rowMap->numTargets,Finley_IndexList);
96     if (! Finley_checkPtr(index_list)) {
97    
98     #pragma omp parallel private(i)
99 jgs 102 {
100     #pragma omp for schedule(static)
101 ksteube 1312 for(i=0;i<rowMap->numTargets;++i) {
102 jgs 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 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->Elements,
107 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
108 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->FaceElements,
109 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
110 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->ContactElements,
111 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
112 ksteube 971 Finley_IndexList_insertElements(index_list,mesh->Points,
113 ksteube 1312 reduce_row_order,rowMap->target,reduce_col_order,colMap->target);
114    
115 jgs 102 }
116 ksteube 1312
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 jgs 102 }
138 jgs 149 #ifdef Finley_TRACE
139 jgs 102 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
140 jgs 149 #endif
141 ksteube 1312 Paso_MPIInfo_noError(mesh->MPIInfo);
142     return out;
143 jgs 102 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26