/[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 471 - (show annotations)
Fri Jan 27 01:33:02 2006 UTC (13 years, 8 months ago) by jgs
File MIME type: text/plain
File size: 8307 byte(s)
reorganise finley src tree to remove inc dir and src/finley directory

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26