/[escript]/trunk/finley/src/Mesh_write.cpp
ViewVC logotype

Annotation of /trunk/finley/src/Mesh_write.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3639 - (hide annotations)
Tue Oct 25 02:13:26 2011 UTC (7 years, 10 months ago) by caltinay
Original Path: trunk/finley/src/Mesh_write.c
File MIME type: text/plain
File size: 9911 byte(s)
Assorted spelling fixes in finley C.

1 jgs 150
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 caltinay 3639 /* Finley: write Mesh in finley file format */
18 jgs 82
19     /**************************************************************/
20    
21     #include "Mesh.h"
22    
23     /**************************************************************/
24    
25 caltinay 3639 /* writes the mesh to the external file fname using the Finley file format: */
26 jgs 82
27     void Finley_Mesh_write(Finley_Mesh *in,char* fname) {
28 jgs 150 char error_msg[LenErrorMsg_MAX];
29 jgs 82 FILE *f;
30     int NN,i,j,numDim;
31 gross 1044 Finley_TagMap* tag_map=in->TagMap;
32 jgs 82
33 ksteube 1312 if (in->MPIInfo->size >1 ) {
34     Finley_setError(IO_ERROR,"Mesh_write: only single processor runs are supported.");
35     return;
36    
37     }
38 jgs 82 /* open file */
39     f=fopen(fname,"w");
40     if (f==NULL) {
41 ksteube 1312 sprintf(error_msg,"Mesh_write: Opening file %s for writing failed.",fname);
42 jgs 150 Finley_setError(IO_ERROR,error_msg);
43 jgs 82 return;
44     }
45    
46     /* write header */
47    
48     fprintf(f,"%s\n",in->Name);
49    
50     /* write nodes: */
51    
52     if (in->Nodes!=NULL) {
53     numDim=Finley_Mesh_getDim(in);
54     fprintf(f,"%1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
55     for (i=0;i<in->Nodes->numNodes;i++) {
56 ksteube 1312 fprintf(f,"%d %d %d",in->Nodes->Id[i],in->Nodes->globalDegreesOfFreedom[i],in->Nodes->Tag[i]);
57 jgs 82 for (j=0;j<numDim;j++) fprintf(f," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
58     fprintf(f,"\n");
59     }
60     } else {
61     fprintf(f,"0D-Nodes 0\n");
62     }
63    
64     /* write elements: */
65    
66     if (in->Elements!=NULL) {
67 gross 2748 fprintf(f, "%s %d\n",in->Elements->referenceElementSet->referenceElement->Type->Name,in->Elements->numElements);
68     NN=in->Elements->numNodes;
69 jgs 82 for (i=0;i<in->Elements->numElements;i++) {
70     fprintf(f,"%d %d",in->Elements->Id[i],in->Elements->Tag[i]);
71     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
72     fprintf(f,"\n");
73     }
74     } else {
75     fprintf(f,"Tet4 0\n");
76     }
77    
78     /* write face elements: */
79     if (in->FaceElements!=NULL) {
80 gross 2748 fprintf(f, "%s %d\n", in->FaceElements->referenceElementSet->referenceElement->Type->Name,in->FaceElements->numElements);
81 ksteube 1312 NN=in->FaceElements->numNodes;
82 jgs 82 for (i=0;i<in->FaceElements->numElements;i++) {
83     fprintf(f,"%d %d",in->FaceElements->Id[i],in->FaceElements->Tag[i]);
84     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
85     fprintf(f,"\n");
86     }
87     } else {
88     fprintf(f,"Tri3 0\n");
89     }
90    
91     /* write Contact elements : */
92     if (in->ContactElements!=NULL) {
93 gross 2748 fprintf(f, "%s %d\n",in->ContactElements->referenceElementSet->referenceElement->Type->Name,in->ContactElements->numElements);
94 ksteube 1312 NN=in->ContactElements->numNodes;
95 jgs 82 for (i=0;i<in->ContactElements->numElements;i++) {
96     fprintf(f,"%d %d",in->ContactElements->Id[i],in->ContactElements->Tag[i]);
97     for (j=0;j<NN;j++) fprintf(f," %d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
98     fprintf(f,"\n");
99     }
100     } else {
101     fprintf(f,"Tri3_Contact 0\n");
102     }
103    
104     /* write points: */
105     if (in->Points!=NULL) {
106 gross 2748 fprintf(f, "%s %d\n",in->Points->referenceElementSet->referenceElement->Type->Name,in->Points->numElements);
107 jgs 82 for (i=0;i<in->Points->numElements;i++) {
108     fprintf(f,"%d %d %d\n",in->Points->Id[i],in->Points->Tag[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
109     }
110     } else {
111     fprintf(f,"Point1 0\n");
112     }
113 gross 1044
114     /* write tags:*/
115     if (tag_map) {
116     fprintf(f,"Tags\n");
117     while (tag_map) {
118     fprintf(f,"%s %d\n",tag_map->name,tag_map->tag_key);
119     tag_map=tag_map->next;
120     }
121     }
122 jgs 82 fclose(f);
123     #ifdef Finley_TRACE
124     printf("mesh %s has been written to file %s\n",in->Name,fname);
125     #endif
126     }
127    
128 ksteube 1339 void Finley_PrintMesh_Info(Finley_Mesh *in, bool_t full) {
129 ksteube 1326 int NN,i,j,numDim;
130     Finley_TagMap* tag_map=in->TagMap;
131    
132     fprintf(stdout, "Finley_PrintMesh_Info running on CPU %d of %d\n",in->MPIInfo->rank, in->MPIInfo->size);
133     fprintf(stdout, "\tMesh name '%s'\n",in->Name);
134 gross 2856 fprintf(stdout, "\tApproximation order %d\n",in->approximationOrder);
135     fprintf(stdout, "\tReduced Approximation order %d\n",in->reducedApproximationOrder);
136     fprintf(stdout, "\tIntegration order %d\n",in->integrationOrder);
137     fprintf(stdout, "\tReduced Integration order %d\n",in->reducedIntegrationOrder);
138 ksteube 1326
139     /* write nodes: */
140     if (in->Nodes!=NULL) {
141     numDim=Finley_Mesh_getDim(in);
142     fprintf(stdout, "\tNodes: %1dD-Nodes %d\n", numDim, in->Nodes->numNodes);
143 ksteube 1339 if (full) {
144 ksteube 1343 fprintf(stdout, "\t Id Tag gDOF gNI grDfI grNI: Coordinates\n");
145 ksteube 1339 for (i=0;i<in->Nodes->numNodes;i++) {
146     fprintf(stdout, "\t %5d %5d %5d %5d %5d %5d: ", in->Nodes->Id[i], in->Nodes->Tag[i], in->Nodes->globalDegreesOfFreedom[i], in->Nodes->globalNodesIndex[i], in->Nodes->globalReducedDOFIndex[i], in->Nodes->globalReducedNodesIndex[i]);
147     for (j=0;j<numDim;j++) fprintf(stdout," %20.15e",in->Nodes->Coordinates[INDEX2(j,i,numDim)]);
148     fprintf(stdout,"\n");
149     }
150 ksteube 1326 }
151     } else {
152     fprintf(stdout, "\tNodes: 0D-Nodes 0\n");
153     }
154    
155     /* write elements: */
156     if (in->Elements!=NULL) {
157 ksteube 1707 int mine=0, overlap=0;
158     for (i=0;i<in->Elements->numElements;i++) {
159     if (in->Elements->Owner[i] == in->MPIInfo->rank) mine++;
160     else overlap++;
161     }
162 gross 2748 fprintf(stdout, "\tElements: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->Elements->referenceElementSet->referenceElement->Type->Name,in->Elements->numElements,in->Elements->referenceElementSet->referenceElement->Type->TypeId, mine, overlap);
163 ksteube 1326 NN=in->Elements->numNodes;
164 ksteube 1339 if (full) {
165     fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
166     for (i=0;i<in->Elements->numElements;i++) {
167     fprintf(stdout, "\t %5d %5d %5d %5d: ",in->Elements->Id[i],in->Elements->Tag[i],in->Elements->Owner[i],in->Elements->Color[i]);
168     for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->Elements->Nodes[INDEX2(j,i,NN)]]);
169     fprintf(stdout,"\n");
170     }
171 ksteube 1326 }
172     } else {
173     fprintf(stdout, "\tElements: Tet4 0\n");
174     }
175    
176     /* write face elements: */
177     if (in->FaceElements!=NULL) {
178 ksteube 1744 int mine=0, overlap=0;
179     for (i=0;i<in->FaceElements->numElements;i++) {
180     if (in->FaceElements->Owner[i] == in->MPIInfo->rank) mine++;
181     else overlap++;
182     }
183 gross 2748 fprintf(stdout, "\tFace elements: %s %d (TypeId=%d) owner=%d overlap=%d\n", in->FaceElements->referenceElementSet->referenceElement->Type->Name,in->FaceElements->numElements,in->FaceElements->referenceElementSet->referenceElement->Type->TypeId, mine, overlap);
184 ksteube 1326 NN=in->FaceElements->numNodes;
185 ksteube 1339 if (full) {
186     fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
187     for (i=0;i<in->FaceElements->numElements;i++) {
188     fprintf(stdout, "\t %5d %5d %5d %5d: ",in->FaceElements->Id[i],in->FaceElements->Tag[i],in->FaceElements->Owner[i],in->FaceElements->Color[i]);
189     for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->FaceElements->Nodes[INDEX2(j,i,NN)]]);
190     fprintf(stdout,"\n");
191     }
192 ksteube 1326 }
193     } else {
194     fprintf(stdout, "\tFace elements: Tri3 0\n");
195     }
196    
197     /* write Contact elements : */
198     if (in->ContactElements!=NULL) {
199 ksteube 1744 int mine=0, overlap=0;
200     for (i=0;i<in->ContactElements->numElements;i++) {
201     if (in->ContactElements->Owner[i] == in->MPIInfo->rank) mine++;
202     else overlap++;
203     }
204 gross 2748 fprintf(stdout, "\tContact elements: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->ContactElements->referenceElementSet->referenceElement->Type->Name,in->ContactElements->numElements,in->ContactElements->referenceElementSet->referenceElement->Type->TypeId, mine, overlap);
205 ksteube 1326 NN=in->ContactElements->numNodes;
206 ksteube 1339 if (full) {
207     fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
208     for (i=0;i<in->ContactElements->numElements;i++) {
209     fprintf(stdout, "\t %5d %5d %5d %5d: ",in->ContactElements->Id[i],in->ContactElements->Tag[i],in->ContactElements->Owner[i],in->ContactElements->Color[i]);
210     for (j=0;j<NN;j++) fprintf(stdout," %5d",in->Nodes->Id[in->ContactElements->Nodes[INDEX2(j,i,NN)]]);
211     fprintf(stdout,"\n");
212     }
213 ksteube 1326 }
214     } else {
215 ksteube 1346 fprintf(stdout, "\tContact elements: Tri3_Contact 0\n");
216 ksteube 1326 }
217    
218     /* write points: */
219     if (in->Points!=NULL) {
220 ksteube 1744 int mine=0, overlap=0;
221     for (i=0;i<in->Points->numElements;i++) {
222     if (in->Points->Owner[i] == in->MPIInfo->rank) mine++;
223     else overlap++;
224     }
225 gross 2748 fprintf(stdout, "\tPoints: %s %d (TypeId=%d) owner=%d overlap=%d\n",in->Points->referenceElementSet->referenceElement->Type->Name,in->Points->numElements,in->Points->referenceElementSet->referenceElement->Type->TypeId, mine, overlap);
226 ksteube 1339 if (full) {
227     fprintf(stdout, "\t Id Tag Owner Color: Nodes\n");
228     for (i=0;i<in->Points->numElements;i++) {
229     fprintf(stdout, "\t %5d %5d %5d %5d %5d\n",in->Points->Id[i],in->Points->Tag[i],in->Points->Owner[i],in->Points->Color[i],in->Nodes->Id[in->Points->Nodes[INDEX2(0,i,1)]]);
230     }
231 ksteube 1326 }
232     } else {
233     fprintf(stdout, "\tPoints: Point1 0\n");
234     }
235    
236     /* write tags:*/
237     if (tag_map) {
238     fprintf(stdout, "\tTags:\n");
239     while (tag_map) {
240     fprintf(stdout, "\t %5d %s\n", tag_map->tag_key, tag_map->name);
241     tag_map=tag_map->next;
242     }
243     }
244     }
245    
246 jgs 82 /*
247     * $Log$
248 jgs 150 * Revision 1.2 2005/09/15 03:44:23 jgs
249     * Merge of development branch dev-02 back to main trunk on 2005-09-15
250 jgs 82 *
251 jgs 150 * Revision 1.1.1.1.6.1 2005/09/07 06:26:20 gross
252     * the solver from finley are put into the standalone package paso now
253     *
254     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
255     * initial import of project esys2
256     *
257 jgs 82 * Revision 1.1.1.1 2004/06/24 04:00:40 johng
258     * Initial version of eys using boost-python.
259     *
260     *
261     */
262    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26