/[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 730 - (show annotations)
Mon May 15 04:03:49 2006 UTC (13 years, 5 months ago) by bcumming
File MIME type: text/plain
File size: 5633 byte(s)


1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* Finley: generates rectangular meshes */
16
17 /* Generates numElements[0] mesh with second order elements (Line3) in the interval */
18 /* [0,Length[0]]. order is the desired accuracy of the integration scheme. */
19
20 /**************************************************************/
21
22 /* Author: gross@access.edu.au */
23 /* Version: $Id$ */
24
25 /**************************************************************/
26
27 #include "RectangularMesh.h"
28
29 /**************************************************************/
30
31 Finley_Mesh* Finley_RectangularMesh_Line3(dim_t* numElements,double* Length,bool_t* periodic,index_t order,bool_t useElementsOnFace) {
32 dim_t N0,NE0,i0,NDOF0,NFaceElements,NUMNODES;
33 index_t k,node0;
34 Finley_Mesh* out;
35 char name[50];
36 double time0=Finley_timer();
37 NE0=MAX(1,numElements[0]);
38 N0=2*NE0+1;
39 if (!periodic[0]) {
40 NDOF0=N0;
41 NFaceElements=2;
42 } else {
43 NDOF0=N0-1;
44 NFaceElements=0;
45 }
46
47 /* allocate mesh: */
48
49 sprintf(name,"Rectangular mesh with %d nodes",N0);
50 /* TEMPFIX */
51 #ifndef PASO_MPI
52 out=Finley_Mesh_alloc(name,1,order);
53 if (! Finley_noError()) return NULL;
54
55 out->Elements=Finley_ElementFile_alloc(Line3,out->order);
56 if (useElementsOnFace) {
57 out->FaceElements=Finley_ElementFile_alloc(Line3Face,out->order);
58 out->ContactElements=Finley_ElementFile_alloc(Line3Face_Contact,out->order);
59 } else {
60 out->FaceElements=Finley_ElementFile_alloc(Point1,out->order);
61 out->ContactElements=Finley_ElementFile_alloc(Point1_Contact,out->order);
62 }
63 out->Points=Finley_ElementFile_alloc(Point1,out->order);
64 #else
65 /* TODO */
66 PASO_MPI_TODO;
67 out = NULL;
68 #endif
69 if (! Finley_noError()) {
70 Finley_Mesh_dealloc(out);
71 return NULL;
72 }
73
74 /* allocate tables: */
75 #ifndef PASO_MPI
76 Finley_NodeFile_allocTable(out->Nodes,N0);
77 #else
78 /* TODO */
79 #endif
80 Finley_ElementFile_allocTable(out->Elements,NE0);
81 Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
82 if (! Finley_noError()) {
83 Finley_Mesh_dealloc(out);
84 return NULL;
85 }
86
87 /* set nodes: */
88
89 #pragma omp parallel for private(i0,k)
90 for (i0=0;i0<N0;i0++) {
91 k=i0;
92 out->Nodes->Coordinates[INDEX2(0,k,1)]=DBLE(i0)/DBLE(N0-1)*Length[0];
93 out->Nodes->Id[k]=k;
94 out->Nodes->Tag[k]=0;
95 out->Nodes->degreeOfFreedom[k]=(i0%NDOF0);
96 }
97 if (!periodic[0]) {
98 out->Nodes->Tag[0]=1;
99 out->Nodes->Tag[N0-1]=2;
100 }
101
102 /* set the elements: */
103
104 #pragma omp parallel for private(i0,k,node0)
105 for (i0=0;i0<NE0;i0++) {
106 k=i0;
107 node0=2*i0;
108
109 out->Elements->Id[k]=k;
110 out->Elements->Tag[k]=0;
111 out->Elements->Color[k]=COLOR_MOD(i0);
112
113 out->Elements->Nodes[INDEX2(0,k,3)]=node0;
114 out->Elements->Nodes[INDEX2(1,k,3)]=node0+2;
115 out->Elements->Nodes[INDEX2(2,k,3)]=node0+1;
116 }
117 out->Elements->minColor=0;
118 out->Elements->maxColor=COLOR_MOD(0);
119
120 /* face elements: */
121 if (useElementsOnFace) {
122 NUMNODES=3;
123 } else {
124 NUMNODES=1;
125 }
126
127 if (!periodic[0]) {
128 out->FaceElements->Id[0]=NE0;
129 out->FaceElements->Tag[0]=1;
130 out->FaceElements->Color[0]=0;
131 if (useElementsOnFace) {
132 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
133 out->FaceElements->Nodes[INDEX2(1,0,NUMNODES)]=2;
134 out->FaceElements->Nodes[INDEX2(2,0,NUMNODES)]=1;
135 } else {
136 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
137 }
138
139 out->FaceElements->Id[1]=NE0+1;
140 out->FaceElements->Tag[1]=2;
141 out->FaceElements->Color[1]=1;
142 if (useElementsOnFace) {
143 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
144 out->FaceElements->Nodes[INDEX2(1,1,NUMNODES)]=N0-3;
145 out->FaceElements->Nodes[INDEX2(2,1,NUMNODES)]=N0-2;
146 } else {
147 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
148 }
149 }
150 out->FaceElements->minColor=0;
151 out->FaceElements->maxColor=1;
152
153 /* face elements done: */
154
155 /* condense the nodes: */
156
157 Finley_Mesh_resolveNodeIds(out);
158
159 /* prepare mesh for further calculations:*/
160
161 Finley_Mesh_prepare(out) ;
162
163 #ifdef Finley_TRACE
164 printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
165 #endif
166
167 if (! Finley_noError()) {
168 Finley_Mesh_dealloc(out);
169 return NULL;
170 }
171 return out;
172 }
173
174 /*
175 * Revision 1.3 2005/09/01 03:31:36 jgs
176 * Merge of development branch dev-02 back to main trunk on 2005-09-01
177 *
178 * Revision 1.2.2.2 2005/09/07 06:26:19 gross
179 * the solver from finley are put into the standalone package paso now
180 *
181 * Revision 1.2.2.1 2005/08/24 02:02:18 gross
182 * timing output switched off. solver output can be swiched through getSolution(verbose=True) now.
183 *
184 * Revision 1.2 2005/07/08 04:07:53 jgs
185 * Merge of development branch back to main trunk on 2005-07-08
186 *
187 * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
188 * some changes towards 64 integers in finley
189 *
190 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
191 * initial import of project esys2
192 *
193 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
194 * Initial version of eys using boost-python.
195 *
196 *
197 */
198

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26