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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1762 - (hide annotations)
Mon Sep 8 02:42:39 2008 UTC (11 years, 3 months ago) by gross
File MIME type: text/plain
File size: 34893 byte(s)
some formatting
1 jgs 150
2 ksteube 1312 /* $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 jgs 82 /**************************************************************/
17    
18     /* Finley: generates rectangular meshes */
19    
20     /* Generates a numElements[0] x numElements[1] x numElements[2] mesh with second order elements (Hex20) in the brick */
21     /* [0,Length[0]] x [0,Length[1]] x [0,Length[2]]. order is the desired accuracy of the */
22     /* integration scheme. */
23    
24    
25     /**************************************************************/
26    
27     #include "RectangularMesh.h"
28    
29 ksteube 1312 Finley_Mesh* Finley_RectangularMesh_Hex20(dim_t* numElements,
30     double* Length,
31     bool_t* periodic,
32     index_t order,
33     index_t reduced_order,
34     bool_t useElementsOnFace,
35     bool_t useFullElementOrder,
36     bool_t optimize)
37 bcumming 782 {
38 ksteube 1312 #define N_PER_E 2
39     #define DIM 3
40     dim_t N0,N1,N2,NE0,NE1,NE2,i0,i1,i2,k,Nstride0,Nstride1,Nstride2, local_NE0, local_NE1, local_NE2;
41     dim_t totalNECount,faceNECount,NDOF0,NDOF1,NDOF2,NFaceElements, local_N0, local_N1, local_N2, NN;
42     index_t node0, myRank, e_offset0, e_offset1, e_offset2, offset0, offset1, offset2, global_i0, global_i1, global_i2;
43     Finley_Mesh* out;
44     Paso_MPIInfo *mpi_info = NULL;
45     char name[50];
46     double time0=Finley_timer();
47 bcumming 782
48 ksteube 1312 /* get MPI information */
49     mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
50     if (! Finley_noError()) {
51     return NULL;
52 bcumming 782 }
53 ksteube 1312 myRank=mpi_info->rank;
54 bcumming 782
55 ksteube 1312 /* set up the global dimensions of the mesh */
56 bcumming 782
57 jgs 82 NE0=MAX(1,numElements[0]);
58     NE1=MAX(1,numElements[1]);
59     NE2=MAX(1,numElements[2]);
60 ksteube 1312 N0=N_PER_E*NE0+1;
61     N1=N_PER_E*NE1+1;
62     N2=N_PER_E*NE2+1;
63 jgs 82
64 ksteube 1312 /* allocate mesh: */
65     sprintf(name,"Rectangular %d x %d x %d mesh",N0,N1,N2);
66     out=Finley_Mesh_alloc(name,DIM,order, reduced_order, mpi_info);
67     if (! Finley_noError()) {
68     Paso_MPIInfo_free( mpi_info );
69     return NULL;
70     }
71    
72     if (useFullElementOrder) {
73 gross 1414 /* Finley_setError(SYSTEM_ERROR,"full element order for Hex elements is not supported yet."); */
74 ksteube 1312 Finley_Mesh_setElements(out,Finley_ElementFile_alloc(Hex27,
75     out->order,
76     out->reduced_order,
77 gross 1414 mpi_info));
78 ksteube 1312 if (useElementsOnFace) {
79     Finley_setError(SYSTEM_ERROR,"rich elements for Hex27 elements is not supported yet.");
80 jgs 153 } else {
81 ksteube 1312 Finley_Mesh_setFaceElements(out,Finley_ElementFile_alloc(Rec9,
82     out->order,
83     out->reduced_order,
84     mpi_info));
85     Finley_Mesh_setContactElements(out,Finley_ElementFile_alloc(Rec9_Contact,
86     out->order,
87     out->reduced_order,
88     mpi_info));
89 jgs 153 }
90 ksteube 1312
91     } else {
92     Finley_Mesh_setElements(out,Finley_ElementFile_alloc(Hex20,out->order,out->reduced_order,mpi_info));
93     if (useElementsOnFace) {
94     Finley_Mesh_setFaceElements(out,Finley_ElementFile_alloc(Hex20Face,
95     out->order,
96     out->reduced_order,
97     mpi_info));
98     Finley_Mesh_setContactElements(out,Finley_ElementFile_alloc(Hex20Face_Contact,
99     out->order,
100     out->reduced_order,
101     mpi_info));
102 jgs 153 } else {
103 ksteube 1312 Finley_Mesh_setFaceElements(out,Finley_ElementFile_alloc(Rec8,
104     out->order,
105     out->reduced_order,
106     mpi_info));
107     Finley_Mesh_setContactElements(out,Finley_ElementFile_alloc(Rec8_Contact,
108     out->order,
109     out->reduced_order,
110     mpi_info));
111 jgs 153 }
112     }
113 ksteube 1312 Finley_Mesh_setPoints(out,Finley_ElementFile_alloc(Point1,
114     out->order,
115     out->reduced_order,
116     mpi_info));
117 bcumming 782 if (! Finley_noError()) {
118 ksteube 1312 Paso_MPIInfo_free( mpi_info );
119     Finley_Mesh_free(out);
120 bcumming 782 return NULL;
121     }
122    
123 ksteube 1312 /* work out the largest dimension */
124     if (N2==MAX3(N0,N1,N2)) {
125     Nstride0=1;
126     Nstride1=N0;
127     Nstride2=N0*N1;
128     local_NE0=NE0;
129     e_offset0=0;
130     local_NE1=NE1;
131     e_offset1=0;
132     Paso_MPIInfo_Split(mpi_info,NE2,&local_NE2,&e_offset2);
133     } else if (N1==MAX3(N0,N1,N2)) {
134     Nstride0=N2;
135     Nstride1=N0*N2;
136     Nstride2=1;
137     local_NE0=NE0;
138     e_offset0=0;
139     Paso_MPIInfo_Split(mpi_info,NE1,&local_NE1,&e_offset1);
140     local_NE2=NE2;
141     e_offset2=0;
142 jgs 82 } else {
143 ksteube 1312 Nstride0=N1*N2;
144     Nstride1=1;
145     Nstride2=N1;
146     Paso_MPIInfo_Split(mpi_info,NE0,&local_NE0,&e_offset0);
147     local_NE1=NE1;
148     e_offset1=0;
149     local_NE2=NE2;
150     e_offset2=0;
151 jgs 82 }
152 ksteube 1312 offset0=e_offset0*N_PER_E;
153     offset1=e_offset1*N_PER_E;
154     offset2=e_offset2*N_PER_E;
155 gross 1733 local_N0=local_NE0>0 ? local_NE0*N_PER_E+1 : 0;
156     local_N1=local_NE1>0 ? local_NE1*N_PER_E+1 : 0;
157     local_N2=local_NE0>0 ? local_NE2*N_PER_E+1 : 0;
158 jgs 82
159 ksteube 1312 /* get the number of surface elements */
160 jgs 153
161 ksteube 1312 NFaceElements=0;
162 gross 1733 if (!periodic[2] && (local_NE2>0) ) {
163 ksteube 1312 NDOF2=N2;
164     if (offset2==0) NFaceElements+=local_NE1*local_NE0;
165     if (local_NE2+e_offset2 == NE2) NFaceElements+=local_NE1*local_NE0;
166     } else {
167     NDOF2=N2-1;
168 jgs 82 }
169 ksteube 1312
170 gross 1733 if (!periodic[0] && (local_NE1>0) ) {
171 ksteube 1312 NDOF0=N0;
172     if (e_offset0 == 0) NFaceElements+=local_NE1*local_NE2;
173     if (local_NE0+e_offset0 == NE0) NFaceElements+=local_NE1*local_NE2;
174     } else {
175     NDOF0=N0-1;
176 jgs 82 }
177 gross 1733 if (!periodic[1] && (local_NE1>0) ) {
178 ksteube 1312 NDOF1=N1;
179     if (e_offset1 == 0) NFaceElements+=local_NE0*local_NE2;
180     if (local_NE1+e_offset1 == NE1) NFaceElements+=local_NE0*local_NE2;
181 jgs 82 } else {
182 ksteube 1312 NDOF1=N1-1;
183 jgs 82 }
184 ksteube 1312 /* allocate tables: */
185 jgs 82
186 ksteube 1312 Finley_NodeFile_allocTable(out->Nodes,local_N0*local_N1*local_N2);
187     Finley_ElementFile_allocTable(out->Elements,local_NE0*local_NE1*local_NE2);
188     Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
189 jgs 82
190 ksteube 1312 if (Finley_noError()) {
191     /* create nodes */
192 jgs 82
193 ksteube 1312 #pragma omp parallel for private(i0,i1,i2,k,global_i0,global_i1,global_i2)
194     for (i2=0;i2<local_N2;i2++) {
195     for (i1=0;i1<local_N1;i1++) {
196     for (i0=0;i0<local_N0;i0++) {
197     k=i0+local_N0*i1+local_N0*local_N1*i2;
198     global_i0=i0+offset0;
199     global_i1=i1+offset1;
200     global_i2=i2+offset2;
201     out->Nodes->Coordinates[INDEX2(0,k,DIM)]=DBLE(global_i0)/DBLE(N0-1)*Length[0];
202     out->Nodes->Coordinates[INDEX2(1,k,DIM)]=DBLE(global_i1)/DBLE(N1-1)*Length[1];
203     out->Nodes->Coordinates[INDEX2(2,k,DIM)]=DBLE(global_i2)/DBLE(N2-1)*Length[2];
204     out->Nodes->Id[k]=Nstride0*global_i0+Nstride1*global_i1+Nstride2*global_i2;
205     out->Nodes->Tag[k]=0;
206     out->Nodes->globalDegreesOfFreedom[k]=Nstride0*(global_i0%NDOF0)
207     +Nstride1*(global_i1%NDOF1)
208     +Nstride2*(global_i2%NDOF2);
209 jgs 82 }
210     }
211     }
212 ksteube 1312 /* set the elements: */
213     NN=out->Elements->numNodes;
214     #pragma omp parallel for private(i0,i1,i2,k,node0)
215     for (i2=0;i2<local_NE2;i2++) {
216     for (i1=0;i1<local_NE1;i1++) {
217     for (i0=0;i0<local_NE0;i0++) {
218    
219     k=i0+local_NE0*i1+local_NE0*local_NE1*i2;
220     node0=Nstride0*N_PER_E*(i0+e_offset0)+Nstride1*N_PER_E*(i1+e_offset1)+Nstride2*N_PER_E*(i2+e_offset2);
221 jgs 82
222 ksteube 1312 out->Elements->Id[k]=(i0+e_offset0)+NE0*(i1+e_offset1)+NE0*NE1*(i2+e_offset2);
223     out->Elements->Tag[k]=0;
224     out->Elements->Owner[k]=myRank;
225 jgs 82
226 ksteube 1312 out->Elements->Nodes[INDEX2(0,k,NN)] =node0 ;
227     out->Elements->Nodes[INDEX2(1,k,NN)] =node0+ 2*Nstride0;
228     out->Elements->Nodes[INDEX2(2,k,NN)] =node0+ 2*Nstride1+2*Nstride0;
229     out->Elements->Nodes[INDEX2(3,k,NN)] =node0+ 2*Nstride1;
230     out->Elements->Nodes[INDEX2(4,k,NN)] =node0+2*Nstride2 ;
231     out->Elements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride2 +2*Nstride0;
232     out->Elements->Nodes[INDEX2(6,k,NN)] =node0+2*Nstride2+2*Nstride1+2*Nstride0;
233     out->Elements->Nodes[INDEX2(7,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
234     out->Elements->Nodes[INDEX2(8,k,NN)] =node0+ 1*Nstride0;
235     out->Elements->Nodes[INDEX2(9,k,NN)] =node0+ 1*Nstride1+2*Nstride0;
236     out->Elements->Nodes[INDEX2(10,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
237     out->Elements->Nodes[INDEX2(11,k,NN)]=node0+ 1*Nstride1 ;
238     out->Elements->Nodes[INDEX2(12,k,NN)]=node0+1*Nstride2 ;
239     out->Elements->Nodes[INDEX2(13,k,NN)]=node0+1*Nstride2 +2*Nstride0;
240     out->Elements->Nodes[INDEX2(14,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
241     out->Elements->Nodes[INDEX2(15,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
242     out->Elements->Nodes[INDEX2(16,k,NN)]=node0+2*Nstride2 +1*Nstride0;
243     out->Elements->Nodes[INDEX2(17,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
244     out->Elements->Nodes[INDEX2(18,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
245     out->Elements->Nodes[INDEX2(19,k,NN)]=node0+2*Nstride2+1*Nstride1 ;
246     if (useFullElementOrder) {
247     out->Elements->Nodes[INDEX2(20,k,NN)]=node0+ 1*Nstride1+1*Nstride0;
248     out->Elements->Nodes[INDEX2(21,k,NN)]=node0+1*Nstride2 +1*Nstride0;
249     out->Elements->Nodes[INDEX2(22,k,NN)]=node0+1*Nstride2+1*Nstride1+2*Nstride0;
250     out->Elements->Nodes[INDEX2(23,k,NN)]=node0+1*Nstride2+2*Nstride1+1*Nstride0;
251     out->Elements->Nodes[INDEX2(24,k,NN)]=node0+1*Nstride2+1*Nstride1 ;
252     out->Elements->Nodes[INDEX2(25,k,NN)]=node0+2*Nstride2+1*Nstride1+1*Nstride0;
253     out->Elements->Nodes[INDEX2(26,k,NN)]=node0+1*Nstride2+1*Nstride1+1*Nstride0;
254     }
255 jgs 82 }
256     }
257     }
258 ksteube 1312 /* face elements */
259     NN=out->FaceElements->numNodes;
260     totalNECount=NE0*NE1*NE2;
261     faceNECount=0;
262     /* these are the quadrilateral elements on boundary 1 (x3=0): */
263 gross 1733 if (!periodic[2] && (local_NE2>0)) {
264 ksteube 1312 /* ** elements on boundary 100 (x3=0): */
265     if (offset2==0) {
266     #pragma omp parallel for private(i0,i1,k,node0)
267     for (i1=0;i1<local_NE1;i1++) {
268     for (i0=0;i0<local_NE0;i0++) {
269    
270     k=i0+local_NE0*i1+faceNECount;
271     node0=Nstride0*N_PER_E*(i0+e_offset0)+Nstride1*N_PER_E*(i1+e_offset1);
272    
273     out->FaceElements->Id[k]=(i0+e_offset0)+NE0*(i1+e_offset1)+totalNECount;
274     out->FaceElements->Tag[k]=100;
275     out->FaceElements->Owner[k]=myRank;
276    
277     if (useElementsOnFace) {
278     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0 ;
279     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0 +2*Nstride1 ;
280     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0 +2*Nstride1+2*Nstride0;
281     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+ 2*Nstride0 ;
282     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0+2*Nstride2 ;
283     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
284     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+2*Nstride2+2*Nstride1+2*Nstride0;
285     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+2*Nstride2 +2*Nstride0;
286     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+ 1*Nstride1 ;
287     out->FaceElements->Nodes[INDEX2(9,k,NN)] =node0+ 2*Nstride1+1*Nstride0;
288     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
289     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+ 1*Nstride0;
290     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+1*Nstride2 ;
291     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
292     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
293     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+1*Nstride2 +2*Nstride0;
294     out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+2*Nstride2+1*Nstride1;
295     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
296     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
297     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+2*Nstride2 +1*Nstride0;
298     } else {
299     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0 ;
300     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0+ 2*Nstride1 ;
301     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0+ 2*Nstride1+2*Nstride0;
302     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+ 2*Nstride0;
303     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0+ 1*Nstride1 ;
304     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+ 2*Nstride1+1*Nstride0;
305     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+ 1*Nstride1+2*Nstride0;
306     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+ 1*Nstride0;
307     if (useFullElementOrder){
308     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+ 1*Nstride1+1*Nstride0;
309     }
310     }
311     }
312     }
313     faceNECount+=local_NE1*local_NE0;
314 jgs 82 }
315 ksteube 1312 totalNECount+=NE1*NE0;
316     /* ** elements on boundary 200 (x3=1) */
317     if (local_NE2+e_offset2 == NE2) {
318     #pragma omp parallel for private(i0,i1,k,node0)
319     for (i1=0;i1<local_NE1;i1++) {
320     for (i0=0;i0<local_NE0;i0++) {
321    
322     k=i0+local_NE0*i1+faceNECount;
323     node0=Nstride0*N_PER_E*(i0+e_offset0)+Nstride1*N_PER_E*(i1+e_offset1)+Nstride2*N_PER_E*(NE2-1);
324    
325     out->FaceElements->Id[k]=(i0+e_offset0)+NE0*(i1+e_offset1)+totalNECount;
326     out->FaceElements->Tag[k]=200;
327     out->FaceElements->Owner[k]=myRank;
328     if (useElementsOnFace) {
329     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0+2*Nstride2 ;
330     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0+2*Nstride2+ 2*Nstride0;
331     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0+2*Nstride2+2*Nstride1+2*Nstride0;
332     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
333    
334     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0 ;
335     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride0 ;
336     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+ 2*Nstride1+2*Nstride0;
337     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+ 2*Nstride1;
338    
339     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+2*Nstride2+ 1*Nstride0;
340     out->FaceElements->Nodes[INDEX2(9,k,NN)] =node0+2*Nstride2+1*Nstride1+2*Nstride0;
341     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
342     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+2*Nstride2+1*Nstride1 ;
343    
344     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+1*Nstride2;
345     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+1*Nstride2 +2*Nstride0;
346     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
347     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
348    
349     out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+ 1*Nstride0;
350     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
351     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
352     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+ 1*Nstride1 ;
353    
354     } else {
355     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0+2*Nstride2 ;
356     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0+2*Nstride2 +2*Nstride0;
357     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0+2*Nstride2+2*Nstride1+2*Nstride0;
358     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
359     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0+2*Nstride2 +1*Nstride0;
360     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride2+1*Nstride1+2*Nstride0;
361     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+2*Nstride2+2*Nstride1+1*Nstride0;
362     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+2*Nstride2+1*Nstride1 ;
363     if (useFullElementOrder){
364     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+2*Nstride2+1*Nstride1+1*Nstride0;
365     }
366     }
367     }
368     }
369     faceNECount+=local_NE1*local_NE0;
370     }
371     totalNECount+=NE1*NE0;
372 jgs 82 }
373 gross 1733 if (!periodic[0] && (local_NE0>0)) {
374 ksteube 1312 /* ** elements on boundary 001 (x1=0): */
375 jgs 82
376 ksteube 1312 if (e_offset0 == 0) {
377     #pragma omp parallel for private(i1,i2,k,node0)
378     for (i2=0;i2<local_NE2;i2++) {
379     for (i1=0;i1<local_NE1;i1++) {
380    
381     k=i1+local_NE1*i2+faceNECount;
382     node0=Nstride1*N_PER_E*(i1+e_offset1)+Nstride2*N_PER_E*(i2+e_offset2);
383     out->FaceElements->Id[k]=(i1+e_offset1)+NE1*(i2+e_offset2)+totalNECount;
384     out->FaceElements->Tag[k]=1;
385     out->FaceElements->Owner[k]=myRank;
386    
387     if (useElementsOnFace) {
388     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0 ;
389     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0+2*Nstride2 ;
390     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
391     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+2*Nstride1 ;
392    
393     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0+2*Nstride0 ;
394     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride2+2*Nstride0 ;
395     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+2*Nstride2+2*Nstride1+2*Nstride0;
396     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+2*Nstride1+2*Nstride0 ;
397    
398     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+1*Nstride2 ;
399     out->FaceElements->Nodes[INDEX2(9,k,NN)] =node0+2*Nstride2+1*Nstride1 ;
400     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
401     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+ 1*Nstride1 ;
402    
403     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+ 1*Nstride0;
404     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+2*Nstride2 +1*Nstride0;
405     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
406     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+2*Nstride1+ 1*Nstride0;
407    
408     out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+1*Nstride2+ 2*Nstride0;
409     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
410     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
411     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+1*Nstride1+ 2*Nstride0;
412    
413     } else {
414     out->FaceElements->Nodes[INDEX2(0,k,NN)] =node0 ;
415     out->FaceElements->Nodes[INDEX2(1,k,NN)] =node0+2*Nstride2 ;
416     out->FaceElements->Nodes[INDEX2(2,k,NN)] =node0+2*Nstride2+2*Nstride1 ;
417     out->FaceElements->Nodes[INDEX2(3,k,NN)] =node0+ 2*Nstride1 ;
418     out->FaceElements->Nodes[INDEX2(4,k,NN)] =node0+1*Nstride2 ;
419     out->FaceElements->Nodes[INDEX2(5,k,NN)] =node0+2*Nstride2+1*Nstride1 ;
420     out->FaceElements->Nodes[INDEX2(6,k,NN)] =node0+1*Nstride2+2*Nstride1 ;
421     out->FaceElements->Nodes[INDEX2(7,k,NN)] =node0+ 1*Nstride1 ;
422     if (useFullElementOrder){
423     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+1*Nstride2+1*Nstride1 ;
424     }
425     }
426     }
427     }
428     faceNECount+=local_NE1*local_NE2;
429     }
430     totalNECount+=NE1*NE2;
431    
432     /* ** elements on boundary 002 (x1=1): */
433     if (local_NE0+e_offset0 == NE0) {
434     #pragma omp parallel for private(i1,i2,k,node0)
435     for (i2=0;i2<local_NE2;i2++) {
436     for (i1=0;i1<local_NE1;i1++) {
437     k=i1+local_NE1*i2+faceNECount;
438     node0=Nstride0*N_PER_E*(NE0-1)+Nstride1*N_PER_E*(i1+e_offset1)+Nstride2*N_PER_E*(i2+e_offset2);
439     out->FaceElements->Id[k]=(i1+e_offset1)+NE1*(i2+e_offset2)+totalNECount;
440     out->FaceElements->Tag[k]=2;
441     out->FaceElements->Owner[k]=myRank;
442 jgs 82
443 ksteube 1312 if (useElementsOnFace) {
444     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0+ 2*Nstride0;
445     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+ 2*Nstride1+2*Nstride0;
446     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2+2*Nstride1+2*Nstride0;
447     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+2*Nstride2+ 2*Nstride0;
448    
449     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0 ;
450     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+ 2*Nstride1 ;
451     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+2*Nstride2+2*Nstride1 ;
452     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+2*Nstride2 ;
453    
454     out->FaceElements->Nodes[INDEX2(8,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
455     out->FaceElements->Nodes[INDEX2(9,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
456     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
457     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+1*Nstride2+ 2*Nstride0;
458    
459     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+ 1*Nstride0;
460     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
461     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
462     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+2*Nstride2+ 1*Nstride0;
463    
464     out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+ 1*Nstride1 ;
465     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
466     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+2*Nstride2+1*Nstride1 ;
467     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+1*Nstride2 ;
468    
469     } else {
470     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0 +2*Nstride0;
471     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+ 2*Nstride1+2*Nstride0;
472     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2+2*Nstride1+2*Nstride0;
473     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+2*Nstride2+ 2*Nstride0;
474     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
475     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
476     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
477     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+1*Nstride2 +2*Nstride0;
478     if (useFullElementOrder){
479     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+1*Nstride2+1*Nstride1+2*Nstride0;
480     }
481     }
482    
483     }
484     }
485     faceNECount+=local_NE1*local_NE2;
486 jgs 82 }
487 ksteube 1312 totalNECount+=NE1*NE2;
488 jgs 82 }
489 gross 1733 if (!periodic[1] && (local_NE1>0)) {
490 ksteube 1312 /* ** elements on boundary 010 (x2=0): */
491     if (e_offset1 == 0) {
492     #pragma omp parallel for private(i0,i2,k,node0)
493     for (i2=0;i2<local_NE2;i2++) {
494     for (i0=0;i0<local_NE0;i0++) {
495     k=i0+local_NE0*i2+faceNECount;
496     node0=Nstride0*N_PER_E*(i0+e_offset0)+Nstride2*N_PER_E*(i2+e_offset2);
497    
498     out->FaceElements->Id[k]=(i2+e_offset2)+NE2*(e_offset0+i0)+totalNECount;
499     out->FaceElements->Tag[k]=10;
500     out->FaceElements->Owner[k]=myRank;
501     if (useElementsOnFace) {
502     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0 ;
503     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+ 2*Nstride0;
504     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2 +2*Nstride0;
505     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+2*Nstride2 ;
506    
507     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0+ 2*Nstride1 ;
508     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+2*Nstride1+ 2*Nstride0;
509     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+2*Nstride2+2*Nstride1+2*Nstride0;
510     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+2*Nstride2+2*Nstride1 ;
511    
512     out->FaceElements->Nodes[INDEX2(8,k,NN)]=node0+ 1*Nstride0;
513     out->FaceElements->Nodes[INDEX2(9,k,NN)]=node0+1*Nstride2+ 2*Nstride0;
514     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+2*Nstride2+ 1*Nstride0;
515     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+1*Nstride2 ;
516    
517     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+ 1*Nstride1 ;
518     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
519     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
520     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+2*Nstride2+1*Nstride1 ;
521 bcumming 782
522 ksteube 1312 out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
523     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
524     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
525     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
526    
527     } else {
528     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0 ;
529     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+ 2*Nstride0;
530     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2+ 2*Nstride0;
531     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+2*Nstride2 ;
532     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0+ 1*Nstride0;
533     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+1*Nstride2+ 2*Nstride0;
534     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+2*Nstride2+ 1*Nstride0;
535     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+1*Nstride2 ;
536     if (useFullElementOrder){
537     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+1*Nstride2+ 1*Nstride0;
538     }
539     }
540     }
541     }
542     faceNECount+=local_NE0*local_NE2;
543     }
544     totalNECount+=NE0*NE2;
545     /* ** elements on boundary 020 (x2=1): */
546     if (local_NE1+e_offset1 == NE1) {
547     #pragma omp parallel for private(i0,i2,k,node0)
548     for (i2=0;i2<local_NE2;i2++) {
549     for (i0=0;i0<local_NE0;i0++) {
550     k=i0+local_NE0*i2+faceNECount;
551     node0=Nstride0*N_PER_E*(i0+e_offset0)+Nstride1*N_PER_E*(NE1-1)+Nstride2*N_PER_E*(i2+e_offset2);
552 bcumming 782
553 ksteube 1312 out->FaceElements->Id[k]=(i2+e_offset2)+NE2*(i0+e_offset0)+totalNECount;
554     out->FaceElements->Tag[k]=20;
555     out->FaceElements->Owner[k]=myRank;
556    
557     if (useElementsOnFace) {
558     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0+ 2*Nstride1 ;
559     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+2*Nstride2+2*Nstride1 ;
560     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2+2*Nstride1+2*Nstride0;
561     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+2*Nstride1+2*Nstride0 ;
562    
563     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0 ;
564     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+2*Nstride2 ;
565     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+2*Nstride2+ 2*Nstride0;
566     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+ 2*Nstride0;
567    
568     out->FaceElements->Nodes[INDEX2(8,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
569     out->FaceElements->Nodes[INDEX2(9,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
570     out->FaceElements->Nodes[INDEX2(10,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
571     out->FaceElements->Nodes[INDEX2(11,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
572    
573     out->FaceElements->Nodes[INDEX2(12,k,NN)]=node0+ 1*Nstride1 ;
574     out->FaceElements->Nodes[INDEX2(13,k,NN)]=node0+2*Nstride2+1*Nstride1 ;
575     out->FaceElements->Nodes[INDEX2(14,k,NN)]=node0+2*Nstride2+1*Nstride1+2*Nstride0;
576     out->FaceElements->Nodes[INDEX2(15,k,NN)]=node0+ 1*Nstride1+2*Nstride0;
577    
578     out->FaceElements->Nodes[INDEX2(16,k,NN)]=node0+1*Nstride2 ;
579     out->FaceElements->Nodes[INDEX2(17,k,NN)]=node0+2*Nstride2 +1*Nstride0;
580     out->FaceElements->Nodes[INDEX2(18,k,NN)]=node0+1*Nstride2 +2*Nstride0;
581     out->FaceElements->Nodes[INDEX2(19,k,NN)]=node0+ 1*Nstride0;
582     } else {
583     out->FaceElements->Nodes[INDEX2(0,k,NN)]=node0+ 2*Nstride1 ;
584     out->FaceElements->Nodes[INDEX2(1,k,NN)]=node0+2*Nstride2+2*Nstride1 ;
585     out->FaceElements->Nodes[INDEX2(2,k,NN)]=node0+2*Nstride2+2*Nstride1+2*Nstride0;
586     out->FaceElements->Nodes[INDEX2(3,k,NN)]=node0+ 2*Nstride1+2*Nstride0;
587     out->FaceElements->Nodes[INDEX2(4,k,NN)]=node0+1*Nstride2+2*Nstride1 ;
588     out->FaceElements->Nodes[INDEX2(5,k,NN)]=node0+2*Nstride2+2*Nstride1+1*Nstride0;
589     out->FaceElements->Nodes[INDEX2(6,k,NN)]=node0+1*Nstride2+2*Nstride1+2*Nstride0;
590     out->FaceElements->Nodes[INDEX2(7,k,NN)]=node0+ 2*Nstride1+1*Nstride0;
591     if (useFullElementOrder){
592     out->FaceElements->Nodes[INDEX2(8,k,NN)] =node0+1*Nstride2+2*Nstride1+1*Nstride0;
593     }
594     }
595     }
596     }
597     faceNECount+=local_NE0*local_NE2;
598     }
599     totalNECount+=NE0*NE2;
600 bcumming 782 }
601 ksteube 1312 /* add tag names */
602     Finley_Mesh_addTagMap(out,"top", 200);
603     Finley_Mesh_addTagMap(out,"bottom", 100);
604     Finley_Mesh_addTagMap(out,"left", 1);
605     Finley_Mesh_addTagMap(out,"right", 2);
606     Finley_Mesh_addTagMap(out,"front", 10);
607     Finley_Mesh_addTagMap(out,"back", 20);
608 bcumming 782
609 ksteube 1312 /* prepare mesh for further calculatuions:*/
610     if (Finley_noError()) {
611     Finley_Mesh_resolveNodeIds(out);
612 bcumming 782 }
613 ksteube 1312 if (Finley_noError()) {
614     Finley_Mesh_prepare(out, optimize);
615 bcumming 782 }
616     }
617    
618 ksteube 1312 if (!Finley_noError()) {
619     Finley_Mesh_free(out);
620     }
621 bcumming 782 /* free up memory */
622 ksteube 1312 Paso_MPIInfo_free( mpi_info );
623 bcumming 782 #ifdef Finley_TRACE
624     printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
625     #endif
626 ksteube 1312
627     return out;
628 bcumming 782 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26