/[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 730 - (show annotations)
Mon May 15 04:03:49 2006 UTC (13 years, 4 months ago) by bcumming
File MIME type: text/plain
File size: 8037 byte(s)


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26