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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 201 - (show annotations)
Wed Nov 23 04:10:21 2005 UTC (13 years, 10 months ago) by jgs
File MIME type: text/plain
File size: 6961 byte(s)
copy finleyC and CPPAdapter to finley and finley/CPPAdapter to
facilitate scons builds

1 /*
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
15 /**************************************************************/
16
17 /* Finley: Mesh */
18
19 /**************************************************************/
20
21 /* Author: gross@access.edu.au */
22 /* Version: $Id$ */
23
24 /**************************************************************/
25
26 #include "Mesh.h"
27 #include "IndexList.h"
28
29 /**************************************************************/
30
31 /* returns a reference to the matrix pattern */
32
33 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 /* 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 if (Finley_noError()) {
51 if (reduce_row_order) {
52 if (reduce_col_order) {
53 out=Paso_SystemMatrixPattern_reference(mesh->ReducedReducedPattern);
54 } else {
55 out=Paso_SystemMatrixPattern_reference(mesh->ReducedFullPattern);
56 }
57 } else {
58 if (reduce_col_order) {
59 out=Paso_SystemMatrixPattern_reference(mesh->FullReducedPattern);
60 } else {
61 out=Paso_SystemMatrixPattern_reference(mesh->FullFullPattern);
62 }
63 }
64 }
65 return out;
66 }
67 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order) {
68 double time0;
69 dim_t i,n;
70 index_t s,itmp,*rowLabel=NULL,*colLabel=NULL, *ptr=NULL, *index=NULL;
71 Finley_IndexList* index_list=NULL;
72 Finley_resetError();
73
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 ptr=MEMALLOC(n+1,index_t);
93 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 for(i=0;i<n;++i) {
113 ptr[i]=Finley_IndexList_count(&index_list[i]);
114 }
115 /* 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 index=MEMALLOC(ptr[n],index_t);
128 }
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 #ifdef Finley_TRACE
144 printf("timing: mesh to matrix pattern: %.4e sec\n",Finley_timer()-time0);
145 #endif
146 if (! Finley_noError()) {
147 MEMFREE(ptr);
148 MEMFREE(index);
149 return NULL;
150 } else {
151 return Paso_SystemMatrixPattern_alloc(n,ptr,index);
152 }
153 }
154 /*
155 * $Log$
156 * 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 * 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 * 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 * 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 * 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 * Revision 1.2 2004/12/15 07:08:33 jgs
172 * *** empty log message ***
173 *
174 * 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 * 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