/[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 150 by jgs, Thu Sep 15 03:44:45 2005 UTC trunk/finley/src/Mesh_joinFaces.c revision 2748 by gross, Tue Nov 17 07:32:59 2009 UTC
# Line 1  Line 1 
1  /*  
2   ******************************************************************************  /*******************************************************
3   *                                                                            *  *
4   *       COPYRIGHT  ACcESS 2003,2004,2005 -  All Rights Reserved              *  * Copyright (c) 2003-2009 by University of Queensland
5   *                                                                            *  * Earth Systems Science Computational Center (ESSCC)
6   * This software is the property of ACcESS. No part of this code              *  * http://www.uq.edu.au/esscc
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          *  * Primary Business: Queensland, Australia
9   * by any unauthorised person is illegal unless that person has a software    *  * Licensed under the Open Software License version 3.0
10   * license agreement with ACcESS.                                             *  * http://www.opensource.org/licenses/osl-3.0.php
11   *                                                                            *  *
12   ******************************************************************************  *******************************************************/
13  */  
14    
15  /**************************************************************/  /**************************************************************/
16    
# Line 20  Line 20 
20    
21  /**************************************************************/  /**************************************************************/
22    
 /*  Author: gross@access.edu.au */  
 /*  Version: $Id$ */  
   
 /**************************************************************/  
   
23  #include "Mesh.h"  #include "Mesh.h"
24    
25  /**************************************************************/  /**************************************************************/
26    
27  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) {
28    
29     char error_msg[LenErrorMsg_MAX];     char error_msg[LenErrorMsg_MAX];
30     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;
31     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;     Finley_ElementFile *newFaceElementsFile=NULL,*newContactElementsFile=NULL;
32     dim_t e,i,numPairs;     dim_t e,i,numPairs, NN, NN_Contact,c, new_numFaceElements;
33     if (self->FaceElements==NULL) return;     Finley_ReferenceElement*  faceRefElement=NULL, *contactRefElement=NULL;
34    
35     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {     if (self->MPIInfo->size>1) {
36       sprintf(error_msg,"__FILE__:joining faces cannot be applied to face elements of type %s",self->FaceElements->ReferenceElement->Type->Name);       Finley_setError(TYPE_ERROR,"Finley_Mesh_joinFaces: MPI is not supported yet.");
      Finley_setError(TYPE_ERROR,error_msg);  
37       return;       return;
38     }     }
39     if (self->ContactElements==NULL) {     if (self->ContactElements==NULL) {
40       Finley_setError(TYPE_ERROR,"__FILE__: no contact element file present.");       Finley_setError(TYPE_ERROR,"Finley_Mesh_joinFaces: no contact element file present.");
41         return;
42       }
43       if (self->FaceElements==NULL) return;
44       faceRefElement= Finley_ReferenceElementSet_borrowReferenceElement(self->FaceElements->referenceElementSet, FALSE);
45       contactRefElement= Finley_ReferenceElementSet_borrowReferenceElement(self->ContactElements->referenceElementSet, FALSE);
46      
47    
48       NN=self->FaceElements->numNodes;
49       NN_Contact=self->ContactElements->numNodes;
50    
51       if (faceRefElement->Type->numNodesOnFace<=0) {
52         sprintf(error_msg,"Finley_Mesh_joinFaces:joining faces cannot be applied to face elements of type %s",faceRefElement->Type->Name);
53         Finley_setError(TYPE_ERROR,error_msg);
54       return;       return;
55     }     }
56    
    int NN=self->FaceElements->ReferenceElement->Type->numNodes;  
    int NN_Contact=self->ContactElements->ReferenceElement->Type->numNodes;  
57    
58     if (2*NN!=NN_Contact) {     if (contactRefElement->Type->numNodes != 2*faceRefElement->Type->numNodes) {
59       sprintf(error_msg,"__FILE__:contact element file for %s cannot hold elements created from face elements %s",       sprintf(error_msg,"Finley_Mesh_joinFaces:contact element file for %s need to hold elements created from face elements %s", contactRefElement->Type->Name,faceRefElement->Type->Name);
            self->ContactElements->ReferenceElement->Type->Name,self->FaceElements->ReferenceElement->Type->Name);  
60       Finley_setError(TYPE_ERROR,error_msg);       Finley_setError(TYPE_ERROR,error_msg);
61       return;       return;
62     }     }
# Line 64  void Finley_Mesh_joinFaces(Finley_Mesh* Line 68  void Finley_Mesh_joinFaces(Finley_Mesh*
68     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);
69    
70     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)))  {
71    
72        /* find the matching face elements */        /* find the matching face elements */
73        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);
74        if (Finley_noError()) {        if (Finley_noError()) {
# Line 74  void Finley_Mesh_joinFaces(Finley_Mesh* Line 79  void Finley_Mesh_joinFaces(Finley_Mesh*
79               elem_mask[elem0[e]]=0;               elem_mask[elem0[e]]=0;
80               elem_mask[elem1[e]]=0;               elem_mask[elem1[e]]=0;
81           }           }
82           dim_t new_numFaceElements=0;           new_numFaceElements=0;
83           /* OMP */           /* OMP */
84           for(e=0;e<self->FaceElements->numElements;e++) {           for(e=0;e<self->FaceElements->numElements;e++) {
85               if (elem_mask[e]>0) {               if (elem_mask[e]>0) {
# Line 83  void Finley_Mesh_joinFaces(Finley_Mesh* Line 88  void Finley_Mesh_joinFaces(Finley_Mesh*
88               }               }
89           }           }
90           /*  allocate new face element and Contact element files */           /*  allocate new face element and Contact element files */
91           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->ReferenceElement->Type->TypeId,self->ContactElements->order);           newContactElementsFile=Finley_ElementFile_alloc(self->ContactElements->referenceElementSet, self->MPIInfo);
92           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);           newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->referenceElementSet, self->MPIInfo);
93           if (Finley_noError()) {           if (Finley_noError()) {
94                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);                 Finley_ElementFile_allocTable(newContactElementsFile,numPairs+self->ContactElements->numElements);
95                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);                 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
# Line 95  void Finley_Mesh_joinFaces(Finley_Mesh* Line 100  void Finley_Mesh_joinFaces(Finley_Mesh*
100              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);              Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
101              /* get the Contact elements which are still in use:*/              /* get the Contact elements which are still in use:*/
102              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);              Finley_ElementFile_copyTable(0,newContactElementsFile,0,0,self->ContactElements);
103              dim_t c=self->ContactElements->numElements;              c=self->ContactElements->numElements;
104              /* OMP */              /* OMP */
105              for (e=0;e<numPairs;e++) {              for (e=0;e<numPairs;e++) {
106                   e0=elem0[e];                   e0=elem0[e];
# Line 113  void Finley_Mesh_joinFaces(Finley_Mesh* Line 118  void Finley_Mesh_joinFaces(Finley_Mesh*
118           /* set new face and Contact elements */           /* set new face and Contact elements */
119           if (Finley_noError()) {           if (Finley_noError()) {
120    
121              Finley_ElementFile_dealloc(self->FaceElements);              Finley_ElementFile_free(self->FaceElements);
122              self->FaceElements=newFaceElementsFile;              self->FaceElements=newFaceElementsFile;
123              Finley_ElementFile_prepare(&(self->FaceElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);              Finley_ElementFile_free(self->ContactElements);
   
             Finley_ElementFile_dealloc(self->ContactElements);  
124              self->ContactElements=newContactElementsFile;              self->ContactElements=newContactElementsFile;
125              Finley_ElementFile_prepare(&(self->ContactElements),self->Nodes->numNodes,self->Nodes->degreeOfFreedom);              Finley_Mesh_prepare(self, optimize);
   
             Finley_Mesh_prepareNodes(self);  
126    
127           } else {           } else {
128              Finley_ElementFile_dealloc(newFaceElementsFile);              Finley_ElementFile_free(newFaceElementsFile);
129              Finley_ElementFile_dealloc(newContactElementsFile);              Finley_ElementFile_free(newContactElementsFile);
130           }           }
131        }        }
132     }     }
# Line 134  void Finley_Mesh_joinFaces(Finley_Mesh* Line 135  void Finley_Mesh_joinFaces(Finley_Mesh*
135     TMPMEMFREE(matching_nodes_in_elem1);     TMPMEMFREE(matching_nodes_in_elem1);
136     TMPMEMFREE(elem_mask);     TMPMEMFREE(elem_mask);
137  }  }
   
 /*  
 * $Log$  
 * Revision 1.6  2005/09/15 03:44:22  jgs  
 * Merge of development branch dev-02 back to main trunk on 2005-09-15  
 *  
 * Revision 1.5.2.1  2005/09/07 06:26:19  gross  
 * the solver from finley are put into the standalone package paso now  
 *  
 * 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.150  
changed lines
  Added in v.2748

  ViewVC Help
Powered by ViewVC 1.1.26