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

Diff of /trunk/finley/src/Mesh_rec8.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/esys2/finley/src/finleyC/Mesh_rec8.c revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/finley/src/Mesh_rec8.c revision 616 by elspeth, Wed Mar 22 02:46:56 2006 UTC
# Line 1  Line 1 
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 */  /*   Finley: generates rectangular meshes */
# Line 7  Line 19 
19    
20  /**************************************************************/  /**************************************************************/
21    
 /*   Copyrights by ACcESS Australia 2003 */  
22  /*   Author: gross@access.edu.au */  /*   Author: gross@access.edu.au */
23  /*   Version: $Id$ */  /*   Version: $Id$ */
24    
25  /**************************************************************/  /**************************************************************/
26    
 #include "Common.h"  
 #include "Finley.h"  
 #include "Mesh.h"  
27  #include "RectangularMesh.h"  #include "RectangularMesh.h"
28    
29  /**************************************************************/  /**************************************************************/
30    
31  Finley_Mesh* Finley_RectangularMesh_Rec8(int* numElements,double* Length,int* periodic,int order,int useElementsOnFace) {  Finley_Mesh* Finley_RectangularMesh_Rec8(int* numElements,double* Length,int* periodic,int order,int useElementsOnFace) {
32    dim_t N0,N1,NE0,NE1,i0,i1,totalNECount,faceNECount,NDOF0,NDOF1,NFaceElements,NUMNODES;    dim_t N0,N1,NE0,NE1,i0,i1,totalNECount,faceNECount,NDOF0,NDOF1,NFaceElements,NUMNODES,M0,M1;
33    index_t k,node0;    index_t k,node0;
34    Finley_Mesh* out;    Finley_Mesh* out;
35    char name[50];    char name[50];
# Line 31  Finley_Mesh* Finley_RectangularMesh_Rec8 Line 39  Finley_Mesh* Finley_RectangularMesh_Rec8
39    N0=2*NE0+1;    N0=2*NE0+1;
40    N1=2*NE1+1;    N1=2*NE1+1;
41    
42      if (N0<=N1) {
43         M0=1;
44         M1=N0;
45      } else {
46         M0=N1;
47         M1=1;
48      }
49    
50    NFaceElements=0;    NFaceElements=0;
51    if (!periodic[0]) {    if (!periodic[0]) {
52        NDOF0=N0;        NDOF0=N0;
# Line 49  Finley_Mesh* Finley_RectangularMesh_Rec8 Line 65  Finley_Mesh* Finley_RectangularMesh_Rec8
65        
66    sprintf(name,"Rectangular %d x %d mesh",N0,N1);    sprintf(name,"Rectangular %d x %d mesh",N0,N1);
67    out=Finley_Mesh_alloc(name,2,order);    out=Finley_Mesh_alloc(name,2,order);
68    if (Finley_ErrorCode!=NO_ERROR) return NULL;    if (! Finley_noError()) return NULL;
69    
70    out->Elements=Finley_ElementFile_alloc(Rec8,out->order);    out->Elements=Finley_ElementFile_alloc(Rec8,out->order);
71    if (useElementsOnFace) {    if (useElementsOnFace) {
# Line 60  Finley_Mesh* Finley_RectangularMesh_Rec8 Line 76  Finley_Mesh* Finley_RectangularMesh_Rec8
76       out->ContactElements=Finley_ElementFile_alloc(Line3_Contact,out->order);       out->ContactElements=Finley_ElementFile_alloc(Line3_Contact,out->order);
77    }    }
78    out->Points=Finley_ElementFile_alloc(Point1,out->order);    out->Points=Finley_ElementFile_alloc(Point1,out->order);
79    if (Finley_ErrorCode!=NO_ERROR) {    if (! Finley_noError()) {
80         Finley_Mesh_dealloc(out);         Finley_Mesh_dealloc(out);
81         return NULL;         return NULL;
82    }    }
# Line 70  Finley_Mesh* Finley_RectangularMesh_Rec8 Line 86  Finley_Mesh* Finley_RectangularMesh_Rec8
86    Finley_NodeFile_allocTable(out->Nodes,N0*N1);    Finley_NodeFile_allocTable(out->Nodes,N0*N1);
87    Finley_ElementFile_allocTable(out->Elements,NE0*NE1);    Finley_ElementFile_allocTable(out->Elements,NE0*NE1);
88    Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);    Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
89    if (Finley_ErrorCode!=NO_ERROR) {    if (! Finley_noError()) {
90        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
91        return NULL;        return NULL;
92    }    }
     
93    /*  set nodes: */    /*  set nodes: */
94                                                                                                                                                                                                          
95    #pragma omp parallel for private(i0,i1,k)    #pragma omp parallel for private(i0,i1,k)
96    for (i1=0;i1<N1;i1++) {    for (i1=0;i1<N1;i1++) {
97      for (i0=0;i0<N0;i0++) {      for (i0=0;i0<N0;i0++) {
98        k=i0+N0*i1;        k=M0*i0+M1*i1;
99        out->Nodes->Coordinates[INDEX2(0,k,2)]=DBLE(i0)/DBLE(N0-1)*Length[0];        out->Nodes->Coordinates[INDEX2(0,k,2)]=DBLE(i0)/DBLE(N0-1)*Length[0];
100        out->Nodes->Coordinates[INDEX2(1,k,2)]=DBLE(i1)/DBLE(N1-1)*Length[1];        out->Nodes->Coordinates[INDEX2(1,k,2)]=DBLE(i1)/DBLE(N1-1)*Length[1];
101        out->Nodes->Id[k]=k;        out->Nodes->Id[k]=i0+N0*i1;
102        out->Nodes->Tag[k]=0;        out->Nodes->Tag[k]=0;
103        out->Nodes->degreeOfFreedom[k]=(i0%NDOF0) +N0*(i1%NDOF1);        out->Nodes->degreeOfFreedom[k]=M0*(i0%NDOF0) +M1*(i1%NDOF1);
104      }      }
105    }    }
106    /* tags for the faces: */    /* tags for the faces: */
107    if (!periodic[1]) {    if (!periodic[1]) {
108      for (i0=0;i0<N0;i0++) {      for (i0=0;i0<N0;i0++) {
109        out->Nodes->Tag[i0+N0*0]+=10;        out->Nodes->Tag[M0*i0+M1*0]+=10;
110        out->Nodes->Tag[i0+N0*(N1-1)]+=20;        out->Nodes->Tag[M0*i0+M1*(N1-1)]+=20;
111      }      }
112    }    }
113    if (!periodic[0]) {    if (!periodic[0]) {
114      for (i1=0;i1<N1;i1++) {      for (i1=0;i1<N1;i1++) {
115        out->Nodes->Tag[0+N0*i1]+=1;        out->Nodes->Tag[M0*0+M1*i1]+=1;
116        out->Nodes->Tag[(N0-1)+N0*i1]+=2;        out->Nodes->Tag[M0*(N0-1)+M1*i1]+=2;
117      }      }
118    }    }
119      
120    /*   set the elements: */    /*   set the elements: */
121        
122    #pragma omp parallel for private(i0,i1,k,node0)    #pragma omp parallel for private(i0,i1,k,node0)
# Line 271  Finley_Mesh* Finley_RectangularMesh_Rec8 Line 286  Finley_Mesh* Finley_RectangularMesh_Rec8
286    
287    Finley_Mesh_prepare(out) ;    Finley_Mesh_prepare(out) ;
288    
289      #ifdef Finley_TRACE
290    printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);    printf("timing: mesh generation: %.4e sec\n",Finley_timer()-time0);
291      #endif
292    
293    if (Finley_ErrorCode!=NO_ERROR) {    if (! Finley_noError()) {
294        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
295        return NULL;        return NULL;
296    }    }
297    return out;    return out;
298  }  }
   
 /*  
 * $Log$  
 * Revision 1.2  2005/07/08 04:07:54  jgs  
 * Merge of development branch back to main trunk on 2005-07-08  
 *  
 * Revision 1.1.1.1.2.1  2005/06/29 02:34:53  gross  
 * some changes towards 64 integers in finley  
 *  
 * Revision 1.1.1.1  2004/10/26 06:53:57  jgs  
 * initial import of project esys2  
 *  
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
 *  
 *  
 */  
   

Legend:
Removed from v.123  
changed lines
  Added in v.616

  ViewVC Help
Powered by ViewVC 1.1.26