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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 616 - (hide annotations)
Wed Mar 22 02:46:56 2006 UTC (13 years, 7 months ago) by elspeth
File MIME type: text/plain
File size: 7985 byte(s)
Copyright added to more source files.

1 jgs 150 /*
2 elspeth 616 ************************************************************
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 jgs 150 */
12    
13 jgs 82 /**************************************************************/
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 jgs 150 /* Author: gross@access.edu.au */
23     /* Version: $Id$ */
24 jgs 82
25     /**************************************************************/
26    
27     #include "Mesh.h"
28     #include "Util.h"
29    
30     /**************************************************************/
31    
32     static double Finley_Mesh_lockingGridSize=0;
33    
34 jgs 123 Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
35 jgs 82 Finley_Mesh* out=NULL;
36 jgs 123 dim_t i;
37 jgs 82 char newName[LenString_MAX];
38     if (numMsh==0) {
39 jgs 150 Finley_setError(VALUE_ERROR,"__FILE__: Empty mesh list");
40 jgs 82 } else {
41 jgs 123 index_t order=msh[0]->order;
42     dim_t numDim=msh[0]->Nodes->numDim;
43 jgs 82 ElementTypeId elementTypeId=NoType;
44     ElementTypeId faceElementTypeId=NoType;
45     ElementTypeId pointTypeId=NoType;
46     ElementTypeId contactTypeId=NoType;
47     strcpy(newName,"");
48 jgs 123 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 jgs 82 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 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: Spatial dimensions of meshes don't match.");
59 jgs 82 }
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 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: element types of meshes don't match.");
68 jgs 82 }
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 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: face element types of meshes don't match.");
79 jgs 82 }
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 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: contact element types of meshes don't match.");
90 jgs 82 }
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 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: point element types of meshes don't match.");
101 jgs 82 }
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 jgs 150 if (Finley_noError()) out=Finley_Mesh_alloc(newName,numDim,order);
112 jgs 82
113     out->Elements=Finley_ElementFile_alloc(elementTypeId,out->order);
114     out->FaceElements=Finley_ElementFile_alloc(faceElementTypeId,out->order);
115     out->Points=Finley_ElementFile_alloc(pointTypeId,out->order);
116     out->ContactElements=Finley_ElementFile_alloc(contactTypeId,out->order);
117    
118     /* allocate new tables */
119    
120 jgs 150 if (Finley_noError()) {
121 jgs 82 Finley_NodeFile_allocTable(out->Nodes,numNodes);
122     Finley_ElementFile_allocTable(out->Elements,numElements);
123     Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
124     Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
125     Finley_ElementFile_allocTable(out->Points,numPoints);
126     }
127    
128     /* copy tables :*/
129    
130 jgs 150 if (Finley_noError()) {
131 jgs 82
132 jgs 123 dim_t numNodes=0;
133     dim_t numElements=0;
134     dim_t numFaceElements=0;
135     dim_t numContactElements=0;
136     dim_t numPoints=0;
137     index_t maxNodeID=0;
138     index_t maxDOF=0;
139     index_t maxElementID=0;
140     index_t maxElementID2=0;
141 jgs 82
142     for (i=0;i<numMsh;i++) {
143    
144     Finley_NodeFile_copyTable(numNodes,out->Nodes,maxNodeID,maxDOF,msh[i]->Nodes);
145     Finley_ElementFile_copyTable(numElements,out->Elements,numNodes,maxElementID,msh[i]->Elements);
146     Finley_ElementFile_copyTable(numFaceElements,out->FaceElements,numNodes,maxElementID,msh[i]->FaceElements);
147     Finley_ElementFile_copyTable(numContactElements,out->ContactElements,numNodes,maxElementID,msh[i]->ContactElements);
148     Finley_ElementFile_copyTable(numPoints,out->Points,numNodes,maxElementID,msh[i]->Points);
149    
150     numNodes=+msh[i]->Nodes->numNodes;
151     numElements=+msh[i]->Elements->numElements;
152     numFaceElements=+msh[i]->FaceElements->numElements;
153     numContactElements=+msh[i]->ContactElements->numElements;
154     numPoints=+msh[i]->Points->numElements;
155    
156     if (msh[i]->Nodes->numNodes>0)
157     maxNodeID+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->Id)+1;
158     maxDOF+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->degreeOfFreedom)+1;
159     maxElementID2=0;
160     if (msh[i]->Elements->numElements>0)
161     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Elements->numElements,msh[i]->Elements->Id));
162     if (msh[i]->FaceElements->numElements>0)
163     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->FaceElements->numElements,msh[i]->FaceElements->Id));
164     if (msh[i]->ContactElements->numElements>0)
165     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->ContactElements->numElements,msh[i]->ContactElements->Id));
166     if (msh[i]->Points->numElements)
167     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Points->numElements,msh[i]->Points->Id));
168     maxElementID+=maxElementID2+1;
169     }
170     }
171     /* all done */
172    
173 jgs 150 if (! Finley_noError()) {
174 jgs 82 Finley_Mesh_dealloc(out);
175     } else {
176     Finley_Mesh_prepare(out);
177     #ifdef Finley_TRACE
178     printf("%d meshes merged.\n",numMsh);
179     #endif
180     }
181     }
182     return out;
183     }
184    
185     /*
186     * $Log$
187 jgs 150 * Revision 1.3 2005/09/15 03:44:22 jgs
188     * Merge of development branch dev-02 back to main trunk on 2005-09-15
189     *
190     * Revision 1.2.2.1 2005/09/07 06:26:19 gross
191     * the solver from finley are put into the standalone package paso now
192     *
193 jgs 123 * Revision 1.2 2005/07/08 04:07:53 jgs
194     * Merge of development branch back to main trunk on 2005-07-08
195 jgs 82 *
196 jgs 123 * Revision 1.1.1.1.2.1 2005/06/29 02:34:52 gross
197     * some changes towards 64 integers in finley
198     *
199     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
200     * initial import of project esys2
201     *
202 jgs 82 * Revision 1.2 2004/07/30 04:37:06 gross
203     * escript and finley are linking now and RecMeshTest.py has been passed
204     *
205     * Revision 1.1.1.1 2004/06/24 04:00:40 johng
206     * Initial version of eys using boost-python.
207     *
208     *
209     */
210    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26