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

trunk/esys2/finley/src/finleyC/Mesh_joinFaces.c revision 123 by jgs, Fri Jul 8 04:08:13 2005 UTC trunk/finley/src/Mesh_joinFaces.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 6  Line 18 
18    
19  /**************************************************************/  /**************************************************************/
20    
21  /*   Copyrights by ACcESS Australia 2003 */  /*  Author: gross@access.edu.au */
22  /*   Author: gross@access.edu.au */  /*  Version: $Id$ */
 /*   Version: $Id$ */  
23    
24  /**************************************************************/  /**************************************************************/
25    
 #include "Common.h"  
 #include "Finley.h"  
26  #include "Mesh.h"  #include "Mesh.h"
27    
28  /**************************************************************/  /**************************************************************/
29    
30  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance) {  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance) {
31    
32       char error_msg[LenErrorMsg_MAX];
33     index_t e0,e1,*elem1=NULL,*elem0=NULL,*elem_mask=NULL,*matching_nodes_in_elem1=NULL;     index_t e0,e1,*elem1=NULL,*elem0=NULL,*elem_mask=NULL,*matching_nodes_in_elem1=NULL;
34     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;
35     dim_t e,i,numPairs;     dim_t e,i,numPairs, NN, NN_Contact,c, new_numFaceElements;
36     if (self->FaceElements==NULL) return;     if (self->FaceElements==NULL) return;
37    
38     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {
39       Finley_ErrorCode=TYPE_ERROR;       sprintf(error_msg,"Finley_Mesh_joinFaces:joining faces cannot be applied to face elements of type %s",self->FaceElements->ReferenceElement->Type->Name);
40       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);
41       return;       return;
42     }     }
43     if (self->ContactElements==NULL) {     if (self->ContactElements==NULL) {
44       Finley_ErrorCode=TYPE_ERROR;       Finley_setError(TYPE_ERROR,"Finley_Mesh_joinFaces: no contact element file present.");
      sprintf(Finley_ErrorMsg,"no contact element file present.");  
45       return;       return;
46     }     }
47    
48     int NN=self->FaceElements->ReferenceElement->Type->numNodes;     NN=self->FaceElements->ReferenceElement->Type->numNodes;
49     int NN_Contact=self->ContactElements->ReferenceElement->Type->numNodes;     NN_Contact=self->ContactElements->ReferenceElement->Type->numNodes;
50    
51     if (2*NN!=NN_Contact) {     if (2*NN!=NN_Contact) {
52       Finley_ErrorCode=TYPE_ERROR;       sprintf(error_msg,"Finley_Mesh_joinFaces: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",  
53             self->ContactElements->ReferenceElement->Type->Name,self->FaceElements->ReferenceElement->Type->Name);             self->ContactElements->ReferenceElement->Type->Name,self->FaceElements->ReferenceElement->Type->Name);
54         Finley_setError(TYPE_ERROR,error_msg);
55       return;       return;
56     }     }
57    
# Line 55  void Finley_Mesh_joinFaces(Finley_Mesh* Line 64  void Finley_Mesh_joinFaces(Finley_Mesh*
64     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)))  {
65        /* find the matching face elements */        /* find the matching face elements */
66        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);
67        if (Finley_ErrorCode==NO_ERROR) {        if (Finley_noError()) {
68           /* get a list of the face elements to be kept */           /* get a list of the face elements to be kept */
69           #pragma omp parallel for private(e) schedule(static)           #pragma omp parallel for private(e) schedule(static)
70           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 72  void Finley_Mesh_joinFaces(Finley_Mesh*
72               elem_mask[elem0[e]]=0;               elem_mask[elem0[e]]=0;
73               elem_mask[elem1[e]]=0;               elem_mask[elem1[e]]=0;
74           }           }
75           dim_t new_numFaceElements=0;           new_numFaceElements=0;
76           /* OMP */           /* OMP */
77           for(e=0;e<self->FaceElements->numElements;e++) {           for(e=0;e<self->FaceElements->numElements;e++) {
78               if (elem_mask[e]>0) {               if (elem_mask[e]>0) {
# Line 72  void Finley_Mesh_joinFaces(Finley_Mesh* Line 81  void Finley_Mesh_joinFaces(Finley_Mesh*
81               }               }
82           }           }
83           /*  allocate new face element and Contact element files */           /*  allocate new face element and Contact element files */
84    #ifndef PASO_MPI
85           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);
86           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);
87           if (Finley_ErrorCode==NO_ERROR) {  #else
88      /* TODO */
89      PASO_MPI_TODO;
90    #endif
91             if (Finley_noError()) {
92                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);
93                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
94           }           }
95           /* copy the old elements over */           /* copy the old elements over */
96           if (Finley_ErrorCode==NO_ERROR) {           if (Finley_noError()) {
97              /* get the face elements which are still in use:*/              /* get the face elements which are still in use:*/
98              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
99              /* get the Contact elements which are still in use:*/              /* get the Contact elements which are still in use:*/
100              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);
101              dim_t c=self->ContactElements->numElements;              c=self->ContactElements->numElements;
102              /* OMP */              /* OMP */
103              for (e=0;e<numPairs;e++) {              for (e=0;e<numPairs;e++) {
104                   e0=elem0[e];                   e0=elem0[e];
# Line 98  void Finley_Mesh_joinFaces(Finley_Mesh* Line 112  void Finley_Mesh_joinFaces(Finley_Mesh*
112              }              }
113              newContactElementsFile->minColor=0;              newContactElementsFile->minColor=0;
114              newContactElementsFile->maxColor=numPairs-1;              newContactElementsFile->maxColor=numPairs-1;
115                newContactElementsFile->isPrepared=self->FaceElements->isPrepared;
116           }           }
117           /* set new face and Contact elements */           /* set new face and Contact elements */
118           if (Finley_ErrorCode==NO_ERROR) {           if (Finley_noError()) {
119    
120              Finley_ElementFile_dealloc(self->FaceElements);              Finley_ElementFile_dealloc(self->FaceElements);
121              self->FaceElements=newFaceElementsFile;              self->FaceElements=newFaceElementsFile;
# Line 110  void Finley_Mesh_joinFaces(Finley_Mesh* Line 125  void Finley_Mesh_joinFaces(Finley_Mesh*
125              self->ContactElements=newContactElementsFile;              self->ContactElements=newContactElementsFile;
126              Finley_ElementFile_prepare(&(self->ContactElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);              Finley_ElementFile_prepare(&(self->ContactElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);
127    
128              Finley_Mesh_prepareNodes(self);              Finley_Mesh_prepare(self);
129    
130           } else {           } else {
131              Finley_ElementFile_dealloc(newFaceElementsFile);              Finley_ElementFile_dealloc(newFaceElementsFile);
# Line 122  void Finley_Mesh_joinFaces(Finley_Mesh* Line 137  void Finley_Mesh_joinFaces(Finley_Mesh*
137     TMPMEMFREE(elem0);     TMPMEMFREE(elem0);
138     TMPMEMFREE(matching_nodes_in_elem1);     TMPMEMFREE(matching_nodes_in_elem1);
139     TMPMEMFREE(elem_mask);     TMPMEMFREE(elem_mask);
140       if (Finley_noError()) {
141           if ( ! Finley_Mesh_isPrepared(self) ) {
142              Finley_setError(SYSTEM_ERROR,"Mesh is not prepared for calculation. Contact the programmers.");
143           }
144      }
145  }  }
   
 /*  
 * $Log$  
 * Revision 1.5  2005/07/08 04:07:52  jgs  
 * Merge of development branch back to main trunk on 2005-07-08  
 *  
 * Revision 1.4  2004/12/15 07:08:33  jgs  
 * *** empty log message ***  
 * Revision 1.1.1.1.2.2  2005/06/29 02:34:52  gross  
 * some changes towards 64 integers in finley  
 *  
 * Revision 1.1.1.1.2.1  2004/11/24 01:37:14  gross  
 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
 *  
 *  
 *  
 */  
   

Legend:
Removed from v.123  
changed lines
  Added in v.1028

  ViewVC Help
Powered by ViewVC 1.1.26