/[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 2856 - (hide annotations)
Mon Jan 18 04:14:37 2010 UTC (10 years ago) by gross
File MIME type: text/plain
File size: 7938 byte(s)
FunctionSpaces provide now some information about their approximation order.
1 jgs 150
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 gross 2748 /* Finley: Mesh */
18 jgs 82
19 gross 2748 /* takes nodes elements, etc of in2 and copies them into in1 */
20     /* Ids of in2 are shifted by the maximum Id of in1 */
21 jgs 82
22     /**************************************************************/
23    
24     #include "Mesh.h"
25     #include "Util.h"
26    
27     /**************************************************************/
28    
29 gross 2748 /*static double Finley_Mesh_lockingGridSize=0;*/
30 jgs 82
31 jgs 123 Finley_Mesh* Finley_Mesh_merge(dim_t numMsh, Finley_Mesh** msh) {
32 ksteube 1312 Paso_MPIInfo *mpi_info=NULL;
33 gross 2748 Finley_ReferenceElementSet *refPoints=NULL, *refContactElements=NULL, *refFaceElements=NULL, *refElements=NULL;
34 jgs 82 Finley_Mesh* out=NULL;
35 gross 1028 dim_t numNodes=0;
36     dim_t numElements=0;
37     dim_t numFaceElements=0;
38     dim_t numContactElements=0;
39     dim_t numPoints=0;
40 jgs 123 dim_t i;
41 gross 1062 index_t order, reduced_order;
42 gross 1028 dim_t numDim;
43 gross 2748 ElementTypeId elementTypeId=NoRef ;
44     ElementTypeId faceElementTypeId=NoRef ;
45     ElementTypeId pointTypeId=NoRef ;
46     ElementTypeId contactTypeId=NoRef ;
47 gross 1028 index_t maxNodeID=0;
48     index_t maxDOF=0;
49     index_t maxElementID=0;
50     index_t maxElementID2=0;
51 jgs 82 char newName[LenString_MAX];
52     if (numMsh==0) {
53 gross 2748 Finley_setError(VALUE_ERROR,"Finley_Mesh_merge: Empty mesh list");
54 jgs 82 } else {
55 gross 2748 for (i=0;i<numMsh;i++) {
56     if (msh[i]->MPIInfo->size > 1) {
57     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: more than processor is not supported yet.");
58     return NULL;
59     }
60     }
61 gross 2856 order=msh[0]->integrationOrder;
62     reduced_order=msh[0]->reducedIntegrationOrder;
63 gross 2748 numDim=msh[0]->Nodes->numDim;
64     mpi_info=msh[0]->MPIInfo;
65     strcpy(newName,"");
66     for (i=0;i<numMsh;i++) {
67     /* check if all mesh have the same type and dimensions */
68 gross 2856 order=MAX(order,msh[i]->integrationOrder);
69     reduced_order=MIN(reduced_order,msh[i]->reducedIntegrationOrder);
70 gross 2748 numNodes+=msh[i]->Nodes->numNodes;
71     if (mpi_info->comm!=msh[i]->MPIInfo->comm) {
72     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: MPI communicators of meshes don't match.");
73     }
74     if (numDim!=msh[i]->Nodes->numDim) {
75     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: Spatial dimensions of meshes don't match.");
76     }
77 jgs 82
78 gross 2748 if (msh[i]->Elements!=NULL) {
79     numElements+=msh[i]->Elements->numElements;
80     if (elementTypeId==NoRef ) {
81     elementTypeId=msh[i]->Elements->referenceElementSet->referenceElement->Type->TypeId;
82     } else {
83     if (elementTypeId!=msh[i]->Elements->referenceElementSet->referenceElement->Type->TypeId ) {
84     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: element types of meshes don't match.");
85     }
86     }
87     }
88 jgs 82
89 gross 2748 if (msh[i]->FaceElements!=NULL) {
90     numFaceElements+=msh[i]->FaceElements->numElements;
91     if (faceElementTypeId==NoRef ) {
92     faceElementTypeId=msh[i]->FaceElements->referenceElementSet->referenceElement->Type->TypeId;
93     } else {
94     if (faceElementTypeId!=msh[i]->FaceElements->referenceElementSet->referenceElement->Type->TypeId ) {
95     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: face element types of meshes don't match.");
96     }
97     }
98     }
99 jgs 82
100 gross 2748 if (msh[i]->ContactElements!=NULL) {
101     numContactElements+=msh[i]->ContactElements->numElements;
102     if (contactTypeId==NoRef ) {
103     contactTypeId=msh[i]->ContactElements->referenceElementSet->referenceElement->Type->TypeId;
104     } else {
105     if (contactTypeId!=msh[i]->ContactElements->referenceElementSet->referenceElement->Type->TypeId ) {
106     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: contact element types of meshes don't match.");
107     }
108     }
109     }
110 jgs 82
111 gross 2748 if (msh[i]->Points!=NULL) {
112     numPoints+=msh[i]->Points->numElements;
113     if (pointTypeId==NoRef ) {
114     pointTypeId=msh[i]->Points->referenceElementSet->referenceElement->Type->TypeId;
115     } else {
116     if (pointTypeId!=msh[i]->Points->referenceElementSet->referenceElement->Type->TypeId ) {
117     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: point element types of meshes don't match.");
118     }
119     }
120     }
121 jgs 82
122 gross 2748 strncat(newName,"+",LenString_MAX-strlen(newName));
123     strncat(newName,msh[i]->Name,LenString_MAX-strlen(newName)-1);
124     }
125 jgs 82
126 gross 2748 if (mpi_info->size >1 ) {
127     Finley_setError(TYPE_ERROR,"Finley_Mesh_merge: only single processor runs are supported.");
128     }
129     /* allocate */
130 jgs 82
131 gross 2748 if (Finley_noError()) {
132 gross 2856 out=Finley_Mesh_alloc(newName,numDim,mpi_info);
133 jgs 82 }
134 gross 2748 if (Finley_noError()) {
135     refElements= Finley_ReferenceElementSet_alloc(elementTypeId,order,reduced_order);
136     refFaceElements=Finley_ReferenceElementSet_alloc(faceElementTypeId, order,reduced_order);
137     refContactElements=Finley_ReferenceElementSet_alloc(contactTypeId, order,reduced_order);
138     refPoints=Finley_ReferenceElementSet_alloc(pointTypeId, order,reduced_order);
139     }
140     if (Finley_noError()) {
141     out->Elements=Finley_ElementFile_alloc(refElements,mpi_info);
142     out->FaceElements=Finley_ElementFile_alloc(refFaceElements,mpi_info);
143     out->Points=Finley_ElementFile_alloc(refPoints,mpi_info);
144     out->ContactElements=Finley_ElementFile_alloc(refContactElements,mpi_info);
145 jgs 82
146 gross 2748 }
147     /* allocate new tables */
148     if (Finley_noError()) {
149     Finley_NodeFile_allocTable(out->Nodes,numNodes);
150     Finley_ElementFile_allocTable(out->Elements,numElements);
151     Finley_ElementFile_allocTable(out->FaceElements,numFaceElements);
152     Finley_ElementFile_allocTable(out->ContactElements,numContactElements);
153     Finley_ElementFile_allocTable(out->Points,numPoints);
154     }
155 jgs 82
156 gross 2748 /* copy tables :*/
157 jgs 82
158 gross 2748 if (Finley_noError()) {
159     numNodes=0;
160     numElements=0;
161     numFaceElements=0;
162     numContactElements=0;
163     numPoints=0;
164 jgs 82
165 gross 2748 for (i=0;i<numMsh;i++) {
166 jgs 82
167 gross 2748 Finley_NodeFile_copyTable(numNodes,out->Nodes,maxNodeID,maxDOF,msh[i]->Nodes);
168     Finley_ElementFile_copyTable(numElements,out->Elements,numNodes,maxElementID,msh[i]->Elements);
169     Finley_ElementFile_copyTable(numFaceElements,out->FaceElements,numNodes,maxElementID,msh[i]->FaceElements);
170     Finley_ElementFile_copyTable(numContactElements,out->ContactElements,numNodes,maxElementID,msh[i]->ContactElements);
171     Finley_ElementFile_copyTable(numPoints,out->Points,numNodes,maxElementID,msh[i]->Points);
172 jgs 82
173 gross 2748 numNodes=+msh[i]->Nodes->numNodes;
174     numElements=+msh[i]->Elements->numElements;
175     numFaceElements=+msh[i]->FaceElements->numElements;
176     numContactElements=+msh[i]->ContactElements->numElements;
177     numPoints=+msh[i]->Points->numElements;
178 jgs 82
179 gross 2748 if (msh[i]->Nodes->numNodes>0)
180     maxNodeID+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->Id)+1;
181     maxDOF+=Finley_Util_getMaxInt(1,msh[i]->Nodes->numNodes,msh[i]->Nodes->globalDegreesOfFreedom)+1;
182     maxElementID2=0;
183     if (msh[i]->Elements->numElements>0)
184     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Elements->numElements,msh[i]->Elements->Id));
185     if (msh[i]->FaceElements->numElements>0)
186     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->FaceElements->numElements,msh[i]->FaceElements->Id));
187     if (msh[i]->ContactElements->numElements>0)
188     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->ContactElements->numElements,msh[i]->ContactElements->Id));
189     if (msh[i]->Points->numElements)
190     maxElementID2=MAX(maxElementID2,Finley_Util_getMaxInt(1,msh[i]->Points->numElements,msh[i]->Points->Id));
191     maxElementID+=maxElementID2+1;
192     }
193     }
194     /* all done */
195     Finley_ReferenceElementSet_dealloc(refPoints);
196     Finley_ReferenceElementSet_dealloc(refContactElements);
197     Finley_ReferenceElementSet_dealloc(refFaceElements);
198     Finley_ReferenceElementSet_dealloc(refElements);
199     if (! Finley_noError()) {
200     Finley_Mesh_free(out);
201     } else {
202     Finley_Mesh_prepare(out, FALSE);
203     }
204 jgs 82 }
205     return out;
206     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26