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

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

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

trunk/esys2/finley/src/finleyC/Mesh_merge.c revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC trunk/finley/src/Mesh_merge.c revision 1062 by gross, Mon Mar 26 06:17:53 2007 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: Mesh */  /*   Finley: Mesh */
# Line 7  Line 19 
19    
20  /**************************************************************/  /**************************************************************/
21    
22  /*   Copyrights by ACcESS Australia 2003/04 */  /*  Author: gross@access.edu.au */
23  /*   Author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
24    
25  /**************************************************************/  /**************************************************************/
26    
 #include "Finley.h"  
27  #include "Mesh.h"  #include "Mesh.h"
28  #include "Util.h"  #include "Util.h"
29    
# Line 21  Line 31 
31    
32  static double  Finley_Mesh_lockingGridSize=0;  static double  Finley_Mesh_lockingGridSize=0;
33    
34  Finley_Mesh* Finley_Mesh_merge(int numMsh, Finley_Mesh** msh) {  Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
35    Finley_Mesh* out=NULL;    Finley_Mesh* out=NULL;
36    int i;    dim_t numNodes=0;
37      dim_t numElements=0;
38      dim_t numFaceElements=0;
39      dim_t numContactElements=0;
40      dim_t numPoints=0;
41      dim_t i;
42      index_t order, reduced_order;
43      dim_t numDim;
44      ElementTypeId elementTypeId=NoType;
45      ElementTypeId faceElementTypeId=NoType;
46      ElementTypeId pointTypeId=NoType;
47      ElementTypeId contactTypeId=NoType;
48      index_t maxNodeID=0;
49      index_t maxDOF=0;
50      index_t maxElementID=0;
51      index_t maxElementID2=0;
52    char newName[LenString_MAX];    char newName[LenString_MAX];
53    if (numMsh==0) {    if (numMsh==0) {
54       Finley_ErrorCode=VALUE_ERROR;       Finley_setError(VALUE_ERROR,"__FILE__: Empty mesh list");
      sprintf(Finley_ErrorMsg,"Empty mesh list");  
55    } else {    } else {
56      int order=msh[0]->order;      order=msh[0]->order;
57      int numDim=msh[0]->Nodes->numDim;      reduced_order=msh[0]->reduced_order;
58      ElementTypeId elementTypeId=NoType;      numDim=msh[0]->Nodes->numDim;
     ElementTypeId faceElementTypeId=NoType;  
     ElementTypeId pointTypeId=NoType;  
     ElementTypeId contactTypeId=NoType;  
59      strcpy(newName,"");      strcpy(newName,"");
     int numNodes=0;  
     int numElements=0;  
     int numFaceElements=0;  
     int numContactElements=0;  
     int numPoints=0;  
60      for (i=0;i<numMsh;i++) {      for (i=0;i<numMsh;i++) {
61         /* check if all mesh have the same type and dimensions */         /* check if all mesh have the same type and dimensions */
62         order=MAX(order,msh[i]->order);         order=MAX(order,msh[i]->order);
63           reduced_order=MIN(reduced_order,msh[i]->reduced_order);
64         numNodes+=msh[i]->Nodes->numNodes;         numNodes+=msh[i]->Nodes->numNodes;
65         if (numDim!=msh[i]->Nodes->numDim) {         if (numDim!=msh[i]->Nodes->numDim) {
66            Finley_ErrorCode=TYPE_ERROR;            Finley_setError(TYPE_ERROR,"__FILE__: Spatial dimensions of meshes don't match.");
           sprintf(Finley_ErrorMsg,"Spatial dimensions of meshes don't match.");  
67         }         }
68    
69         if (msh[i]->Elements!=NULL) {         if (msh[i]->Elements!=NULL) {
# Line 56  Finley_Mesh* Finley_Mesh_merge(int numMs Line 72  Finley_Mesh* Finley_Mesh_merge(int numMs
72               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;
73        } else {        } else {
74               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {
75                 Finley_ErrorCode=TYPE_ERROR;                 Finley_setError(TYPE_ERROR,"__FILE__: element types of meshes don't match.");
                sprintf(Finley_ErrorMsg,"element types of meshes don't match.");  
76               }               }
77            }            }
78         }         }
# Line 68  Finley_Mesh* Finley_Mesh_merge(int numMs Line 83  Finley_Mesh* Finley_Mesh_merge(int numMs
83               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;
84        } else {        } else {
85               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {
86                 Finley_ErrorCode=TYPE_ERROR;                 Finley_setError(TYPE_ERROR,"__FILE__: face element types of meshes don't match.");
                sprintf(Finley_ErrorMsg,"face element types of meshes don't match.");  
87               }               }
88            }            }
89         }         }
# Line 80  Finley_Mesh* Finley_Mesh_merge(int numMs Line 94  Finley_Mesh* Finley_Mesh_merge(int numMs
94               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;
95        } else {        } else {
96               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {
97                 Finley_ErrorCode=TYPE_ERROR;                 Finley_setError(TYPE_ERROR,"__FILE__: contact element types of meshes don't match.");
                sprintf(Finley_ErrorMsg,"contact element types of meshes don't match.");  
98               }               }
99            }            }
100         }         }
# Line 92  Finley_Mesh* Finley_Mesh_merge(int numMs Line 105  Finley_Mesh* Finley_Mesh_merge(int numMs
105               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;
106        } else {        } else {
107               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {
108                 Finley_ErrorCode=TYPE_ERROR;                 Finley_setError(TYPE_ERROR,"__FILE__: point element types of meshes don't match.");
                sprintf(Finley_ErrorMsg,"point element types of meshes don't match.");  
109               }               }
110            }            }
111         }         }
# Line 104  Finley_Mesh* Finley_Mesh_merge(int numMs Line 116  Finley_Mesh* Finley_Mesh_merge(int numMs
116    
117      /* allocate */      /* allocate */
118    
119      if (Finley_ErrorCode == NO_ERROR) out=Finley_Mesh_alloc(newName,numDim,order);  #ifndef PASO_MPI
120        if (Finley_noError())
121      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);        out=Finley_Mesh_alloc(newName,numDim,order,reduced_order);
122      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order);  
123      out->Points=Finley_ElementFile_alloc(pointTypeId,out->order);      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order, out->reduced_order);
124      out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order);      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order, out->reduced_order);
125        out->Points=Finley_ElementFile_alloc(pointTypeId,out->order, out->reduced_order);
126        out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order, out->reduced_order);
127    
128      /* allocate new tables */      /* allocate new tables */
129    
130      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError())
131        {
132          Finley_NodeFile_allocTable(out->Nodes,numNodes);          Finley_NodeFile_allocTable(out->Nodes,numNodes);
133          Finley_ElementFile_allocTable(out->Elements,numElements);          Finley_ElementFile_allocTable(out->Elements,numElements);
134          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
135          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
136          Finley_ElementFile_allocTable(out->Points,numPoints);          Finley_ElementFile_allocTable(out->Points,numPoints);
137      }      }
138    #else
139    /* TODO */
140    #endif
141    
142      /* copy tables :*/      /* copy tables :*/
143    
144      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError()) {
145           numNodes=0;
146          int numNodes=0;         numElements=0;
147          int numElements=0;         numFaceElements=0;
148          int numFaceElements=0;         numContactElements=0;
149          int numContactElements=0;         numPoints=0;
         int numPoints=0;  
         int maxNodeID=0;  
         int maxDOF=0;  
         int maxElementID=0;  
         int maxElementID2=0;  
150    
151          for (i=0;i<numMsh;i++) {          for (i=0;i<numMsh;i++) {
152    
# Line 166  Finley_Mesh* Finley_Mesh_merge(int numMs Line 179  Finley_Mesh* Finley_Mesh_merge(int numMs
179      }      }
180      /* all done  */      /* all done  */
181    
182      if (Finley_ErrorCode != NO_ERROR) {      if (! Finley_noError()) {
183         Finley_Mesh_dealloc(out);         Finley_Mesh_dealloc(out);
184      } else {      } else {
185         Finley_Mesh_prepare(out);         Finley_Mesh_prepare(out);
# Line 180  Finley_Mesh* Finley_Mesh_merge(int numMs Line 193  Finley_Mesh* Finley_Mesh_merge(int numMs
193    
194  /*  /*
195  * $Log$  * $Log$
196  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.3  2005/09/15 03:44:22  jgs
197  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
198    *
199    * Revision 1.2.2.1  2005/09/07 06:26:19  gross
200    * the solver from finley are put into the standalone package paso now
201    *
202    * Revision 1.2  2005/07/08 04:07:53  jgs
203    * Merge of development branch back to main trunk on 2005-07-08
204    *
205    * Revision 1.1.1.1.2.1  2005/06/29 02:34:52  gross
206    * some changes towards 64 integers in finley
207    *
208    * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
209    * initial import of project esys2
210  *  *
211  * Revision 1.2  2004/07/30 04:37:06  gross  * Revision 1.2  2004/07/30 04:37:06  gross
212  * escript and finley are linking now and RecMeshTest.py has been passed  * escript and finley are linking now and RecMeshTest.py has been passed

Legend:
Removed from v.82  
changed lines
  Added in v.1062

  ViewVC Help
Powered by ViewVC 1.1.26