/[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 201 - (hide annotations)
Wed Nov 23 04:10:21 2005 UTC (14 years ago) by jgs
File MIME type: text/plain
File size: 5688 byte(s)
copy finleyC and CPPAdapter to finley and finley/CPPAdapter to
facilitate scons builds

1 jgs 150 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2003,2004,2005 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14    
15 jgs 82 /**************************************************************/
16    
17     /* Finley: generates rectangular meshes */
18    
19     /* Generates numElements[0] mesh with first order elements (Line2) in
20     the interval [0,Length[0]]. order is the desired accuracy of the
21     integration scheme. */
22    
23    
24     /**************************************************************/
25    
26 jgs 150 /* Author: gross@access.edu.au */
27     /* Version: $Id$ */
28 jgs 82
29     /**************************************************************/
30    
31     #include "RectangularMesh.h"
32    
33     /**************************************************************/
34    
35 jgs 123 Finley_Mesh* Finley_RectangularMesh_Line2(dim_t* numElements,double* Length,bool_t* periodic, index_t order,bool_t useElementsOnFace) {
36     dim_t N0,NE0,i0,NDOF0,NFaceElements;
37     index_t NUMNODES,k;
38 jgs 82 Finley_Mesh* out;
39     char name[50];
40     double time0=Finley_timer();
41     NE0=MAX(1,numElements[0]);
42     N0=NE0+1;
43    
44     if (!periodic[0]) {
45     NDOF0=N0;
46     NFaceElements=2;
47     } else {
48     NDOF0=N0-1;
49     NFaceElements=0;
50     }
51    
52     /* allocate mesh: */
53    
54     sprintf(name,"Rectangular mesh with %d nodes",N0);
55     out=Finley_Mesh_alloc(name,1,order);
56 jgs 150 if (! Finley_noError()) return NULL;
57 jgs 82
58     out->Elements=Finley_ElementFile_alloc(Line2,out->order);
59     if (useElementsOnFace) {
60     out->FaceElements=Finley_ElementFile_alloc(Line2Face,out->order);
61     out->ContactElements=Finley_ElementFile_alloc(Line2Face_Contact,out->order);
62     } else {
63     out->FaceElements=Finley_ElementFile_alloc(Point1,out->order);
64     out->ContactElements=Finley_ElementFile_alloc(Point1_Contact,out->order);
65     }
66     out->Points=Finley_ElementFile_alloc(Point1,out->order);
67 jgs 150 if (! Finley_noError()) {
68 jgs 82 Finley_Mesh_dealloc(out);
69     return NULL;
70     }
71    
72     /* allocate tables: */
73    
74     Finley_NodeFile_allocTable(out->Nodes,N0);
75     Finley_ElementFile_allocTable(out->Elements,NE0);
76     Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
77 jgs 150 if (! Finley_noError()) {
78 jgs 82 Finley_Mesh_dealloc(out);
79     return NULL;
80     }
81    
82     /* set nodes: */
83    
84     #pragma omp parallel for private(i0,k)
85     for (i0=0;i0<N0;i0++) {
86     k=i0;
87     out->Nodes->Coordinates[INDEX2(0,k,1)]=DBLE(i0)/DBLE(N0-1)*Length[0];
88     out->Nodes->Id[k]=k;
89     out->Nodes->Tag[k]=0;
90     out->Nodes->degreeOfFreedom[k]=(i0%NDOF0);
91     }
92     if (!periodic[0]) {
93     out->Nodes->Tag[0]=1;
94     out->Nodes->Tag[N0-1]=2;
95     }
96    
97     /* set the elements: */
98    
99     #pragma omp parallel for private(i0,k)
100     for (i0=0;i0<NE0;i0++) {
101     k=i0;
102     out->Elements->Id[k]=k;
103     out->Elements->Tag[k]=0;
104     out->Elements->Color[k]=COLOR_MOD(i0);
105    
106     out->Elements->Nodes[INDEX2(0,k,2)]=i0;
107     out->Elements->Nodes[INDEX2(1,k,2)]=i0+1;
108     }
109 jgs 123 out->Elements->minColor=0;
110     out->Elements->maxColor=COLOR_MOD(0);
111 jgs 82
112     /* face elements: */
113     if (useElementsOnFace) {
114     NUMNODES=2;
115     } else {
116     NUMNODES=1;
117     }
118     if (!periodic[0]) {
119     out->FaceElements->Id[0]=NE0;
120     out->FaceElements->Tag[0]=1;
121     out->FaceElements->Color[0]=0;
122     if (useElementsOnFace) {
123     out->FaceElements->Nodes[INDEX2(0,0,NUMNODES)]=0;
124     out->FaceElements->Nodes[INDEX2(1,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-2;
135     } else {
136     out->FaceElements->Nodes[INDEX2(0,1,NUMNODES)]=N0-1;
137     }
138     }
139 jgs 123 out->FaceElements->maxColor=1;
140     out->FaceElements->minColor=0;
141 jgs 82
142     /* face elements done: */
143    
144    
145     /* condense the nodes: */
146    
147     Finley_Mesh_resolveNodeIds(out);
148    
149     /* prepare mesh for further calculatuions:*/
150    
151     Finley_Mesh_prepare(out) ;
152    
153 jgs 149 #ifdef Finley_TRACE
154 jgs 82 printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
155 jgs 149 #endif
156 jgs 82
157 jgs 150 if (! Finley_noError()) {
158 jgs 82 Finley_Mesh_dealloc(out);
159     return NULL;
160     }
161     return out;
162     }
163    
164     /*
165 jgs 149 * 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 jgs 150 * 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 jgs 149 * 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 jgs 123 * Revision 1.2 2005/07/08 04:07:52 jgs
175     * Merge of development branch back to main trunk on 2005-07-08
176 jgs 82 *
177 jgs 123 * Revision 1.1.1.1.2.2 2005/06/30 01:53:56 gross
178     * a bug in coloring fixed
179     *
180     * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
181     * some changes towards 64 integers in finley
182     *
183     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
184     * initial import of project esys2
185     *
186 jgs 82 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
187     * Initial version of eys using boost-python.
188     *
189     *
190     */
191    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26