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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26