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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26