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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2320 - (hide annotations)
Thu Mar 19 03:40:16 2009 UTC (12 years, 4 months ago) by gross
File MIME type: text/plain
File size: 6143 byte(s)
some modifictaions to make sure that Mesh_merge.c Mesh_glueFaces.c Mesh_joinFaces.c reject to work under MPI
1 jgs 150
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17     /* Finley: Mesh */
18    
19     /* removes matching face elements from self */
20    
21     /**************************************************************/
22    
23     #include "Mesh.h"
24    
25     /**************************************************************/
26    
27    
28 ksteube 1312 void Finley_Mesh_glueFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t optimize) {
29 jgs 150 char error_msg[LenErrorMsg_MAX];
30 jgs 82 Finley_NodeFile *newNodeFile=NULL;
31     Finley_ElementFile *newFaceElementsFile=NULL;
32 gross 1028 dim_t numPairs,e,i,n, NNFace, NN, numDim, new_numFaceElements, newNumNodes;
33 jgs 123 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;
34    
35 ksteube 1312 if (self->MPIInfo->size>1) {
36     Finley_setError(TYPE_ERROR,"Finley_Mesh_glueFaces: MPI is not supported yet.");
37     return;
38     }
39    
40 jgs 82 if (self->FaceElements==NULL) return;
41    
42     if (self->FaceElements->ReferenceElement->Type->numNodesOnFace<=0) {
43 jgs 153 sprintf(error_msg,"Finley_Mesh_glueFaces:glueing faces cannot be applied to face elements of type %s",self->FaceElements->ReferenceElement->Type->Name);
44 jgs 150 Finley_setError(TYPE_ERROR,error_msg);
45 jgs 82 return;
46     }
47    
48 gross 1028 NNFace=self->FaceElements->ReferenceElement->Type->numNodesOnFace;
49     NN=self->FaceElements->ReferenceElement->Type->numNodes;
50     numDim=self->Nodes->numDim;
51 jgs 82 /* allocate work arrays */
52 jgs 123 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 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)) ) {
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 jgs 150 if (Finley_noError()) {
63 jgs 82 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 gross 1028 new_numFaceElements=0;
76 jgs 82 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 gross 1028 newNumNodes=0;
84 jgs 82 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 ksteube 1312 newNodeFile=Finley_NodeFile_alloc(numDim, self->MPIInfo);
96 bcumming 730
97 jgs 150 if (Finley_noError()) {
98 jgs 82 Finley_NodeFile_allocTable(newNodeFile,newNumNodes);
99 jgs 150 if (Finley_noError()) {
100 ksteube 1312 newFaceElementsFile=Finley_ElementFile_alloc(self->FaceElements->ReferenceElement->Type->TypeId,
101     self->FaceElements->order,
102     self->FaceElements->reduced_order,
103     self->MPIInfo);
104 jgs 150 if (Finley_noError()) {
105 jgs 82 Finley_ElementFile_allocTable(newFaceElementsFile,new_numFaceElements);
106     }
107     }
108     }
109 bcumming 730 if (Finley_noError())
110     {
111 jgs 82 /* get the new nodes :*/
112     Finley_NodeFile_gather(new_node_list,self->Nodes,newNodeFile);
113     /* they are the new nodes*/
114 ksteube 1312 Finley_NodeFile_free(self->Nodes);
115 jgs 82 self->Nodes=newNodeFile;
116     /* get the face elements which are still in use:*/
117     Finley_ElementFile_gather(elem_mask,self->FaceElements,newFaceElementsFile);
118     /* they are the new face elements */
119 ksteube 1312 Finley_ElementFile_free(self->FaceElements);
120 jgs 82 self->FaceElements=newFaceElementsFile;
121    
122     /* assign new node ids to elements */
123     Finley_Mesh_relableElementNodes(new_node_label,0,self);
124 jgs 153
125 ksteube 1312 Finley_Mesh_prepare(self, optimize);
126 bcumming 730 }
127     else
128     {
129 ksteube 1312 Finley_NodeFile_free(newNodeFile);
130     Finley_ElementFile_free(newFaceElementsFile);
131 jgs 82 }
132 bcumming 730
133 jgs 82 }
134 bcumming 730 }
135 jgs 82 TMPMEMFREE(elem1);
136     TMPMEMFREE(elem0);
137     TMPMEMFREE(elem_mask);
138     TMPMEMFREE(new_node_label);
139     TMPMEMFREE(new_node_list);
140     TMPMEMFREE(new_node_mask);
141     TMPMEMFREE(matching_nodes_in_elem1);
142     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26