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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (hide annotations)
Thu Sep 1 03:31:39 2005 UTC (14 years, 2 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_getPattern.c
File MIME type: text/plain
File size: 5960 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

1 jgs 102 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Finley: Mesh */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS Australia 2003, 2004 */
10     /* Author: gross@access.edu.au */
11    
12     /**************************************************************/
13    
14     #include "Finley.h"
15     #include "IndexList.h"
16     #include "System.h"
17     #include "Mesh.h"
18    
19     /**************************************************************/
20    
21     /* returns a reference to the matrix pattern */
22    
23 jgs 123 Finley_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
24 jgs 102 Finley_SystemMatrixPattern *out=NULL;
25     Finley_ErrorCode=NO_ERROR;
26     /* make sure that the requested pattern is available */
27     if (reduce_row_order) {
28     if (reduce_col_order) {
29     if (mesh->ReducedReducedPattern==NULL) mesh->ReducedReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
30     } else {
31     if (mesh->ReducedFullPattern==NULL) mesh->ReducedFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
32     }
33     } else {
34     if (reduce_col_order) {
35     if (mesh->FullReducedPattern==NULL) mesh->FullReducedPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
36     } else {
37     if (mesh->FullFullPattern==NULL) mesh->FullFullPattern=Finley_makePattern(mesh,reduce_row_order,reduce_col_order);
38     }
39     }
40     if (Finley_ErrorCode==NO_ERROR) {
41     if (reduce_row_order) {
42     if (reduce_col_order) {
43     out=Finley_SystemMatrixPattern_reference(mesh->ReducedReducedPattern);
44     } else {
45     out=Finley_SystemMatrixPattern_reference(mesh->ReducedFullPattern);
46     }
47     } else {
48     if (reduce_col_order) {
49     out=Finley_SystemMatrixPattern_reference(mesh->FullReducedPattern);
50     } else {
51     out=Finley_SystemMatrixPattern_reference(mesh->FullFullPattern);
52     }
53     }
54     }
55     return out;
56     }
57 jgs 123 Finley_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
58 jgs 102 double time0;
59 jgs 123 dim_t i,n;
60     index_t s,itmp,*rowLabel=NULL,*colLabel=NULL, *ptr=NULL, *index=NULL;
61 jgs 102 Finley_IndexList* index_list=NULL;
62     Finley_ErrorCode=NO_ERROR;
63    
64     time0=Finley_timer();
65     if (reduce_col_order) {
66     n=mesh->Nodes->reducedNumDegreesOfFreedom;
67     colLabel=mesh->Nodes->reducedDegreeOfFreedom;
68     } else {
69     n=mesh->Nodes->numDegreesOfFreedom;
70     colLabel=mesh->Nodes->degreeOfFreedom;
71     }
72    
73     if (reduce_row_order) {
74     n=mesh->Nodes->reducedNumDegreesOfFreedom;
75     rowLabel=mesh->Nodes->reducedDegreeOfFreedom;
76     } else {
77     n=mesh->Nodes->numDegreesOfFreedom;
78     rowLabel=mesh->Nodes->degreeOfFreedom;
79     }
80    
81     index_list=TMPMEMALLOC(n,Finley_IndexList);
82 jgs 123 ptr=MEMALLOC(n+1,index_t);
83 jgs 102 if (! (Finley_checkPtr(index_list) || Finley_checkPtr(ptr)) ) {
84     #pragma omp parallel private(i,s,itmp)
85     {
86     #pragma omp for schedule(static)
87     for(i=0;i<n;++i) {
88     index_list[i].extension=NULL;
89     index_list[i].n=0;
90     }
91     /* insert contributions from element matrices into colums index index_list: */
92     Finley_IndexList_insertElements(index_list,mesh->Elements,
93     reduce_row_order,rowLabel,reduce_col_order,colLabel);
94     Finley_IndexList_insertElements(index_list,mesh->FaceElements,
95     reduce_row_order,rowLabel,reduce_col_order,colLabel);
96     Finley_IndexList_insertElements(index_list,mesh->ContactElements,
97     reduce_row_order,rowLabel,reduce_col_order,colLabel);
98     Finley_IndexList_insertElements(index_list,mesh->Points,
99     reduce_row_order,rowLabel,reduce_col_order,colLabel);
100     /* get the number of connections per row */
101     #pragma omp for schedule(static)
102 jgs 123 for(i=0;i<n;++i) {
103     ptr[i]=Finley_IndexList_count(&index_list[i]);
104     }
105 jgs 102 /* accumalate ptr */
106     /* OMP */
107     #pragma omp master
108     {
109     s=0;
110     for(i=0;i<n;++i) {
111     itmp=ptr[i];
112     ptr[i]=s;
113     s+=itmp;
114     }
115     ptr[n]=s;
116     /* fill index */
117 jgs 123 index=MEMALLOC(ptr[n],index_t);
118 jgs 102 }
119     #pragma omp barrier
120     if (! Finley_checkPtr(index)) {
121     #pragma omp for schedule(static)
122     for(i=0;i<n;++i) Finley_IndexList_toArray(&index_list[i],&index[ptr[i]]);
123     }
124     }
125     }
126     /* all done */
127     /* clean up */
128     if (index_list!=NULL) {
129     #pragma omp parallel for private(i)
130     for(i=0;i<n;++i) Finley_IndexList_free(index_list[i].extension);
131     }
132     TMPMEMFREE(index_list);
133 jgs 149 #ifdef Finley_TRACE
134 jgs 102 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
135 jgs 149 #endif
136 jgs 102 if (Finley_ErrorCode!=NO_ERROR) {
137     MEMFREE(ptr);
138     MEMFREE(index);
139     return NULL;
140     } else {
141     return Finley_SystemMatrixPattern_alloc(n,ptr,index);
142     }
143     }
144     /*
145     * $Log$
146 jgs 149 * Revision 1.4 2005/09/01 03:31:35 jgs
147     * Merge of development branch dev-02 back to main trunk on 2005-09-01
148     *
149     * Revision 1.3.2.1 2005/08/24 02:02:18 gross
150     * timing output switched off. solver output can be swiched through getSolution(verbose=True) now.
151     *
152 jgs 123 * Revision 1.3 2005/07/08 04:07:52 jgs
153     * Merge of development branch back to main trunk on 2005-07-08
154     *
155 jgs 102 * Revision 1.2 2004/12/15 07:08:33 jgs
156     * *** empty log message ***
157     *
158 jgs 123 * Revision 1.1.2.5 2005/06/30 01:53:55 gross
159     * a bug in coloring fixed
160     *
161     * Revision 1.1.2.4 2005/06/29 02:34:51 gross
162     * some changes towards 64 integers in finley
163     *
164 jgs 102 * Revision 1.1.2.3 2004/11/24 01:37:14 gross
165     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
166     *
167     * Revision 1.1.2.1 2004/11/15 01:01:09 gross
168     * and anotther missing file
169     *
170     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26