/[escript]/temp/finley/src/Mesh_findMatchingFaces.c
ViewVC logotype

Diff of /temp/finley/src/Mesh_findMatchingFaces.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 123 by jgs, Fri Jul 8 04:08:13 2005 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/04 */  /*  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 "Util.h"  #include "Util.h"
29  #include "Mesh.h"  #include "Mesh.h"
30    
# Line 53  void Finley_Mesh_findMatchingFaces(Finle Line 64  void Finley_Mesh_findMatchingFaces(Finle
64                (_i1_)=i; \                (_i1_)=i; \
65               }               }
66    
67        char error_msg[LenErrorMsg_MAX];
68      double h=DBLE(HUGE_VAL),h_local,dist,*X=NULL;      double h=DBLE(HUGE_VAL),h_local,dist,*X=NULL;
69      dim_t NN=faces->ReferenceElement->Type->numNodes;      dim_t NN=faces->ReferenceElement->Type->numNodes;
70      dim_t numDim=nodes->numDim;      dim_t numDim=nodes->numDim;
# Line 92  void Finley_Mesh_findMatchingFaces(Finle Line 104  void Finley_Mesh_findMatchingFaces(Finle
104         /* find elements with matching center */         /* find elements with matching center */
105         *numPairs=0;         *numPairs=0;
106         /* OMP */         /* OMP */
107         for (e=0;e<faces->numElements-1 && Finley_ErrorCode==NO_ERROR;e++) {         for (e=0;e<faces->numElements-1 && Finley_noError();e++) {
108            if (Finley_Mesh_findMatchingFaces_compar((void*) &(center[e]),(void*) &(center[e+1]))==0) {            if (Finley_Mesh_findMatchingFaces_compar((void*) &(center[e]),(void*) &(center[e+1]))==0) {
109                e_0=center[e].refId;                e_0=center[e].refId;
110                e_1=center[e+1].refId;                e_1=center[e+1].refId;
# Line 102  void Finley_Mesh_findMatchingFaces(Finle Line 114  void Finley_Mesh_findMatchingFaces(Finle
114                perm=a1;                perm=a1;
115                perm_tmp=a2;                perm_tmp=a2;
116                for (i=0;i<NN;i++) perm[i]=i;                for (i=0;i<NN;i++) perm[i]=i;
117                while (Finley_ErrorCode==NO_ERROR) {                while (Finley_noError()) {
118                   /* if node 0 and perm[0] are the same we are ready */                   /* if node 0 and perm[0] are the same we are ready */
119                   getDist(dist,e_0,0,e_1,perm[0]);                   getDist(dist,e_0,0,e_1,perm[0]);
120                   if (dist<=h*tolerance) break;                   if (dist<=h*tolerance) break;
# Line 113  void Finley_Mesh_findMatchingFaces(Finle Line 125  void Finley_Mesh_findMatchingFaces(Finle
125                   }                   }
126                   /* if the permutation is back at the identity, ie. perm[0]=0, the faces don't match: */                   /* if the permutation is back at the identity, ie. perm[0]=0, the faces don't match: */
127                   if (perm[0]==0) {                   if (perm[0]==0) {
128                         Finley_ErrorCode=VALUE_ERROR;                         sprintf(error_msg,"__FILE__:couldn't match first node of element %d to touching element %d",e_0,e_1);
129                         sprintf(Finley_ErrorMsg,"couldn't match first node of element %d to touching element %d",e_0,e_1);                         Finley_setError(VALUE_ERROR,error_msg);
130                   }                   }
131                }                }
132                /* now we check if the second nodes match */                /* now we check if the second nodes match */
133                if (Finley_ErrorCode==NO_ERROR) {                if (Finley_noError()) {
134                   if (faces->ReferenceElement->Type->numNodesOnFace>1) {                   if (faces->ReferenceElement->Type->numNodesOnFace>1) {
135                      getDist(dist,e_0,1,e_1,perm[faces->ReferenceElement->Type->faceNode[1]]);                      getDist(dist,e_0,1,e_1,perm[faces->ReferenceElement->Type->faceNode[1]]);
136                      /* if the second node does not match we reverse the direction of the nodes */                      /* if the second node does not match we reverse the direction of the nodes */
137                      if (dist>h*tolerance) {                      if (dist>h*tolerance) {
138                            /* rotate the nodes */                            /* rotate the nodes */
139                            if (faces->ReferenceElement->Type->reverseNodes[0]<0) {                            if (faces->ReferenceElement->Type->reverseNodes[0]<0) {
140                               Finley_ErrorCode=VALUE_ERROR;                               sprintf(error_msg,"__FILE__:couldn't match the second node of element %d to touching element %d",e_0,e_1);
141                               sprintf(Finley_ErrorMsg,"couldn't match the second node of element %d to touching element %d",e_0,e_1);                               Finley_setError(VALUE_ERROR,error_msg);
142                            } else {                            } else {
143                               for (i=0;i<NN;i++) perm_tmp[i]=perm[faces->ReferenceElement->Type->reverseNodes[i]];                               for (i=0;i<NN;i++) perm_tmp[i]=perm[faces->ReferenceElement->Type->reverseNodes[i]];
144                               SWAP(perm,perm_tmp);                               SWAP(perm,perm_tmp);
145                               getDist(dist,e_0,1,e_1,perm[faces->ReferenceElement->Type->faceNode[1]]);                               getDist(dist,e_0,1,e_1,perm[faces->ReferenceElement->Type->faceNode[1]]);
146                               if (dist>h*tolerance) {                               if (dist>h*tolerance) {
147                                   Finley_ErrorCode=VALUE_ERROR;                                   sprintf(error_msg,"__FILE__:couldn't match the second node of element %d to touching element %d",e_0,e_1);
148                                   sprintf(Finley_ErrorMsg,"couldn't match the second node of element %d to touching element %d",e_0,e_1);                                   Finley_setError(VALUE_ERROR,error_msg);
149                               }                               }
150                            }                            }
151                      }                      }
152                   }                   }
153                }                }
154                /* we check if the rest of the face nodes match: */                /* we check if the rest of the face nodes match: */
155                if (Finley_ErrorCode==NO_ERROR) {                if (Finley_noError()) {
156                   for (i=2;i<faces->ReferenceElement->Type->numNodesOnFace;i++) {                   for (i=2;i<faces->ReferenceElement->Type->numNodesOnFace;i++) {
157                      n=faces->ReferenceElement->Type->faceNode[i];                      n=faces->ReferenceElement->Type->faceNode[i];
158                      getDist(dist,e_0,n,e_1,perm[n]);                      getDist(dist,e_0,n,e_1,perm[n]);
159                      if (dist>h*tolerance) {                      if (dist>h*tolerance) {
160                         Finley_ErrorCode=VALUE_ERROR;                         sprintf(error_msg,"__FILE__:couldn't match the %d-th node of element %d to touching element %d",i,e_0,e_1);
161                         sprintf(Finley_ErrorMsg,"couldn't match the %d-th node of element %d to touching element %d",i,e_0,e_1);                         Finley_setError(VALUE_ERROR,error_msg);
162                         break;                         break;
163                      }                      }
164                   }                   }
165                }                }
166                /* copy over the permuted nodes of e_1 into matching_nodes_in_elem1 */                /* copy over the permuted nodes of e_1 into matching_nodes_in_elem1 */
167                if (Finley_ErrorCode==NO_ERROR) {                if (Finley_noError()) {
168                   for (i=0;i<NN;i++)  matching_nodes_in_elem1[INDEX2(i,*numPairs,NN)]=faces->Nodes[INDEX2(perm[i],e_1,NN)];                   for (i=0;i<NN;i++)  matching_nodes_in_elem1[INDEX2(i,*numPairs,NN)]=faces->Nodes[INDEX2(perm[i],e_1,NN)];
169                }                }
170                (*numPairs)++;                (*numPairs)++;
# Line 172  void Finley_Mesh_findMatchingFaces(Finle Line 184  void Finley_Mesh_findMatchingFaces(Finle
184    
185  /*  /*
186  * $Log$  * $Log$
187    * Revision 1.6  2005/09/15 03:44:22  jgs
188    * Merge of development branch dev-02 back to main trunk on 2005-09-15
189    *
190    * Revision 1.5.2.1  2005/09/07 06:26:19  gross
191    * the solver from finley are put into the standalone package paso now
192    *
193  * Revision 1.5  2005/07/08 04:07:51  jgs  * Revision 1.5  2005/07/08 04:07:51  jgs
194  * Merge of development branch back to main trunk on 2005-07-08  * Merge of development branch back to main trunk on 2005-07-08
195  *  *

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

  ViewVC Help
Powered by ViewVC 1.1.26