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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26