/[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

revision 82 by jgs, Tue Oct 26 06:53:54 2004 UTC revision 150 by jgs, Thu Sep 15 03:44:45 2005 UTC
# Line 1  Line 1 
1    /*
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  /**************************************************************/  /**************************************************************/
16    
17  /*   Finley: Mesh */  /*   Finley: Mesh */
# Line 7  Line 21 
21    
22  /**************************************************************/  /**************************************************************/
23    
24  /*   Copyrights by ACcESS Australia 2003/04 */  /*  Author: gross@access.edu.au */
25  /*   Author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
26    
27  /**************************************************************/  /**************************************************************/
28    
 #include "Finley.h"  
29  #include "Mesh.h"  #include "Mesh.h"
30  #include "Util.h"  #include "Util.h"
31    
# Line 21  Line 33 
33    
34  static double  Finley_Mesh_lockingGridSize=0;  static double  Finley_Mesh_lockingGridSize=0;
35    
36  Finley_Mesh* Finley_Mesh_merge(int numMsh, Finley_Mesh** msh) {  Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
37    Finley_Mesh* out=NULL;    Finley_Mesh* out=NULL;
38    int i;    dim_t i;
39    char newName[LenString_MAX];    char newName[LenString_MAX];
40    if (numMsh==0) {    if (numMsh==0) {
41       Finley_ErrorCode=VALUE_ERROR;       Finley_setError(VALUE_ERROR,"__FILE__: Empty mesh list");
      sprintf(Finley_ErrorMsg,"Empty mesh list");  
42    } else {    } else {
43      int order=msh[0]->order;      index_t order=msh[0]->order;
44      int numDim=msh[0]->Nodes->numDim;      dim_t numDim=msh[0]->Nodes->numDim;
45      ElementTypeId elementTypeId=NoType;      ElementTypeId elementTypeId=NoType;
46      ElementTypeId faceElementTypeId=NoType;      ElementTypeId faceElementTypeId=NoType;
47      ElementTypeId pointTypeId=NoType;      ElementTypeId pointTypeId=NoType;
48      ElementTypeId contactTypeId=NoType;      ElementTypeId contactTypeId=NoType;
49      strcpy(newName,"");      strcpy(newName,"");
50      int numNodes=0;      dim_t numNodes=0;
51      int numElements=0;      dim_t numElements=0;
52      int numFaceElements=0;      dim_t numFaceElements=0;
53      int numContactElements=0;      dim_t numContactElements=0;
54      int numPoints=0;      dim_t numPoints=0;
55      for (i=0;i<numMsh;i++) {      for (i=0;i<numMsh;i++) {
56         /* check if all mesh have the same type and dimensions */         /* check if all mesh have the same type and dimensions */
57         order=MAX(order,msh[i]->order);         order=MAX(order,msh[i]->order);
58         numNodes+=msh[i]->Nodes->numNodes;         numNodes+=msh[i]->Nodes->numNodes;
59         if (numDim!=msh[i]->Nodes->numDim) {         if (numDim!=msh[i]->Nodes->numDim) {
60            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.");  
61         }         }
62    
63         if (msh[i]->Elements!=NULL) {         if (msh[i]->Elements!=NULL) {
# Line 56  Finley_Mesh* Finley_Mesh_merge(int numMs Line 66  Finley_Mesh* Finley_Mesh_merge(int numMs
66               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;
67        } else {        } else {
68               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {
69                 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.");  
70               }               }
71            }            }
72         }         }
# Line 68  Finley_Mesh* Finley_Mesh_merge(int numMs Line 77  Finley_Mesh* Finley_Mesh_merge(int numMs
77               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;
78        } else {        } else {
79               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {
80                 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.");  
81               }               }
82            }            }
83         }         }
# Line 80  Finley_Mesh* Finley_Mesh_merge(int numMs Line 88  Finley_Mesh* Finley_Mesh_merge(int numMs
88               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;
89        } else {        } else {
90               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {
91                 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.");  
92               }               }
93            }            }
94         }         }
# Line 92  Finley_Mesh* Finley_Mesh_merge(int numMs Line 99  Finley_Mesh* Finley_Mesh_merge(int numMs
99               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;
100        } else {        } else {
101               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {
102                 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.");  
103               }               }
104            }            }
105         }         }
# Line 104  Finley_Mesh* Finley_Mesh_merge(int numMs Line 110  Finley_Mesh* Finley_Mesh_merge(int numMs
110    
111      /* allocate */      /* allocate */
112    
113      if (Finley_ErrorCode == NO_ERROR) out=Finley_Mesh_alloc(newName,numDim,order);      if (Finley_noError()) out=Finley_Mesh_alloc(newName,numDim,order);
114    
115      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);
116      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 119  Finley_Mesh* Finley_Mesh_merge(int numMs
119    
120      /* allocate new tables */      /* allocate new tables */
121    
122      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError()) {
123          Finley_NodeFile_allocTable(out->Nodes,numNodes);          Finley_NodeFile_allocTable(out->Nodes,numNodes);
124          Finley_ElementFile_allocTable(out->Elements,numElements);          Finley_ElementFile_allocTable(out->Elements,numElements);
125          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);          Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
# Line 123  Finley_Mesh* Finley_Mesh_merge(int numMs Line 129  Finley_Mesh* Finley_Mesh_merge(int numMs
129    
130      /* copy tables :*/      /* copy tables :*/
131    
132      if (Finley_ErrorCode == NO_ERROR) {      if (Finley_noError()) {
133    
134          int numNodes=0;          dim_t numNodes=0;
135          int numElements=0;          dim_t numElements=0;
136          int numFaceElements=0;          dim_t numFaceElements=0;
137          int numContactElements=0;          dim_t numContactElements=0;
138          int numPoints=0;          dim_t numPoints=0;
139          int maxNodeID=0;          index_t maxNodeID=0;
140          int maxDOF=0;          index_t maxDOF=0;
141          int maxElementID=0;          index_t maxElementID=0;
142          int maxElementID2=0;          index_t maxElementID2=0;
143    
144          for (i=0;i<numMsh;i++) {          for (i=0;i<numMsh;i++) {
145    
# Line 166  Finley_Mesh* Finley_Mesh_merge(int numMs Line 172  Finley_Mesh* Finley_Mesh_merge(int numMs
172      }      }
173      /* all done  */      /* all done  */
174    
175      if (Finley_ErrorCode != NO_ERROR) {      if (! Finley_noError()) {
176         Finley_Mesh_dealloc(out);         Finley_Mesh_dealloc(out);
177      } else {      } else {
178         Finley_Mesh_prepare(out);         Finley_Mesh_prepare(out);
# Line 180  Finley_Mesh* Finley_Mesh_merge(int numMs Line 186  Finley_Mesh* Finley_Mesh_merge(int numMs
186    
187  /*  /*
188  * $Log$  * $Log$
189  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.3  2005/09/15 03:44:22  jgs
190  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
191    *
192    * Revision 1.2.2.1  2005/09/07 06:26:19  gross
193    * the solver from finley are put into the standalone package paso now
194    *
195    * Revision 1.2  2005/07/08 04:07:53  jgs
196    * Merge of development branch back to main trunk on 2005-07-08
197    *
198    * Revision 1.1.1.1.2.1  2005/06/29 02:34:52  gross
199    * some changes towards 64 integers in finley
200    *
201    * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
202    * initial import of project esys2
203  *  *
204  * Revision 1.2  2004/07/30 04:37:06  gross  * Revision 1.2  2004/07/30 04:37:06  gross
205  * 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.150

  ViewVC Help
Powered by ViewVC 1.1.26