/[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 1062 by gross, Mon Mar 26 06:17:53 2007 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
1  /*  
2   ************************************************************  /* $Id$ */
3   *          Copyright 2006 by ACcESS MNRF                   *  
4   *                                                          *  /*******************************************************
5   *              http://www.access.edu.au                    *   *
6   *       Primary Business: Queensland, Australia            *   *           Copyright 2003-2007 by ACceSS MNRF
7   *  Licensed under the Open Software License version 3.0    *   *       Copyright 2007 by University of Queensland
8   *     http://www.opensource.org/licenses/osl-3.0.php       *   *
9   *                                                          *   *                http://esscc.uq.edu.au
10   ************************************************************   *        Primary Business: Queensland, Australia
11  */   *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
# Line 19  Line 22 
22    
23  /**************************************************************/  /**************************************************************/
24    
 /*  Author: gross@access.edu.au */  
 /*  Version: $Id$ */  
   
 /**************************************************************/  
   
25  #include "Mesh.h"  #include "Mesh.h"
26  #include "Util.h"  #include "Util.h"
27    
# Line 32  Line 30 
30  static double  Finley_Mesh_lockingGridSize=0;  static double  Finley_Mesh_lockingGridSize=0;
31    
32  Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {  Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
33      Paso_MPIInfo *mpi_info=NULL;
34    Finley_Mesh* out=NULL;    Finley_Mesh* out=NULL;
35    dim_t numNodes=0;    dim_t numNodes=0;
36    dim_t numElements=0;    dim_t numElements=0;
# Line 51  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 50  Finley_Mesh* Finley_Mesh_merge(dim_t num
50    index_t maxElementID2=0;    index_t maxElementID2=0;
51    char newName[LenString_MAX];    char newName[LenString_MAX];
52    if (numMsh==0) {    if (numMsh==0) {
53       Finley_setError(VALUE_ERROR,"__FILE__: Empty mesh list");       Finley_setError(VALUE_ERROR,"Finley_Mesh_merge: Empty mesh list");
54    } else {    } else {
55      order=msh[0]->order;      order=msh[0]->order;
56      reduced_order=msh[0]->reduced_order;      reduced_order=msh[0]->reduced_order;
57      numDim=msh[0]->Nodes->numDim;      numDim=msh[0]->Nodes->numDim;
58        mpi_info=msh[0]->MPIInfo;
59        if (mpi_info->size > 1) {
60             Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: more than processor is not supported yet.");
61             return NULL;
62        }
63      strcpy(newName,"");      strcpy(newName,"");
64      for (i=0;i<numMsh;i++) {      for (i=0;i<numMsh;i++) {
65         /* check if all mesh have the same type and dimensions */         /* check if all mesh have the same type and dimensions */
66         order=MAX(order,msh[i]->order);         order=MAX(order,msh[i]->order);
67         reduced_order=MIN(reduced_order,msh[i]->reduced_order);         reduced_order=MIN(reduced_order,msh[i]->reduced_order);
68         numNodes+=msh[i]->Nodes->numNodes;         numNodes+=msh[i]->Nodes->numNodes;
69           if (mpi_info->comm!=msh[i]->MPIInfo->comm) {
70              Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: MPI communicators of meshes don't match.");
71           }
72         if (numDim!=msh[i]->Nodes->numDim) {         if (numDim!=msh[i]->Nodes->numDim) {
73            Finley_setError(TYPE_ERROR,"__FILE__: Spatial dimensions of meshes don't match.");            Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: Spatial dimensions of meshes don't match.");
74         }         }
75    
76         if (msh[i]->Elements!=NULL) {         if (msh[i]->Elements!=NULL) {
# Line 72  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 79  Finley_Mesh* Finley_Mesh_merge(dim_t num
79               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;               elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;
80        } else {        } else {
81               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {               if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {
82                 Finley_setError(TYPE_ERROR,"__FILE__: element types of meshes don't match.");                 Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: element types of meshes don't match.");
83               }               }
84            }            }
85         }         }
# Line 83  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 90  Finley_Mesh* Finley_Mesh_merge(dim_t num
90               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;               faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;
91        } else {        } else {
92               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {               if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {
93                 Finley_setError(TYPE_ERROR,"__FILE__: face element types of meshes don't match.");                 Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: face element types of meshes don't match.");
94               }               }
95            }            }
96         }         }
# Line 94  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 101  Finley_Mesh* Finley_Mesh_merge(dim_t num
101               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;               contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;
102        } else {        } else {
103               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {               if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {
104                 Finley_setError(TYPE_ERROR,"__FILE__: contact element types of meshes don't match.");                 Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: contact element types of meshes don't match.");
105               }               }
106            }            }
107         }         }
# Line 105  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 112  Finley_Mesh* Finley_Mesh_merge(dim_t num
112               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;               pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;
113        } else {        } else {
114               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {               if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {
115                 Finley_setError(TYPE_ERROR,"__FILE__: point element types of meshes don't match.");                 Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: point element types of meshes don't match.");
116               }               }
117            }            }
118         }         }
# Line 114  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 121  Finley_Mesh* Finley_Mesh_merge(dim_t num
121         strncat(newName,msh[i]->Name,LenString_MAX-strlen(newName)-1);         strncat(newName,msh[i]->Name,LenString_MAX-strlen(newName)-1);
122      }      }
123    
124        if (mpi_info->size >1 ) {
125            Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: only single processor runs are supported.");
126        }
127      /* allocate */      /* allocate */
128    
 #ifndef PASO_MPI  
