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

Diff of /trunk/finley/src/Mesh_joinFaces.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 6  Line 20 
20    
21  /**************************************************************/  /**************************************************************/
22    
23  /*   Copyrights by ACcESS Australia 2003 */  /*  Author: gross@access.edu.au */
24  /*   Author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
25    
26  /**************************************************************/  /**************************************************************/
27    
 #include "Common.h"  
 #include "Finley.h"  
28  #include "Mesh.h"  #include "Mesh.h"
29    
30  /**************************************************************/  /**************************************************************/
31    
32  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance) {  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance) {
33    
34     int numPairs,*elem1=NULL,*elem0=NULL,*elem_mask=NULL,*matching_nodes_in_elem1=NULL;     char error_msg[LenErrorMsg_MAX];
35       index_t e0,e1,*elem1=NULL,*elem0=NULL,*elem_mask=NULL,*matching_nodes_in_elem1=NULL;
36     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;
37     int e,i,e0,e1;     dim_t e,i,numPairs;
38     if (self->FaceElements==NULL) return;     if (self->FaceElements==NULL) return;
39    
40     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {
41       Finley_ErrorCode=TYPE_ERROR;       sprintf(error_msg,"__FILE__:joining faces cannot be applied to face elements of type %s",self->FaceElements->ReferenceElement->Type->Name);
42       sprintf(Finley_ErrorMsg,"joining faces cannot be applied to face elements of type %s",self->FaceElements->ReferenceElement->Type->Name);       Finley_setError(TYPE_ERROR,error_msg);
43       return;       return;
44     }     }
45     if (self->ContactElements==NULL) {     if (self->ContactElements==NULL) {
46       Finley_ErrorCode=TYPE_ERROR;       Finley_setError(TYPE_ERROR,"__FILE__: no contact element file present.");
      sprintf(Finley_ErrorMsg,"no contact element file present.");  
47       return;       return;
48     }     }
49    
# Line 40  void Finley_Mesh_joinFaces(Finley_Mesh* Line 51  void Finley_Mesh_joinFaces(Finley_Mesh*
51     int NN_Contact=self->ContactElements->ReferenceElement->Type->numNodes;     int NN_Contact=self->ContactElements->ReferenceElement->Type->numNodes;
52    
53     if (2*NN!=NN_Contact) {     if (2*NN!=NN_Contact) {
54       Finley_ErrorCode=TYPE_ERROR;       sprintf(error_msg,"__FILE__:contact element file for %s cannot hold elements created from face elements %s",
      sprintf(Finley_ErrorMsg,"contact element file for %s cannot hold elements created from face elements %s",  
55             self->ContactElements->ReferenceElement->Type->Name,self->FaceElements->ReferenceElement->Type->Name);             self->ContactElements->ReferenceElement->Type->Name,self->FaceElements->ReferenceElement->Type->Name);
56         Finley_setError(TYPE_ERROR,error_msg);
57       return;       return;
58     }     }
59    
60     /* allocate work arrays */     /* allocate work arrays */
61     elem1=(int*) TMPMEMALLOC(sizeof(int)*self->FaceElements->numElements);     elem1=TMPMEMALLOC(self->FaceElements->numElements,index_t);
62     elem0=(int*) TMPMEMALLOC(sizeof(int)*self->FaceElements->numElements);     elem0=TMPMEMALLOC(self->FaceElements->numElements,index_t);
63     elem_mask=(int*) TMPMEMALLOC(sizeof(int)*self->FaceElements->numElements);     elem_mask=TMPMEMALLOC(self->FaceElements->numElements,index_t);
64     matching_nodes_in_elem1=(int*) TMPMEMALLOC(sizeof(int)*self->FaceElements->numElements*NN);     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);
65    
66     if (!(Finley_checkPtr(elem1) || Finley_checkPtr(elem0) || Finley_checkPtr(elem_mask) || Finley_checkPtr(matching_nodes_in_elem1)))  {     if (!(Finley_checkPtr(elem1) || Finley_checkPtr(elem0) || Finley_checkPtr(elem_mask) || Finley_checkPtr(matching_nodes_in_elem1)))  {
67        /* find the matching face elements */        /* find the matching face elements */
68        Finley_Mesh_findMatchingFaces(self->Nodes,self->FaceElements,safety_factor,tolerance,&numPairs,elem0,elem1,matching_nodes_in_elem1);        Finley_Mesh_findMatchingFaces(self->Nodes,self->FaceElements,safety_factor,tolerance,&numPairs,elem0,elem1,matching_nodes_in_elem1);
69        if (Finley_ErrorCode==NO_ERROR) {        if (Finley_noError()) {
70           /* get a list of the face elements to be kept */           /* get a list of the face elements to be kept */
71           #pragma omp parallel for private(e) schedule(static)           #pragma omp parallel for private(e) schedule(static)
72           for(e=0;e<self->FaceElements->numElements;e++) elem_mask[e]=1;           for(e=0;e<self->FaceElements->numElements;e++) elem_mask[e]=1;
# Line 63  void Finley_Mesh_joinFaces(Finley_Mesh* Line 74  void Finley_Mesh_joinFaces(Finley_Mesh*
74               elem_mask[elem0[e]]=0;               elem_mask[elem0[e]]=0;
75               elem_mask[elem1[e]]=0;               elem_mask[elem1[e]]=0;
76           }           }
77           int new_numFaceElements=0;           dim_t new_numFaceElements=0;
78           /* OMP */           /* OMP */
79           for(e=0;e<self->FaceElements->numElements;e++) {           for(e=0;e<self->FaceElements->numElements;e++) {
80               if (elem_mask[e]>0) {               if (elem_mask[e]>0) {
# Line 74  void Finley_Mesh_joinFaces(Finley_Mesh* Line 85  void Finley_Mesh_joinFaces(Finley_Mesh*
85           /*  allocate new face element and Contact element files */           /*  allocate new face element and Contact element files */
86           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);
87           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);
88           if (Finley_ErrorCode==NO_ERROR) {           if (Finley_noError()) {
89                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);
90                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
91           }           }
92           /* copy the old elements over */           /* copy the old elements over */
93           if (Finley_ErrorCode==NO_ERROR) {           if (Finley_noError()) {
94              /* get the face elements which are still in use:*/              /* get the face elements which are still in use:*/
95              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
96              /* get the Contact elements which are still in use:*/              /* get the Contact elements which are still in use:*/
97              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);
98              int c=self->ContactElements->numElements;              dim_t c=self->ContactElements->numElements;
99              /* OMP */              /* OMP */
100              for (e=0;e<numPairs;e++) {              for (e=0;e<numPairs;e++) {
101                   e0=elem0[e];                   e0=elem0[e];
# Line 96  void Finley_Mesh_joinFaces(Finley_Mesh* Line 107  void Finley_Mesh_joinFaces(Finley_Mesh*
107                   for (i=0;i<NN;i++) newContactElementsFile->Nodes[INDEX2(i+NN,c,NN_Contact)]=matching_nodes_in_elem1[INDEX2(i,e,NN)];                   for (i=0;i<NN;i++) newContactElementsFile->Nodes[INDEX2(i+NN,c,NN_Contact)]=matching_nodes_in_elem1[INDEX2(i,e,NN)];
108                   c++;                   c++;
109              }              }
110              newContactElementsFile->numColors=numPairs;              newContactElementsFile->minColor=0;
111                newContactElementsFile->maxColor=numPairs-1;
112           }           }
113           /* set new face and Contact elements */           /* set new face and Contact elements */
114           if (Finley_ErrorCode==NO_ERROR) {           if (Finley_noError()) {
115    
116              Finley_ElementFile_dealloc(self->FaceElements);              Finley_ElementFile_dealloc(self->FaceElements);
117              self->FaceElements=newFaceElementsFile;              self->FaceElements=newFaceElementsFile;
# Line 125  void Finley_Mesh_joinFaces(Finley_Mesh* Line 137  void Finley_Mesh_joinFaces(Finley_Mesh*
137    
138  /*  /*
139  * $Log$  * $Log$
140  * Revision 1.1  2004/10/26 06:53:57  jgs  * Revision 1.6  2005/09/15 03:44:22  jgs
141  * Initial revision  * Merge of development branch dev-02 back to main trunk on 2005-09-15
142    *
143    * Revision 1.5.2.1  2005/09/07 06:26:19  gross
144    * the solver from finley are put into the standalone package paso now
145    *
146    * Revision 1.5  2005/07/08 04:07:52  jgs
147    * Merge of development branch back to main trunk on 2005-07-08
148    *
149    * Revision 1.4  2004/12/15 07:08:33  jgs
150    * *** empty log message ***
151    * Revision 1.1.1.1.2.2  2005/06/29 02:34:52  gross
152    * some changes towards 64 integers in finley
153    *
154    * Revision 1.1.1.1.2.1  2004/11/24 01:37:14  gross
155    * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
156  *  *
 * Revision 1.1.1.1  2004/06/24 04:00:40  johng  
 * Initial version of eys using boost-python.  
157  *  *
158  *  *
159  */  */

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

  ViewVC Help
Powered by ViewVC 1.1.26