/[escript]/branches/domexper/dudley/src/Mesh_hex20.c
ViewVC logotype

Diff of /branches/domexper/dudley/src/Mesh_hex20.c

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

revision 3080 by jfenwick, Tue Aug 3 04:28:03 2010 UTC revision 3086 by jfenwick, Thu Aug 5 05:07:58 2010 UTC
# Line 14  Line 14 
14    
15  /**************************************************************/  /**************************************************************/
16    
17  /*   Finley: generates rectangular meshes  */  /*   Dudley: generates rectangular meshes  */
18    
19  /*   Generates a numElements[0] x numElements[1] x numElements[2] mesh with second order elements (Hex20) in the brick */  /*   Generates a numElements[0] x numElements[1] x numElements[2] mesh with second order elements (Hex20) in the brick */
20  /*   [0,Length[0]] x [0,Length[1]] x [0,Length[2]]. order is the desired accuracy of the */  /*   [0,Length[0]] x [0,Length[1]] x [0,Length[2]]. order is the desired accuracy of the */
# Line 25  Line 25 
25    
26  #include "RectangularMesh.h"  #include "RectangularMesh.h"
27    
28  Finley_Mesh* Finley_RectangularMesh_Hex20(dim_t* numElements,  Dudley_Mesh* Dudley_RectangularMesh_Hex20(dim_t* numElements,
29                                            double* Length,                                            double* Length,
30                                            bool_t* periodic,                                            bool_t* periodic,
31                                            index_t order,                                            index_t order,
# Line 40  Finley_Mesh* Finley_RectangularMesh_Hex2 Line 40  Finley_Mesh* Finley_RectangularMesh_Hex2
40    dim_t N0,N1,N2,NE0,NE1,NE2,i0,i1,i2,k,Nstride0=0, Nstride1=0, Nstride2=0, local_NE0, local_NE1, local_NE2;    dim_t N0,N1,N2,NE0,NE1,NE2,i0,i1,i2,k,Nstride0=0, Nstride1=0, Nstride2=0, local_NE0, local_NE1, local_NE2;
41    dim_t totalNECount,faceNECount,NDOF0=0, NDOF1=0, NDOF2=0, NFaceElements=0, local_N0=0, local_N1=0, local_N2=0, NN;    dim_t totalNECount,faceNECount,NDOF0=0, NDOF1=0, NDOF2=0, NFaceElements=0, local_N0=0, local_N1=0, local_N2=0, NN;
42    index_t node0, myRank, e_offset0, e_offset1, e_offset2, offset0=0, offset1=0, offset2=0, global_i0, global_i1, global_i2;    index_t node0, myRank, e_offset0, e_offset1, e_offset2, offset0=0, offset1=0, offset2=0, global_i0, global_i1, global_i2;
43    Finley_Mesh* out;    Dudley_Mesh* out;
44    Paso_MPIInfo *mpi_info = NULL;    Paso_MPIInfo *mpi_info = NULL;
45    Finley_ReferenceElementSet *refPoints=NULL, *refContactElements=NULL, *refFaceElements=NULL, *refElements=NULL;    Dudley_ReferenceElementSet *refPoints=NULL, *refContactElements=NULL, *refFaceElements=NULL, *refElements=NULL;
46    char name[50];    char name[50];
47    bool_t generateAllNodes= useFullElementOrder || useMacroElements;    bool_t generateAllNodes= useFullElementOrder || useMacroElements;
48    #ifdef Finley_TRACE    #ifdef Dudley_TRACE
49    double time0=Finley_timer();    double time0=Dudley_timer();
50    #endif    #endif
51    
52    /* get MPI information */    /* get MPI information */
53    mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );    mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
54    if (! Finley_noError()) {    if (! Dudley_noError()) {
55          return NULL;          return NULL;
56    }    }
57    myRank=mpi_info->rank;    myRank=mpi_info->rank;
# Line 67  Finley_Mesh* Finley_RectangularMesh_Hex2 Line 67  Finley_Mesh* Finley_RectangularMesh_Hex2
67    
68    /*  allocate mesh: */      /*  allocate mesh: */  
69    sprintf(name,"Brick %d x %d x %d mesh",N0,N1,N2);    sprintf(name,"Brick %d x %d x %d mesh",N0,N1,N2);
70    out=Finley_Mesh_alloc(name,DIM, mpi_info);    out=Dudley_Mesh_alloc(name,DIM, mpi_info);
71    if (! Finley_noError()) {    if (! Dudley_noError()) {
72        Paso_MPIInfo_free( mpi_info );        Paso_MPIInfo_free( mpi_info );
73        return NULL;        return NULL;
74    }    }
75    
76    if (generateAllNodes) {    if (generateAllNodes) {
77       /* Finley_setError(SYSTEM_ERROR,"full element order for Hex elements is not supported yet."); */       /* Dudley_setError(SYSTEM_ERROR,"full element order for Hex elements is not supported yet."); */
78       if (useMacroElements) {       if (useMacroElements) {
79            refElements= Finley_ReferenceElementSet_alloc(Hex27Macro,order,reduced_order);            refElements= Dudley_ReferenceElementSet_alloc(Hex27Macro,order,reduced_order);
80       } else {       } else {
81            refElements=Finley_ReferenceElementSet_alloc(Hex27, order,reduced_order);            refElements=Dudley_ReferenceElementSet_alloc(Hex27, order,reduced_order);
82       }       }
83       if (useElementsOnFace) {       if (useElementsOnFace) {
84           Finley_setError(SYSTEM_ERROR,"rich elements for Hex27 elements is not supported yet.");           Dudley_setError(SYSTEM_ERROR,"rich elements for Hex27 elements is not supported yet.");
85       } else {       } else {
86           if (useMacroElements) {           if (useMacroElements) {
87               refFaceElements=Finley_ReferenceElementSet_alloc(Rec9Macro, order, reduced_order);               refFaceElements=Dudley_ReferenceElementSet_alloc(Rec9Macro, order, reduced_order);
88           } else {           } else {
89               refFaceElements=Finley_ReferenceElementSet_alloc(Rec9, order, reduced_order);               refFaceElements=Dudley_ReferenceElementSet_alloc(Rec9, order, reduced_order);
90           }           }
91           refContactElements=Finley_ReferenceElementSet_alloc(Rec9_Contact, order, reduced_order);           refContactElements=Dudley_ReferenceElementSet_alloc(Rec9_Contact, order, reduced_order);
92       }       }
93    
94    } else  {    } else  {
95       refElements= Finley_ReferenceElementSet_alloc(Hex20,order,reduced_order);       refElements= Dudley_ReferenceElementSet_alloc(Hex20,order,reduced_order);
96       if (useElementsOnFace) {       if (useElementsOnFace) {
97           refFaceElements = Finley_ReferenceElementSet_alloc(Hex20Face ,order,reduced_order);           refFaceElements = Dudley_ReferenceElementSet_alloc(Hex20Face ,order,reduced_order);
98           refContactElements=Finley_ReferenceElementSet_alloc(Hex20Face_Contact, order, reduced_order);           refContactElements=Dudley_ReferenceElementSet_alloc(Hex20Face_Contact, order, reduced_order);
99    
100       } else {       } else {
101           refFaceElements = Finley_ReferenceElementSet_alloc(Rec8 ,order,reduced_order);           refFaceElements = Dudley_ReferenceElementSet_alloc(Rec8 ,order,reduced_order);
102           refContactElements=Finley_ReferenceElementSet_alloc(Rec8_Contact, order, reduced_order);           refContactElements=Dudley_ReferenceElementSet_alloc(Rec8_Contact, order, reduced_order);
103    
104       }       }
105    }    }
106    refPoints=Finley_ReferenceElementSet_alloc(Point1, order, reduced_order);    refPoints=Dudley_ReferenceElementSet_alloc(Point1, order, reduced_order);
107    
108    if ( Finley_noError()) {    if ( Dudley_noError()) {
109        
110        Finley_Mesh_setPoints(out,Finley_ElementFile_alloc(refPoints, mpi_info));        Dudley_Mesh_setPoints(out,Dudley_ElementFile_alloc(refPoints, mpi_info));
111        Finley_Mesh_setContactElements(out,Finley_ElementFile_alloc(refContactElements, mpi_info));        Dudley_Mesh_setContactElements(out,Dudley_ElementFile_alloc(refContactElements, mpi_info));
112        Finley_Mesh_setFaceElements(out,Finley_ElementFile_alloc(refFaceElements, mpi_info));        Dudley_Mesh_setFaceElements(out,Dudley_ElementFile_alloc(refFaceElements, mpi_info));
113        Finley_Mesh_setElements(out,Finley_ElementFile_alloc(refElements, mpi_info));        Dudley_Mesh_setElements(out,Dudley_ElementFile_alloc(refElements, mpi_info));
114    
115        /* work out the largest dimension */        /* work out the largest dimension */
116        if (N2==MAX3(N0,N1,N2)) {        if (N2==MAX3(N0,N1,N2)) {
# Line 175  Finley_Mesh* Finley_RectangularMesh_Hex2 Line 175  Finley_Mesh* Finley_RectangularMesh_Hex2
175        }        }
176    }    }
177    /*  allocate tables: */    /*  allocate tables: */
178    if (Finley_noError()) {    if (Dudley_noError()) {
179        Finley_NodeFile_allocTable(out->Nodes,local_N0*local_N1*local_N2);        Dudley_NodeFile_allocTable(out->Nodes,local_N0*local_N1*local_N2);
180        Finley_ElementFile_allocTable(out->Elements,local_NE0*local_NE1*local_NE2);        Dudley_ElementFile_allocTable(out->Elements,local_NE0*local_NE1*local_NE2);
181        Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);        Dudley_ElementFile_allocTable(out->FaceElements,NFaceElements);
182    }    }
183    if (Finley_noError()) {    if (Dudley_noError()) {
184    
185        /* create nodes */        /* create nodes */
186        
# Line 592  Finley_Mesh* Finley_RectangularMesh_Hex2 Line 592  Finley_Mesh* Finley_RectangularMesh_Hex2
592          }          }
593          totalNECount+=NE0*NE2;          totalNECount+=NE0*NE2;
594       }       }
595       if (Finley_noError()) {       if (Dudley_noError()) {
596           /* add tag names */           /* add tag names */
597           Finley_Mesh_addTagMap(out,"top", 200);           Dudley_Mesh_addTagMap(out,"top", 200);
598           Finley_Mesh_addTagMap(out,"bottom", 100);           Dudley_Mesh_addTagMap(out,"bottom", 100);
599           Finley_Mesh_addTagMap(out,"left", 1);           Dudley_Mesh_addTagMap(out,"left", 1);
600           Finley_Mesh_addTagMap(out,"right", 2);           Dudley_Mesh_addTagMap(out,"right", 2);
601           Finley_Mesh_addTagMap(out,"front", 10);           Dudley_Mesh_addTagMap(out,"front", 10);
602           Finley_Mesh_addTagMap(out,"back", 20);           Dudley_Mesh_addTagMap(out,"back", 20);
603       }       }
604    }    }
605    /* prepare mesh for further calculatuions:*/    /* prepare mesh for further calculatuions:*/
606    if (Finley_noError()) {    if (Dudley_noError()) {
607           Finley_Mesh_resolveNodeIds(out);           Dudley_Mesh_resolveNodeIds(out);
608    }    }
609    if (Finley_noError()) {    if (Dudley_noError()) {
610           Finley_Mesh_prepare(out, optimize);           Dudley_Mesh_prepare(out, optimize);
611    }    }
612    
613    if (!Finley_noError()) {    if (!Dudley_noError()) {
614        Finley_Mesh_free(out);        Dudley_Mesh_free(out);
615    }    }
616      /* free up memory */      /* free up memory */
617    Finley_ReferenceElementSet_dealloc(refPoints);    Dudley_ReferenceElementSet_dealloc(refPoints);
618    Finley_ReferenceElementSet_dealloc(refContactElements);    Dudley_ReferenceElementSet_dealloc(refContactElements);
619    Finley_ReferenceElementSet_dealloc(refFaceElements);    Dudley_ReferenceElementSet_dealloc(refFaceElements);
620    Finley_ReferenceElementSet_dealloc(refElements);    Dudley_ReferenceElementSet_dealloc(refElements);
621    Paso_MPIInfo_free( mpi_info );      Paso_MPIInfo_free( mpi_info );  
622    
623    return out;    return out;

Legend:
Removed from v.3080  
changed lines
  Added in v.3086

  ViewVC Help
Powered by ViewVC 1.1.26