/[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 1028 by gross, Wed Mar 14 00:15:24 2007 UTC revision 1376 by gross, Wed Jan 9 01:38:18 2008 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 18  Line 21 
21    
22  /**************************************************************/  /**************************************************************/
23    
 /*  Author: gross@access.edu.au */  
 /*  Version: $Id$ */  
   
 /**************************************************************/  
   
24  #include "Mesh.h"  #include "Mesh.h"
25    
26  /**************************************************************/  /**************************************************************/
27    
28  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance) {  void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t optimize) {
29    
30     char error_msg[LenErrorMsg_MAX];     char error_msg[LenErrorMsg_MAX];
31     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;
32     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;
33     dim_t e,i,numPairs, NN, NN_Contact,c, new_numFaceElements;     dim_t e,i,numPairs, NN, NN_Contact,c, new_numFaceElements;
34    
35       if (self->MPIInfo->size>1) {
36         Finley_setError(TYPE_ERROR,"Finley_Mesh_joinFaces: MPI is not supported yet.");
37         return;
38       }
39     if (self->FaceElements==NULL) return;     if (self->FaceElements==NULL) return;
40    
41     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {
# Line 62  void Finley_Mesh_joinFaces(Finley_Mesh* Line 65  void Finley_Mesh_joinFaces(Finley_Mesh*
65     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);
66    
67     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)))  {
68    
69        /* find the matching face elements */        /* find the matching face elements */
70        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);
71        if (Finley_noError()) {        if (Finley_noError()) {
# Line 81  void Finley_Mesh_joinFaces(Finley_Mesh* Line 85  void Finley_Mesh_joinFaces(Finley_Mesh*
85               }               }
86           }           }
87           /*  allocate new face element and Contact element files */           /*  allocate new face element and Contact element files */
88  #ifndef PASO_MPI           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order,self->ContactElements->reduced_order, self->MPIInfo);
89           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order,self->FaceElements->reduced_order, self->MPIInfo);
          newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);  
 #else  
   /* TODO */  
   PASO_MPI_TODO;  
 #endif  
90           if (Finley_noError()) {           if (Finley_noError()) {
91                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);
92                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
# Line 112  void Finley_Mesh_joinFaces(Finley_Mesh* Line 111  void Finley_Mesh_joinFaces(Finley_Mesh*
111              }              }
112              newContactElementsFile->minColor=0;              newContactElementsFile->minColor=0;
113              newContactElementsFile->maxColor=numPairs-1;              newContactElementsFile->maxColor=numPairs-1;
             newContactElementsFile->isPrepared=self->FaceElements->isPrepared;  
114           }           }
115           /* set new face and Contact elements */           /* set new face and Contact elements */
116           if (Finley_noError()) {           if (Finley_noError()) {
117    
118              Finley_ElementFile_dealloc(self->FaceElements);              Finley_ElementFile_free(self->FaceElements);
119              self->FaceElements=newFaceElementsFile;              self->FaceElements=newFaceElementsFile;
120              Finley_ElementFile_prepare(&(self->FaceElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);              Finley_ElementFile_free(self->ContactElements);
   
             Finley_ElementFile_dealloc(self->ContactElements);  
121              self->ContactElements=newContactElementsFile;              self->ContactElements=newContactElementsFile;
122              Finley_ElementFile_prepare(&(self->ContactElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);              Finley_Mesh_prepare(self, optimize);
   
             Finley_Mesh_prepare(self);  
123    
124           } else {           } else {
125              Finley_ElementFile_dealloc(newFaceElementsFile);              Finley_ElementFile_free(newFaceElementsFile);
126              Finley_ElementFile_dealloc(newContactElementsFile);              Finley_ElementFile_free(newContactElementsFile);
127           }           }
128        }        }
129     }     }
# Line 137  void Finley_Mesh_joinFaces(Finley_Mesh* Line 131  void Finley_Mesh_joinFaces(Finley_Mesh*
131     TMPMEMFREE(elem0);     TMPMEMFREE(elem0);
132     TMPMEMFREE(matching_nodes_in_elem1);     TMPMEMFREE(matching_nodes_in_elem1);
133     TMPMEMFREE(elem_mask);     TMPMEMFREE(elem_mask);
    if (Finley_noError()) {  
        if ( ! Finley_Mesh_isPrepared(self) ) {  
           Finley_setError(SYSTEM_ERROR,"Mesh is not prepared for calculation. Contact the programmers.");  
        }  
   }  
134  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26