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

Annotation of /trunk/esys2/finley/src/finleyC/Mesh_line2.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 5 months ago) by jgs
File MIME type: text/plain
File size: 4153 byte(s)
Initial revision

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26