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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations)
Thu Sep 15 03:44:45 2005 UTC (14 years, 9 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_glueFaces.c
File MIME type: text/plain
File size: 6900 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-15

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26