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

Annotation of /trunk/finley/src/finley/Mesh_glueFaces.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (hide annotations)
Fri Jul 8 04:08:13 2005 UTC (15 years ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_glueFaces.c
File MIME type: text/plain
File size: 5874 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 jgs 82 /**************************************************************/
2    
3     /* Finley: Mesh */
4    
5     /* removes matching face elements from self */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS Australia 2003/04 */
10     /* Author: gross@access.edu.au */
11     /* Version: $Id$ */
12    
13     /**************************************************************/
14    
15     #include "Common.h"
16     #include "Finley.h"
17     #include "Mesh.h"
18    
19     /**************************************************************/
20    
21    
22     void Finley_Mesh_glueFaces(Finley_Mesh* self,double safety_factor,double tolerance) {
23     Finley_NodeFile *newNodeFile=NULL;
24     Finley_ElementFile *newFaceElementsFile=NULL;
25 jgs 123 dim_t numPairs,e,i,n;
26     index_t face_node, *elem1=NULL,*elem0=NULL,*elem_mask=NULL,*new_node_label=NULL,*new_node_list=NULL,*new_node_mask=NULL,*matching_nodes_in_elem1=NULL;
27    
28 jgs 82 if (self->FaceElements==NULL) return;
29    
30     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {
31     Finley_ErrorCode=TYPE_ERROR;
32     sprintf(Finley_ErrorMsg,"glueing faces cannot be applied to face elements pf type %s",self->FaceElements->ReferenceElement->Type->Name);
33     return;
34     }
35    
36 jgs 123 dim_t NNFace=self->FaceElements->ReferenceElement->Type->numNodesOnFace;
37     dim_t NN=self->FaceElements->ReferenceElement->Type->numNodes;
38     dim_t numDim=self->Nodes->numDim;
39 jgs 82 /* allocate work arrays */
40 jgs 123 elem1=TMPMEMALLOC(self->FaceElements->numElements,index_t);
41     elem0=TMPMEMALLOC(self->FaceElements->numElements,index_t);
42     elem_mask=TMPMEMALLOC(self->FaceElements->numElements,index_t);
43     matching_nodes_in_elem1=TMPMEMALLOC(self->FaceElements->numElements*NN,index_t);
44     new_node_label=TMPMEMALLOC(self->Nodes->numNodes,index_t);
45     new_node_list=TMPMEMALLOC(self->Nodes->numNodes,index_t);
46     new_node_mask=TMPMEMALLOC(self->Nodes->numNodes,index_t);
47 jgs 82 if (!(Finley_checkPtr(elem1) || Finley_checkPtr(elem0) || Finley_checkPtr(elem_mask) || Finley_checkPtr(new_node_label) || Finley_checkPtr(new_node_list) || Finley_checkPtr(new_node_mask) || Finley_checkPtr(matching_nodes_in_elem1)) ) {
48     /* find the matching face elements */
49     Finley_Mesh_findMatchingFaces(self->Nodes,self->FaceElements,safety_factor,tolerance,&numPairs,elem0,elem1,matching_nodes_in_elem1);
50     if (Finley_ErrorCode==NO_ERROR) {
51     for(e=0;e<self->FaceElements->numElements;e++) elem_mask[e]=0;
52     for(n=0;n<self->Nodes->numNodes;n++) new_node_label[n]=n;
53     /* remove mark imatching face elements to be removed */
54     for(e=0;e<numPairs;e++) {
55     elem_mask[elem0[e]]=1;
56     elem_mask[elem1[e]]=1;
57     for (i=0;i<NNFace;i++) {
58     face_node=self->FaceElements->ReferenceElement->Type->faceNode[i];
59     new_node_label[matching_nodes_in_elem1[INDEX2(face_node,e,NN)]]=self->FaceElements->Nodes[INDEX2(face_node,elem0[e],NN)];
60     }
61     }
62     /* create an index of face elements */
63 jgs 123 dim_t new_numFaceElements=0;
64 jgs 82 for(e=0;e<self->FaceElements->numElements;e++) {
65     if (elem_mask[e]<1) {
66     elem_mask[new_numFaceElements]=e;
67     new_numFaceElements++;
68     }
69     }
70     /* get the new number of nodes */
71 jgs 123 dim_t newNumNodes=0;
72 jgs 82 for (n=0;n<self->Nodes->numNodes;n++) new_node_mask[n]=-1;
73     for (n=0;n<self->Nodes->numNodes;n++) new_node_mask[new_node_label[n]]=1;
74     for (n=0;n<self->Nodes->numNodes;n++) {
75     if (new_node_mask[n]>0) {
76     new_node_mask[n]=newNumNodes;
77     new_node_list[newNumNodes]=n;
78     newNumNodes++;
79     }
80     }
81     for (n=0;n<self->Nodes->numNodes;n++) new_node_label[n]=new_node_mask[new_node_label[n]];
82     /* allocate new node and element files */
83     newNodeFile=Finley_NodeFile_alloc(numDim);
84     if (Finley_ErrorCode==NO_ERROR) {
85     Finley_NodeFile_allocTable(newNodeFile,newNumNodes);
86     if (Finley_ErrorCode==NO_ERROR) {
87     newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,self->FaceElements->order);
88     if (Finley_ErrorCode==NO_ERROR) {
89     Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
90     }
91     }
92     }
93     if (Finley_ErrorCode==NO_ERROR) {
94     /* get the new nodes :*/
95     Finley_NodeFile_gather(new_node_list,self->Nodes,newNodeFile);
96     /* they are the new nodes*/
97     Finley_NodeFile_dealloc(self->Nodes);
98     self->Nodes=newNodeFile;
99     /* get the face elements which are still in use:*/
100     Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
101     /* they are the new face elements */
102     Finley_ElementFile_dealloc(self->FaceElements);
103     self->FaceElements=newFaceElementsFile;
104    
105     /* assign new node ids to elements */
106     Finley_Mesh_relableElementNodes(new_node_label,0,self);
107     } else {
108     Finley_NodeFile_dealloc(newNodeFile);
109     Finley_ElementFile_dealloc(newFaceElementsFile);
110     }
111     }
112     }
113     TMPMEMFREE(elem1);
114     TMPMEMFREE(elem0);
115     TMPMEMFREE(elem_mask);
116     TMPMEMFREE(new_node_label);
117     TMPMEMFREE(new_node_list);
118     TMPMEMFREE(new_node_mask);
119     TMPMEMFREE(matching_nodes_in_elem1);
120     }
121    
122     /*
123     * $Log$
124 jgs 123 * Revision 1.5 2005/07/08 04:07:52 jgs
125     * Merge of development branch back to main trunk on 2005-07-08
126     *
127 jgs 102 * Revision 1.4 2004/12/15 07:08:33 jgs
128 jgs 97 * *** empty log message ***
129 jgs 123 * Revision 1.1.1.1.2.2 2005/06/29 02:34:51 gross
130     * some changes towards 64 integers in finley
131 jgs 82 *
132 jgs 123 * Revision 1.1.1.1.2.1 2004/11/24 01:37:14 gross
133     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
134 jgs 97 *
135 jgs 82 *
136 jgs 123 *
137 jgs 82 */
138    

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26