/[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 616 - (show annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 7 months ago) by elspeth
File MIME type: text/plain
File size: 5502 byte(s)
Copyright added to more source files.

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 out=Finley_Mesh_alloc(name,1,order);
51 if (! Finley_noError()) return NULL;
52
53 out->Elements=Finley_ElementFile_alloc(Line3,out->order);
54 if (useElementsOnFace) {
55 out->FaceElements=Finley_ElementFile_alloc(Line3Face,out->order);
56 out->ContactElements=Finley_ElementFile_alloc(Line3Face_Contact,out->order);
57 } else {
58 out->FaceElements=Finley_ElementFile_alloc(Point1,out->order);
59 out->ContactElements=Finley_ElementFile_alloc(Point1_Contact,out->order);
60 }
61 out->Points=Finley_ElementFile_alloc(Point1,out->order);
62 if (! Finley_noError()) {
63 Finley_Mesh_dealloc(out);
64 return NULL;
65 }
66
67 /* allocate tables: */
68
69 Finley_NodeFile_allocTable(out->Nodes,N0);
70 Finley_ElementFile_allocTable(out->Elements,NE0);
71 Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
72 if (! Finley_noError()) {
73 Finley_Mesh_dealloc(out);
74 return NULL;
75 }
76
77 /* set nodes: */
78
79 #pragma omp parallel for private(i0,k)
80 for (i0=0;i0<N0;i0++) {
81 k=i0;
82 out->Nodes->Coordinates[INDEX2(0,k,1)]=DBLE(i0)/DBLE(N0-1)*Length[0];
83 out->Nodes->Id[k]=k;
84 out->Nodes->Tag[k]=0;
85 out->Nodes->degreeOfFreedom[k]=(i0%NDOF0);
86 }
87 if (!periodic[0]) {
88 out->Nodes->Tag[0]=1;
89 out->Nodes->Tag[N0-1]=2;
90 }
91
92 /* set the elements: */
93
94 #pragma omp parallel for private(i0,k,node0)
95 for (i0=0;i0<NE0;i0++) {
96 k=i0;
97 node0=2*i0;
98
99 out->Elements->Id[k]=k;
100 out->Elements->Tag[k]=0;
101 out->Elements->Color[k]=COLOR_MOD(i0);
102
103 out->Elements->Nodes[INDEX2(0,k,3)]=node0;
104 out->Elements->Nodes[INDEX2(1,k,3)]=node0+2;
105 out->Elements->Nodes[INDEX2(2,k,3)]=node0+1;
106 }
107 out->Elements->minColor=0;
108 out->Elements->maxColor=COLOR_MOD(0);
109
110 /* face elements: */
111 if (useElementsOnFace) {
112 NUMNODES=3;
113 } else {
114 NUMNODES=1;
115 }
116
117 if (!periodic[0]) {
118 out->FaceElements->Id[0]=NE0;
119 out->FaceElements->Tag[0]=1;
120 out->FaceElements->Color[0]=0;
121 if (useElementsOnFace) {
122 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
123 out->FaceElements->Nodes[INDEX2(1,0,NUMNODES)]=2;
124 out->FaceElements->Nodes[INDEX2(2,0,NUMNODES)]=1;
125 } else {
126 out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
127 }
128
129 out->FaceElements->Id[1]=NE0+1;
130 out->FaceElements->Tag[1]=2;
131 out->FaceElements->Color[1]=1;
132 if (useElementsOnFace) {
133 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
134 out->FaceElements->Nodes[INDEX2(1,1,NUMNODES)]=N0-3;
135 out->FaceElements->Nodes[INDEX2(2,1,NUMNODES)]=N0-2;
136 } else {
137 out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
138 }
139 }
140 out->FaceElements->minColor=0;
141 out->FaceElements->maxColor=1;
142
143 /* face elements done: */
144
145 /* condense the nodes: */
146
147 Finley_Mesh_resolveNodeIds(out);
148
149 /* prepare mesh for further calculations:*/
150
151 Finley_Mesh_prepare(out) ;
152
153 #ifdef Finley_TRACE
154 printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
155 #endif
156
157 if (! Finley_noError()) {
158 Finley_Mesh_dealloc(out);
159 return NULL;
160 }
161 return out;
162 }
163
164 /*
165 * Revision 1.3 2005/09/01 03:31:36 jgs
166 * Merge of development branch dev-02 back to main trunk on 2005-09-01
167 *
168 * Revision 1.2.2.2 2005/09/07 06:26:19 gross
169 * the solver from finley are put into the standalone package paso now
170 *
171 * Revision 1.2.2.1 2005/08/24 02:02:18 gross
172 * timing output switched off. solver output can be swiched through getSolution(verbose=True) now.
173 *
174 * Revision 1.2 2005/07/08 04:07:53 jgs
175 * Merge of development branch back to main trunk on 2005-07-08
176 *
177 * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
178 * some changes towards 64 integers in finley
179 *
180 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
181 * initial import of project esys2
182 *
183 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
184 * Initial version of eys using boost-python.
185 *
186 *
187 */
188

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26