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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 /**************************************************************/
2
3 /* Finley: Mesh */
4
5 /* takes nodes elements, etc of in2 and copies them into in1 */
6 /* Ids of in2 are shifted by the maximum Id of in1 */
7
8 /**************************************************************/
9
10 /* Copyrights by ACcESS Australia 2003/04 */
11 /* Author: gross@access.edu.au */
12 /* Version: $Id$ */
13
14 /**************************************************************/
15
16 #include "Finley.h"
17 #include "Mesh.h"
18 #include "Util.h"
19
20 /**************************************************************/
21
22 static double Finley_Mesh_lockingGridSize=0;
23
24 Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
25 Finley_Mesh* out=NULL;
26 dim_t i;
27 char newName[LenString_MAX];
28 if (numMsh==0) {
29 Finley_ErrorCode=VALUE_ERROR;
30 sprintf(Finley_ErrorMsg,"Empty mesh list");
31 } else {
32 index_t order=msh[0]->order;
33 dim_t numDim=msh[0]->Nodes->numDim;
34 ElementTypeId elementTypeId=NoType;
35 ElementTypeId faceElementTypeId=NoType;
36 ElementTypeId pointTypeId=NoType;
37 ElementTypeId contactTypeId=NoType;
38 strcpy(newName,"");
39 dim_t numNodes=0;
40 dim_t numElements=0;
41 dim_t numFaceElements=0;
42 dim_t numContactElements=0;
43 dim_t numPoints=0;
44 for (i=0;i<numMsh;i++) {
45 /* check if all mesh have the same type and dimensions */
46 order=MAX(order,msh[i]->order);
47 numNodes+=msh[i]->Nodes->numNodes;
48 if (numDim!=msh[i]->Nodes->numDim) {
49 Finley_ErrorCode=TYPE_ERROR;
50 sprintf(Finley_ErrorMsg,"Spatial dimensions of meshes don't match.");
51 }
52
53 if (msh[i]->Elements!=NULL) {
54 numElements+=msh[i]->Elements->numElements;
55 if (elementTypeId==NoType) {
56 elementTypeId=msh[i]->Elements->ReferenceElement->Type->TypeId;
57 } else {
58 if (elementTypeId!=msh[i]->Elements->ReferenceElement->Type->TypeId ) {
59 Finley_ErrorCode=TYPE_ERROR;
60 sprintf(Finley_ErrorMsg,"element types of meshes don't match.");
61 }
62 }
63 }
64
65 if (msh[i]->FaceElements!=NULL) {
66 numFaceElements+=msh[i]->FaceElements->numElements;
67 if (faceElementTypeId==NoType) {
68 faceElementTypeId=msh[i]->FaceElements->ReferenceElement->Type->TypeId;
69 } else {
70 if (faceElementTypeId!=msh[i]->FaceElements->ReferenceElement->Type->TypeId ) {
71 Finley_ErrorCode=TYPE_ERROR;
72 sprintf(Finley_ErrorMsg,"face element types of meshes don't match.");
73 }
74 }
75 }
76
77 if (msh[i]->ContactElements!=NULL) {
78 numContactElements+=msh[i]->ContactElements->numElements;
79 if (contactTypeId==NoType) {
80 contactTypeId=msh[i]->ContactElements->ReferenceElement->Type->TypeId;
81 } else {
82 if (contactTypeId!=msh[i]->ContactElements->ReferenceElement->Type->TypeId ) {
83 Finley_ErrorCode=TYPE_ERROR;
84 sprintf(Finley_ErrorMsg,"contact element types of meshes don't match.");
85 }
86 }
87 }
88
89 if (msh[i]->Points!=NULL) {
90 numPoints+=msh[i]->Points->numElements;
91 if (pointTypeId==NoType) {
92 pointTypeId=msh[i]->Points->ReferenceElement->Type->TypeId;
93 } else {
94 if (pointTypeId!=msh[i]->Points->ReferenceElement->Type->TypeId ) {
95 Finley_ErrorCode=TYPE_ERROR;
96 sprintf(Finley_ErrorMsg,"point element types of meshes don't match.");
97 }
98 }
99 }
100
101 strncat(newName,"+",LenString_MAX-strlen(newName));
102 strncat(newName,msh[i]->Name,LenString_MAX-strlen(newName)-1);
103 }
104
105 /* allocate */
106
107 if (Finley_ErrorCode == NO_ERROR) out=Finley_Mesh_alloc(newName,numDim,order);
108
109 out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);
110 out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order);
111 out->Points=Finley_ElementFile_alloc(pointTypeId,out->order);
112 out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order);
113
114 /* allocate new tables */
115
116 if (Finley_ErrorCode == NO_ERROR) {
117 Finley_NodeFile_allocTable(out->Nodes,numNodes);
118 Finley_ElementFile_allocTable(out->Elements,numElements);
119 Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
120 Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
121 Finley_ElementFile_allocTable(out->Points,numPoints);
122 }
123
124 /* copy tables :*/
125
126 if (Finley_ErrorCode == NO_ERROR) {
127
128 dim_t numNodes=0;
129 dim_t numElements=0;
130 dim_t numFaceElements=0;
131 dim_t numContactElements=0;
132 dim_t numPoints=0;
133 index_t maxNodeID=0;
134 index_t maxDOF=0;
135 index_t maxElementID=0;
136 index_t maxElementID2=0;
137
138 for (i=0;i<numMsh;i++) {
139
140 Finley_NodeFile_copyTable(numNodes,out->Nodes,maxNodeID,maxDOF,msh[i]->Nodes);
141 Finley_ElementFile_copyTable(numElements,out->Elements,numNodes,maxElementID,msh[i]->Elements);
142 Finley_ElementFile_copyTable(numFaceElements,out->FaceElements,numNodes,maxElementID,msh[i]->FaceElements);
143 Finley_ElementFile_copyTable(numContactElements,out->ContactElements,numNodes,maxElementID,msh[i]->ContactElements);
144 Finley_ElementFile_copyTable(numPoints,out->Points,numNodes,maxElementID,msh[i]->Points);
145
146 numNodes=+msh[i]->Nodes->numNodes;
147 numElements=+msh[i]->Elements->numElements;
148 numFaceElements=+msh[i]->FaceElements->numElements;
149 numContactElements=+msh[i]->ContactElements->numElements;
150 numPoints=+msh[i]->Points->numElements;
151
152 if (msh[i]->Nodes->numNodes>0)
153 maxNodeID+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->Id)+1;
154 maxDOF+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->degreeOfFreedom)+1;
155 maxElementID2=0;
156 if (msh[i]->Elements->numElements>0)
157 maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Elements->numElements,msh[i]->Elements->Id));
158 if (msh[i]->FaceElements->numElements>0)
159 maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->FaceElements->numElements,msh[i]->FaceElements->Id));
160 if (msh[i]->ContactElements->numElements>0)
161 maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->ContactElements->numElements,msh[i]->ContactElements->Id));
162 if (msh[i]->Points->numElements)
163 maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Points->numElements,msh[i]->Points->Id));
164 maxElementID+=maxElementID2+1;
165 }
166 }
167 /* all done */
168
169 if (Finley_ErrorCode != NO_ERROR) {
170 Finley_Mesh_dealloc(out);
171 } else {
172 Finley_Mesh_prepare(out);
173 #ifdef Finley_TRACE
174 printf("%d meshes merged.\n",numMsh);
175 #endif
176 }
177 }
178 return out;
179 }
180
181 /*
182 * $Log$
183 * Revision 1.2 2005/07/08 04:07:53 jgs
184 * Merge of development branch back to main trunk on 2005-07-08
185 *
186 * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
187 * some changes towards 64 integers in finley
188 *
189 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
190 * initial import of project esys2
191 *
192 * Revision 1.2 2004/07/30 04:37:06 gross
193 * escript and finley are linking now and RecMeshTest.py has been passed
194 *
195 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
196 * Initial version of eys using boost-python.
197 *
198 *
199 */
200

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26