/[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 155 - (hide annotations)
Wed Nov 9 02:02:19 2005 UTC (13 years, 11 months ago) by jgs
Original Path: trunk/finley/src/finleyC/Mesh_getPattern.c
File MIME type: text/plain
File size: 6961 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26