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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 4 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_line3.c
File MIME type: text/plain
File size: 4368 byte(s)
Initial revision

1 /**************************************************************/
2
3 /* Finley: generates rectangular meshes */
4
5 /* Generates numElements[0] mesh with second order elements (Line3) in the interval */
6 /* [0,Length[0]]. order is the desired accuracy of the integration scheme. */
7
8 /**************************************************************/
9
10 /* Copyrights by ACcESS Australia 2003/04 */
11 /* Author: gross@access.edu.au */
12 /* Version: $Id$ */
13
14 /**************************************************************/
15
16 #include "Common.h"
17 #include "Finley.h"
18 #include "Mesh.h"
19 #include "RectangularMesh.h"
20
21 /**************************************************************/
22
23 Finley_Mesh* Finley_RectangularMesh_Line3(int* numElements,double* Length,int* periodic,int order,int useElementsOnFace) {
24 int N0,NE0,i0,k,node0,NDOF0,NFaceElements,NUMNODES;
25 Finley_Mesh* out;
26 char name[50];
27 double time0=Finley_timer();
28 NE0=MAX(1,numElements[0]);
29 N0=2*NE0+1;
30 if (!periodic[0]) {
31 NDOF0=N0;
32 NFaceElements=2;
33 } else {
34 NDOF0=N0-1;
35 NFaceElements=0;
36 }
37
38 /* allocate mesh: */
39
40 sprintf(name,"Rectangular mesh with %d nodes",N0);
41 out=Finley_Mesh_alloc(name,1,order);
42 if (Finley_ErrorCode!=NO_ERROR) return NULL;
43
44 out->Elements=Finley_ElementFile_alloc(Line3,out->order);
45 if (useElementsOnFace) {
46 out->FaceElements=Finley_ElementFile_alloc(Line3Face,out->order);
47 out->ContactElements=Finley_ElementFile_alloc(Line3Face_Contact,out->order);
48 } else {
49 out->FaceElements=Finley_ElementFile_alloc(Point1,out->order);
50 out->ContactElements=Finley_ElementFile_alloc(Point1_Contact,out->order);
51 }
52 out->Points=Finley_ElementFile_alloc(Point1,out->order);
53 if (Finley_ErrorCode!=NO_ERROR) {
54 Finley_Mesh_dealloc(out);
55 return NULL;
56 }
57
58 /* allocate tables: */
59
60 Finley_NodeFile_allocTable(out->Nodes,N0);
61 Finley_ElementFile_allocTable(out->Elements,NE0);
62 Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
63 if (Finley_ErrorCode!=NO_ERROR) {
64 Finley_Mesh_dealloc(out);
65 return NULL;
66 }
67
68 /* set nodes: */
69
70 #pragma omp parallel for private(i0,k)
71 for (i0=0;i0<N0;i0++) {
72 k=i0;
73 out->Nodes->Coordinates[INDEX2(0,k,1)]=DBLE(i0)/DBLE(N0-1)*Length[0];
74 out->Nodes->Id[k]=k;
75 out->Nodes->Tag[k]=0;
76 out->Nodes->degreeOfFreedom[k]=(i0%NDOF0);
77 }
78 if (!periodic[0]) {
79 out->Nodes->Tag[0]=1;
80 out->Nodes->Tag[N0-1]=2;
81 }
82
83 /* set the elements: */
84
85 #pragma omp parallel for private(i0,k,node0)
86 for (i0=0;i0<NE0;i0++) {
87 k=i0;
88 node0=2*i0;
89
90 out->Elements->Id[k]=k;
91 out->Elements->Tag[k]=0;
92 out->Elements->Color[k]=COLOR_MOD(i0);
93
94 out->Elements->Nodes[INDEX2(0,k,3)]=node0;
95 out->Elements->Nodes[INDEX2(1,k,3)]=node0+2;
96 out->Elements->Nodes[INDEX2(2,k,3)]=node0+1;
97 }
98 out->Elements->numColors=COLOR_MOD(0)+1;
99
100 /* face elements: */
101 if (useElementsOnFace) {
102 NUMNODES=3;
103 } else {
104 NUMNODES=1;
105 }
106
107 if (!periodic[0]) {
108 out->FaceElements->Id[0]=NE0;
109 out->FaceElements->Tag[0]=1;
110 out->FaceElements->Color[0]=0;
111 if (useElementsOnFace) {
112 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
113 out->FaceElements->Nodes[INDEX2(1,0,NUMNODES)]=2;
114 out->FaceElements->Nodes[INDEX2(2,0,NUMNODES)]=1;
115 } else {
116 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
117 }
118
119 out->FaceElements->Id[1]=NE0+1;
120 out->FaceElements->Tag[1]=2;
121 out->FaceElements->Color[1]=1;
122 if (useElementsOnFace) {
123 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
124 out->FaceElements->Nodes[INDEX2(1,1,NUMNODES)]=N0-3;
125 out->FaceElements->Nodes[INDEX2(2,1,NUMNODES)]=N0-2;
126 } else {
127 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
128 }
129 }
130 out->FaceElements->numColors=2;
131
132 /* face elements done: */
133
134 /* condense the nodes: */
135
136 Finley_Mesh_resolveNodeIds(out);
137
138 /* prepare mesh for further calculations:*/
139
140 Finley_Mesh_prepare(out) ;
141
142 printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
143
144 if (Finley_ErrorCode!=NO_ERROR) {
145 Finley_Mesh_dealloc(out);
146 return NULL;
147 }
148 return out;
149 }
150
151 /*
152 * $Log$
153 * Revision 1.1 2004/10/26 06:53:57 jgs
154 * Initial revision
155 *
156 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
157 * Initial version of eys using boost-python.
158 *
159 *
160 */
161

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26