/[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 1028 by gross, Wed Mar 14 00:15:24 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;
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;      numDim=msh[0]->Nodes->numDim;
     ElementTypeId elementTypeId=NoType;  
     ElementTypeId faceElementTypeId=NoType;  
     ElementTypeId pointTypeId=NoType;  
     ElementTypeId contactTypeId=NoType;  
58      strcpy(newName,"");      strcpy(newName,"");
     int numNodes=0;  
     int numElements=0;  
     int numFaceElements=0;  
     int numContactElements=0;  
     int numPoints=0;  
59      for (i=0;i<numMsh;i++) {      for (i=0;i<numMsh;i++) {
60         /* check if all mesh have the same type and dimensions */         /* check if all mesh have the same type and dimensions */
61         order=MAX(order,msh[i]->order);         order=MAX(order,msh[i]->order);
62         numNodes+=msh[i]->Nodes->numNodes;         numNodes+=msh[i]->Nodes->numNodes;
63         if (numDim!=msh[i]->Nodes->numDim) {         if (numDim!=msh[i]->Nodes->numDim) {
64            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.");  
65         }         }
66    
67         if (msh[i]->Elements!=NULL) {         if (msh[i]->Elements!=NULL) {
# Line 56  Finley_Mesh* Finley_Mesh_merge(int numMs Line 70  Finley_Mesh* Finley_Mesh_merge(int numMs
70               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;
71        } else {        } else {
72               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {
73                 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.");  
74               }               }
75            }            }
76         }         }
# Line 68  Finley_Mesh* Finley_Mesh_merge(int numMs Line 81  Finley_Mesh* Finley_Mesh_merge(int numMs
81               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;
82        } else {        } else {
83               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {
84                 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.");  
85               }               }
86            }            }
87         }         }
# Line 80  Finley_Mesh* Finley_Mesh_merge(int numMs Line 92  Finley_Mesh* Finley_Mesh_merge(int numMs
92               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;
93        } else {        } else {
94               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {
95                 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.");  
96               }               }
97            }            }
98         }         }
# Line 92  Finley_Mesh* Finley_Mesh_merge(int numMs Line 103  Finley_Mesh* Finley_Mesh_merge(int numMs
103               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;
104        } else {        } else {
105               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {
106                 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.");  
107               }               }
108            }            }
109         }         }
# Line 104  Finley_Mesh* Finley_Mesh_merge(int numMs Line 114  Finley_Mesh* Finley_Mesh_merge(int numMs
114    
115      /* allocate */      /* allocate */
116    
117      if (Finley_ErrorCode == NO_ERROR) out=Finley_Mesh_alloc(newName,numDim,order);  #ifndef PASO_MPI
118        if (Finley_noError())
119          out=Finley_Mesh_alloc(newName,numDim,order);
120    
121      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);
122      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order);      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order);
# Line 113  Finley_Mesh* Finley_Mesh_merge(int numMs Line 125  Finley_Mesh* Finley_Mesh_merge(int numMs
125    
126      /* allocate new tables */      /* allocate new tables */
127    
128      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError())
129        {
130          Finley_NodeFile_allocTable(out->Nodes,numNodes);          Finley_NodeFile_allocTable(out->Nodes,numNodes);
131          Finley_ElementFile_allocTable(out->Elements,numElements);          Finley_ElementFile_allocTable(out->Elements,numElements);
132          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
133          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
134          Finley_ElementFile_allocTable(out->Points,numPoints);          Finley_ElementFile_allocTable(out->Points,numPoints);
135      }      }
136    #else
137    /* TODO */
138    #endif
139    
140      /* copy tables :*/      /* copy tables :*/
141    
142      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError()) {
143           numNodes=0;
144          int numNodes=0;         numElements=0;
145          int numElements=0;         numFaceElements=0;
146          int numFaceElements=0;         numContactElements=0;
147          int numContactElements=0;         numPoints=0;
         int numPoints=0;  
         int maxNodeID=0;  
         int maxDOF=0;  
         int maxElementID=0;  
         int maxElementID2=0;  
148    
149          for (i=0;i<numMsh;i++) {          for (i=0;i<numMsh;i++) {
150    
# Line 166  Finley_Mesh* Finley_Mesh_merge(int numMs Line 177  Finley_Mesh* Finley_Mesh_merge(int numMs
177      }      }
178      /* all done  */      /* all done  */
179    
180      if (Finley_ErrorCode != NO_ERROR) {      if (! Finley_noError()) {
181         Finley_Mesh_dealloc(out);         Finley_Mesh_dealloc(out);
182      } else {      } else {
183         Finley_Mesh_prepare(out);         Finley_Mesh_prepare(out);
# Line 180  Finley_Mesh* Finley_Mesh_merge(int numMs Line 191  Finley_Mesh* Finley_Mesh_merge(int numMs
191    
192  /*  /*
193  * $Log$  * $Log$
194  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.3  2005/09/15 03:44:22  jgs
195  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
196    *
197    * Revision 1.2.2.1  2005/09/07 06:26:19  gross
198    * the solver from finley are put into the standalone package paso now
199    *
200    * Revision 1.2  2005/07/08 04:07:53  jgs
201    * Merge of development branch back to main trunk on 2005-07-08
202    *
203    * Revision 1.1.1.1.2.1  2005/06/29 02:34:52  gross
204    * some changes towards 64 integers in finley
205    *
206    * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
207    * initial import of project esys2
208  *  *
209  * Revision 1.2  2004/07/30 04:37:06  gross  * Revision 1.2  2004/07/30 04:37:06  gross
210  * 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.1028

  ViewVC Help
Powered by ViewVC 1.1.26