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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (hide annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 7 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_line3.c
File MIME type: text/plain
File size: 4674 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 jgs 82 /**************************************************************/
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 jgs 123 Finley_Mesh* Finley_RectangularMesh_Line3(dim_t* numElements,double* Length,bool_t* periodic,index_t order,bool_t useElementsOnFace) {
24     dim_t N0,NE0,i0,NDOF0,NFaceElements,NUMNODES;
25     index_t k,node0;
26 jgs 82 Finley_Mesh* out;
27     char name[50];
28     double time0=Finley_timer();
29     NE0=MAX(1,numElements[0]);
30     N0=2*NE0+1;
31     if (!periodic[0]) {
32     NDOF0=N0;
33     NFaceElements=2;
34     } else {
35     NDOF0=N0-1;
36     NFaceElements=0;
37     }
38    
39     /* allocate mesh: */
40    
41     sprintf(name,"Rectangular mesh with %d nodes",N0);
42     out=Finley_Mesh_alloc(name,1,order);
43     if (Finley_ErrorCode!=NO_ERROR) return NULL;
44    
45     out->Elements=Finley_ElementFile_alloc(Line3,out->order);
46     if (useElementsOnFace) {
47     out->FaceElements=Finley_ElementFile_alloc(Line3Face,out->order);
48     out->ContactElements=Finley_ElementFile_alloc(Line3Face_Contact,out->order);
49     } else {
50     out->FaceElements=Finley_ElementFile_alloc(Point1,out->order);
51     out->ContactElements=Finley_ElementFile_alloc(Point1_Contact,out->order);
52     }
53     out->Points=Finley_ElementFile_alloc(Point1,out->order);
54     if (Finley_ErrorCode!=NO_ERROR) {
55     Finley_Mesh_dealloc(out);
56     return NULL;
57     }
58    
59     /* allocate tables: */
60    
61     Finley_NodeFile_allocTable(out->Nodes,N0);
62     Finley_ElementFile_allocTable(out->Elements,NE0);
63     Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
64     if (Finley_ErrorCode!=NO_ERROR) {
65     Finley_Mesh_dealloc(out);
66     return NULL;
67     }
68    
69     /* set nodes: */
70    
71     #pragma omp parallel for private(i0,k)
72     for (i0=0;i0<N0;i0++) {
73     k=i0;
74     out->Nodes->Coordinates[INDEX2(0,k,1)]=DBLE(i0)/DBLE(N0-1)*Length[0];
75     out->Nodes->Id[k]=k;
76     out->Nodes->Tag[k]=0;
77     out->Nodes->degreeOfFreedom[k]=(i0%NDOF0);
78     }
79     if (!periodic[0]) {
80     out->Nodes->Tag[0]=1;
81     out->Nodes->Tag[N0-1]=2;
82     }
83    
84     /* set the elements: */
85    
86     #pragma omp parallel for private(i0,k,node0)
87     for (i0=0;i0<NE0;i0++) {
88     k=i0;
89     node0=2*i0;
90    
91     out->Elements->Id[k]=k;
92     out->Elements->Tag[k]=0;
93     out->Elements->Color[k]=COLOR_MOD(i0);
94    
95     out->Elements->Nodes[INDEX2(0,k,3)]=node0;
96     out->Elements->Nodes[INDEX2(1,k,3)]=node0+2;
97     out->Elements->Nodes[INDEX2(2,k,3)]=node0+1;
98     }
99 jgs 123 out->Elements->minColor=0;
100     out->Elements->maxColor=COLOR_MOD(0);
101 jgs 82
102     /* face elements: */
103     if (useElementsOnFace) {
104     NUMNODES=3;
105     } else {
106     NUMNODES=1;
107     }
108    
109     if (!periodic[0]) {
110     out->FaceElements->Id[0]=NE0;
111     out->FaceElements->Tag[0]=1;
112     out->FaceElements->Color[0]=0;
113     if (useElementsOnFace) {
114     out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
115     out->FaceElements->Nodes[INDEX2(1,0,NUMNODES)]=2;
116     out->FaceElements->Nodes[INDEX2(2,0,NUMNODES)]=1;
117     } else {
118     out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
119     }
120    
121     out->FaceElements->Id[1]=NE0+1;
122     out->FaceElements->Tag[1]=2;
123     out->FaceElements->Color[1]=1;
124     if (useElementsOnFace) {
125     out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
126     out->FaceElements->Nodes[INDEX2(1,1,NUMNODES)]=N0-3;
127     out->FaceElements->Nodes[INDEX2(2,1,NUMNODES)]=N0-2;
128     } else {
129     out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
130     }
131     }
132 jgs 123 out->FaceElements->minColor=0;
133     out->FaceElements->maxColor=1;
134 jgs 82
135     /* face elements done: */
136    
137     /* condense the nodes: */
138    
139     Finley_Mesh_resolveNodeIds(out);
140    
141     /* prepare mesh for further calculations:*/
142    
143     Finley_Mesh_prepare(out) ;
144    
145     printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
146    
147     if (Finley_ErrorCode!=NO_ERROR) {
148     Finley_Mesh_dealloc(out);
149     return NULL;
150     }
151     return out;
152     }
153    
154     /*
155     * $Log$
156 jgs 123 * Revision 1.2 2005/07/08 04:07:53 jgs
157     * Merge of development branch back to main trunk on 2005-07-08
158 jgs 82 *
159 jgs 123 * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
160     * some changes towards 64 integers in finley
161     *
162     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
163     * initial import of project esys2
164     *
165 jgs 82 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
166     * Initial version of eys using boost-python.
167     *
168     *
169     */
170    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26