129      if (Finley_noError())      if (Finley_noError())
130        out=Finley_Mesh_alloc(newName,numDim,order,reduced_order);        out=Finley_Mesh_alloc(newName,numDim,order,reduced_order,mpi_info);
131    
132      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order, out->reduced_order);      out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order, out->reduced_order,mpi_info);
133      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order, out->reduced_order);      out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order, out->reduced_order,mpi_info);
134      out->Points=Finley_ElementFile_alloc(pointTypeId,out->order, out->reduced_order);      out->Points=Finley_ElementFile_alloc(pointTypeId,out->order, out->reduced_order,mpi_info);
135      out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order, out->reduced_order);      out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order, out->reduced_order,mpi_info);
136    
137      /* allocate new tables */      /* allocate new tables */
138    
# Line 135  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 144  Finley_Mesh* Finley_Mesh_merge(dim_t num
144          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);          Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
145          Finley_ElementFile_allocTable(out->Points,numPoints);          Finley_ElementFile_allocTable(out->Points,numPoints);
146      }      }
 #else  
 /* TODO */  
 #endif  
147    
148      /* copy tables :*/      /* copy tables :*/
149    
# Line 164  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 170  Finley_Mesh* Finley_Mesh_merge(dim_t num
170    
171             if (msh[i]->Nodes->numNodes>0)             if (msh[i]->Nodes->numNodes>0)
172                maxNodeID+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->Id)+1;                maxNodeID+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->Id)+1;
173                maxDOF+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->degreeOfFreedom)+1;                maxDOF+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->globalDegreesOfFreedom)+1;
174             maxElementID2=0;             maxElementID2=0;
175             if (msh[i]->Elements->numElements>0)             if (msh[i]->Elements->numElements>0)
176                maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Elements->numElements,msh[i]->Elements->Id));                maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Elements->numElements,msh[i]->Elements->Id));
# Line 180  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 186  Finley_Mesh* Finley_Mesh_merge(dim_t num
186      /* all done  */      /* all done  */
187    
188      if (! Finley_noError()) {      if (! Finley_noError()) {
189         Finley_Mesh_dealloc(out);         Finley_Mesh_free(out);
190      } else {      } else {
191         Finley_Mesh_prepare(out);         Finley_Mesh_prepare(out, FALSE);
192         #ifdef Finley_TRACE         #ifdef Finley_TRACE
193         printf("%d meshes merged.\n",numMsh);         printf("%d meshes merged.\n",numMsh);
194         #endif         #endif
# Line 190  Finley_Mesh* Finley_Mesh_merge(dim_t num Line 196  Finley_Mesh* Finley_Mesh_merge(dim_t num
196    }    }
197    return out;    return out;
198  }  }
   
 /*  
 * $Log$  
 * Revision 1.3  2005/09/15 03:44:22  jgs  
 * Merge of development branch dev-02 back to main trunk on 2005-09-15  
 *  
 * Revision 1.2.2.1  2005/09/07 06:26:19  gross  
 * the solver from finley are put into the standalone package paso now  
 *  
 * Revision 1.2  2005/07/08 04:07:53  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:52  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.2  2004/07/30 04:37:06  gross  
 * escript and finley are linking now and RecMeshTest.py has been passed  
 *  
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
 *  
 *  
 */  
   

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

  ViewVC Help
Powered by ViewVC 1.1.26