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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 149 - (hide annotations)
Thu Sep 1 03:31:39 2005 UTC (14 years, 10 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_line2.c
File MIME type: text/plain
File size: 4829 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-01

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26