/[escript]/branches/domexper/dudley/src/Mesh_saveVTK.c
ViewVC logotype

Annotation of /branches/domexper/dudley/src/Mesh_saveVTK.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (hide annotations)
Fri Aug 12 01:45:47 2005 UTC (13 years, 9 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Mesh_saveVTK.c
File MIME type: text/plain
File size: 21435 byte(s)
erge of development branch dev-02 back to main trunk on 2005-08-12

1 jgs 110 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* writes data and mesh in a vtk file */
6    
7     /**************************************************************/
8    
9     /* Copyrights by ACcESS, Australia 2004 */
10     /* Author: Paul Cochrane, cochrane@esscc.uq.edu.au */
11    
12     /**************************************************************/
13    
14     #include "Finley.h"
15     #include "Common.h"
16     #include "Mesh.h"
17     #include "escript/Data/DataC.h"
18 jgs 113 #include "vtkCellType.h" /* copied from vtk source directory !!! */
19 jgs 110
20     void Finley_Mesh_saveVTK(const char * filename_p, Finley_Mesh *mesh_p, escriptDataC* data_p) {
21     /* if there is no mesh we just return */
22     if (mesh_p==NULL) return;
23     Finley_ElementFile* elements=NULL;
24     char elemTypeStr[32];
25 jgs 123 int i, j, k, numVTKNodesPerElement, isCellCentered=FALSE, nodetype=FINLEY_DEGREES_OF_FREEDOM;
26 jgs 113 double* values, rtmp;
27 jgs 110 int nDim = mesh_p->Nodes->numDim;
28 jgs 113
29     /* get a pointer to the relevant mesh component */
30     if (isEmpty(data_p)) {
31     elements=mesh_p->Elements;
32     } else {
33     switch(getFunctionSpaceType(data_p)) {
34     case(FINLEY_DEGREES_OF_FREEDOM):
35     nodetype = FINLEY_DEGREES_OF_FREEDOM;
36     isCellCentered = FALSE;
37     elements = mesh_p->Elements;
38     break;
39     case(FINLEY_REDUCED_DEGREES_OF_FREEDOM):
40     Finley_ErrorCode=VALUE_ERROR;
41     sprintf(Finley_ErrorMsg,
42     "Reduced degrees of freedom is not yet "
43     "implemented for saving vtk files\n");
44     return;
45     case(FINLEY_NODES):
46     nodetype=FINLEY_NODES;
47     isCellCentered=FALSE;
48     elements=mesh_p->Elements;
49     break;
50     case(FINLEY_ELEMENTS):
51     isCellCentered=TRUE;
52     elements=mesh_p->Elements;
53     break;
54     case(FINLEY_FACE_ELEMENTS):
55     isCellCentered=TRUE;
56     elements=mesh_p->FaceElements;
57     break;
58     case(FINLEY_POINTS):
59     isCellCentered=TRUE;
60     elements=mesh_p->Points;
61     break;
62     case(FINLEY_CONTACT_ELEMENTS_1):
63     case(FINLEY_CONTACT_ELEMENTS_2):
64     isCellCentered=TRUE;
65     elements=mesh_p->ContactElements;
66     break;
67     default:
68     Finley_ErrorCode=TYPE_ERROR;
69     sprintf(Finley_ErrorMsg,
70     "Finley does not know anything about function space type %d",
71     getFunctionSpaceType(data_p));
72     return;
73     }
74     }
75    
76     /* the number of points */
77     int numPoints = mesh_p->Nodes->numNodes;
78    
79     /* the number of cells */
80     if (elements == NULL) {
81     Finley_ErrorCode = VALUE_ERROR;
82     sprintf(Finley_ErrorMsg,
83     "elements object is NULL; cannot proceed");
84     return;
85     }
86     int numCells = elements->numElements;
87    
88     /* open the file and check handle */
89 jgs 110 FILE * fileHandle_p = fopen(filename_p, "w");
90     if (fileHandle_p==NULL) {
91 jgs 113 Finley_ErrorCode=IO_ERROR;
92     sprintf(Finley_ErrorMsg,
93     "File %s could not be opened for writing.", filename_p);
94     return;
95 jgs 110 }
96     /* xml header */
97     fprintf(fileHandle_p, "<?xml version=\"1.0\"?>\n");
98     fprintf(fileHandle_p,
99     "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\">\n");
100    
101     /* finley uses an unstructured mesh, so UnstructuredGrid *should* work */
102     fprintf(fileHandle_p, "<UnstructuredGrid>\n");
103    
104     /* is there only one "piece" to the data?? */
105 jgs 113 fprintf(fileHandle_p, "<Piece "
106     "NumberOfPoints=\"%d\" "
107     "NumberOfCells=\"%d\">\n",
108     numPoints, numCells);
109 jgs 110
110 jgs 113 /* now for the points; equivalent to positions section in saveDX() */
111     /* "The points element explicitly defines coordinates for each point
112     * individually. It contains one DataArray element describing an array
113     * with three components per value, each specifying the coordinates of one
114     * point" - from Vtk User's Guide
115     */
116 jgs 110 fprintf(fileHandle_p, "<Points>\n");
117 jgs 113 /*
118     * the reason for this if statement is explained in the long comment below
119     */
120     if (nDim < 3) {
121     fprintf(fileHandle_p, "<DataArray "
122     "NumberOfComponents=\"3\" "
123     "type=\"Float32\" "
124     "format=\"ascii\">\n");
125     } else {
126     fprintf(fileHandle_p, "<DataArray "
127     "NumberOfComponents=\"%d\" "
128     "type=\"Float32\" "
129     "format=\"ascii\">\n",
130     nDim);
131     }
132     for (i = 0; i < mesh_p->Nodes->numNodes; i++) {
133     fprintf(fileHandle_p,
134     "%e", mesh_p->Nodes->Coordinates[INDEX2(0, i, nDim)]);
135     for (j = 1; j < nDim; j++) {
136     fprintf(fileHandle_p,
137     " %f",mesh_p->Nodes->Coordinates[INDEX2(j, i, nDim)]);
138     /* vtk/mayavi doesn't like 2D data, it likes 3D data with a degenerate
139     * third dimension to handle 2D data (like a sheet of paper). So, if
140     * nDim is 2, we have to append zeros to the array to get this third
141     * dimension, and keep the visualisers happy.
142     * Indeed, if nDim is less than 3, must pad all empty dimensions, so
143     * that the total number of dims is 3.
144     */
145     if (nDim < 3) {
146     for (k=0; k<3-nDim; k++) {
147     fprintf(fileHandle_p, " 0");
148     }
149     }
150     }
151     fprintf(fileHandle_p, "\n");
152     }
153 jgs 110 fprintf(fileHandle_p, "</DataArray>\n");
154     fprintf(fileHandle_p, "</Points>\n");
155    
156 jgs 113 /* connections */
157 jgs 110 /* now for the cells */
158 jgs 113 /* "The Cells element defines cells explicitly by specifying point
159     * connectivity and cell types. It contains three DataArray elements. The
160     * first array specifies the point connectivity. All cells' point lists
161     * are concatenated together. The second array specifies th eoffset into
162     * the connectivity array for the end of each cell. The third array
163     * specifies the type of each cell.
164     */
165     /* if no element table is present jump over the connection table */
166     int cellType;
167     if (elements!=NULL) {
168     fprintf(fileHandle_p, "<Cells>\n");
169     ElementTypeId TypeId = elements->ReferenceElement->Type->TypeId;
170     switch(TypeId) {
171     case Point1:
172     cellType = VTK_VERTEX;
173     break;
174     case Line2:
175     cellType = VTK_LINE;
176     break;
177     case Line3:
178     cellType = VTK_QUADRATIC_EDGE;
179     break;
180     case Tri3:
181     cellType = VTK_TRIANGLE;
182     break;
183     case Tri6:
184     cellType = VTK_QUADRATIC_TRIANGLE;
185     break;
186     case Rec4:
187     cellType = VTK_QUAD;
188     break;
189     case Rec8:
190     cellType = VTK_QUADRATIC_QUAD;
191     break;
192     case Tet4:
193     cellType = VTK_TETRA;
194     break;
195     case Tet10:
196     cellType = VTK_QUADRATIC_TETRA;
197     break;
198     case Hex8:
199     cellType = VTK_HEXAHEDRON;
200     break;
201     case Hex20:
202     cellType = VTK_QUADRATIC_HEXAHEDRON;
203     break;
204     case Line2Face:
205     cellType = VTK_VERTEX;
206     break;
207     case Line3Face:
208     cellType = VTK_VERTEX;
209     break;
210     case Tri3Face:
211     cellType = VTK_LINE;
212     break;
213     case Tri6Face:
214     cellType = VTK_QUADRATIC_EDGE;
215     break;
216     case Rec4Face:
217     cellType = VTK_LINE;
218     break;
219     case Rec8Face:
220     cellType = VTK_QUADRATIC_EDGE;
221     break;
222     case Tet4Face:
223     cellType = VTK_TRIANGLE;
224     break;
225     case Tet10Face:
226     cellType = VTK_QUADRATIC_TRIANGLE;
227     break;
228     case Hex8Face:
229     cellType = VTK_QUADRATIC_QUAD;
230     break;
231     case Hex20Face:
232     cellType = VTK_QUADRATIC_QUAD;
233     break;
234     case Point1_Contact:
235     cellType = VTK_VERTEX;
236     break;
237     case Line2_Contact:
238     cellType = VTK_LINE;
239     break;
240     case Line3_Contact:
241     cellType = VTK_QUADRATIC_EDGE;
242     break;
243     case Tri3_Contact:
244     cellType = VTK_TRIANGLE;
245     break;
246     case Tri6_Contact:
247     cellType = VTK_QUADRATIC_TRIANGLE;
248     break;
249     case Rec4_Contact:
250     cellType = VTK_QUAD;
251     break;
252     case Rec8_Contact:
253     cellType = VTK_QUADRATIC_QUAD;
254     break;
255     case Line2Face_Contact:
256     cellType = VTK_VERTEX;
257     break;
258     case Line3Face_Contact:
259     cellType = VTK_VERTEX;
260     break;
261     case Tri3Face_Contact:
262     cellType = VTK_LINE;
263     break;
264     case Tri6Face_Contact:
265     cellType = VTK_QUADRATIC_EDGE;
266     break;
267     case Rec4Face_Contact:
268     cellType = VTK_LINE;
269     break;
270     case Rec8Face_Contact:
271     cellType = VTK_QUADRATIC_EDGE;
272     break;
273     case Tet4Face_Contact:
274     cellType = VTK_TRIANGLE;
275     break;
276     case Tet10Face_Contact:
277     cellType = VTK_QUADRATIC_TRIANGLE;
278     break;
279     case Hex8Face_Contact:
280     cellType = VTK_QUAD;
281     break;
282     case Hex20Face_Contact:
283     cellType = VTK_QUADRATIC_QUAD;
284     break;
285     default:
286     Finley_ErrorCode=VALUE_ERROR;
287     sprintf(Finley_ErrorMsg,
288     "Element type %s is not supported by VTK",
289     elements->ReferenceElement->Type->Name);
290     return;
291     }
292 jgs 110
293 jgs 113 switch(cellType) {
294     case VTK_VERTEX:
295     numVTKNodesPerElement = 1;
296     strcpy(elemTypeStr, "VTK_VERTEX");
297     break;
298     case VTK_LINE:
299     numVTKNodesPerElement = 2;
300     strcpy(elemTypeStr, "VTK_LINE");
301     break;
302     case VTK_TRIANGLE:
303     numVTKNodesPerElement = 3;
304     strcpy(elemTypeStr, "VTK_TRIANGLE");
305     break;
306     case VTK_QUAD:
307     numVTKNodesPerElement = 4;
308     strcpy(elemTypeStr, "VTK_QUAD");
309     break;
310     case VTK_TETRA:
311     numVTKNodesPerElement = 4;
312     strcpy(elemTypeStr, "VTK_TETRA");
313     break;
314     case VTK_HEXAHEDRON:
315     numVTKNodesPerElement = 8;
316     strcpy(elemTypeStr, "VTK_HEXAHEDRON");
317     break;
318     case VTK_QUADRATIC_EDGE:
319     numVTKNodesPerElement = 3;
320     strcpy(elemTypeStr, "VTK_QUADRATIC_EDGE");
321     break;
322     case VTK_QUADRATIC_TRIANGLE:
323     numVTKNodesPerElement = 6;
324     strcpy(elemTypeStr, "VTK_QUADRATIC_TRIANGLE");
325     break;
326     case VTK_QUADRATIC_QUAD:
327     numVTKNodesPerElement = 8;
328     strcpy(elemTypeStr, "VTK_QUADRATIC_QUAD");
329     break;
330     case VTK_QUADRATIC_TETRA:
331     numVTKNodesPerElement = 10;
332     strcpy(elemTypeStr, "VTK_QUADRATIC_TETRA");
333     break;
334     case VTK_QUADRATIC_HEXAHEDRON:
335     numVTKNodesPerElement = 20;
336     strcpy(elemTypeStr, "VTK_QUADRATIC_HEXAHEDRON");
337     break;
338     default:
339     Finley_ErrorCode = VALUE_ERROR;
340     sprintf(Finley_ErrorMsg,
341     "Cell type %d is not supported by VTK", cellType);
342     return;
343     }
344 jgs 110
345 jgs 113 /* write out the DataArray element for the connectivity */
346     fprintf(fileHandle_p, "<DataArray "
347     "Name=\"connectivity\" "
348     "type=\"Int32\" "
349     "format=\"ascii\">\n");
350     int NN = elements->ReferenceElement->Type->numNodes;
351 jgs 147 if (VTK_QUADRATIC_HEXAHEDRON==cellType) {
352     for (i = 0; i < numCells; i++) {
353     fprintf(fileHandle_p,"%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
354     mesh_p->Elements->Nodes[INDEX2(0, i, NN)],
355     mesh_p->Elements->Nodes[INDEX2(1, i, NN)],
356     mesh_p->Elements->Nodes[INDEX2(2, i, NN)],
357     mesh_p->Elements->Nodes[INDEX2(3, i, NN)],
358     mesh_p->Elements->Nodes[INDEX2(4, i, NN)],
359     mesh_p->Elements->Nodes[INDEX2(5, i, NN)],
360     mesh_p->Elements->Nodes[INDEX2(6, i, NN)],
361     mesh_p->Elements->Nodes[INDEX2(7, i, NN)],
362     mesh_p->Elements->Nodes[INDEX2(8, i, NN)],
363     mesh_p->Elements->Nodes[INDEX2(9, i, NN)],
364     mesh_p->Elements->Nodes[INDEX2(10, i, NN)],
365     mesh_p->Elements->Nodes[INDEX2(11, i, NN)],
366     mesh_p->Elements->Nodes[INDEX2(16, i, NN)],
367     mesh_p->Elements->Nodes[INDEX2(17, i, NN)],
368     mesh_p->Elements->Nodes[INDEX2(18, i, NN)],
369     mesh_p->Elements->Nodes[INDEX2(19, i, NN)],
370     mesh_p->Elements->Nodes[INDEX2(12, i, NN)],
371     mesh_p->Elements->Nodes[INDEX2(13, i, NN)],
372     mesh_p->Elements->Nodes[INDEX2(14, i, NN)],
373     mesh_p->Elements->Nodes[INDEX2(15, i, NN)]);
374     fprintf(fileHandle_p, "\n");
375     }
376     } else {
377     for (i = 0; i < numCells; i++) {
378     for (j = 0; j < numVTKNodesPerElement; j++) fprintf(fileHandle_p,"%d ", mesh_p->Elements->Nodes[INDEX2(j, i, NN)]);
379     fprintf(fileHandle_p, "\n");
380     }
381 jgs 113 }
382     fprintf(fileHandle_p, "\n");
383     fprintf(fileHandle_p, "</DataArray>\n");
384    
385     /* write out the DataArray element for the offsets */
386     fprintf(fileHandle_p, "<DataArray "
387     "Name=\"offsets\" "
388     "type=\"Int32\" "
389     "format=\"ascii\">\n");
390 jgs 147 int counter = 0; /* counter for the number of offsets written to file */
391 jgs 113 for (i=numVTKNodesPerElement; i<=numCells*numVTKNodesPerElement; i+=numVTKNodesPerElement) {
392     fprintf(fileHandle_p, "%d ", i);
393 jgs 121 counter++;
394     /* if the counter gets too big (i.e. the line gets too long),
395     * then add a newline and reset */
396     if (counter > 19) {
397     counter = 0;
398     fprintf(fileHandle_p, "\n");
399     }
400 jgs 110 }
401 jgs 113 fprintf(fileHandle_p, "\n");
402     fprintf(fileHandle_p, "</DataArray>\n");
403    
404     /* write out the DataArray element for the types */
405 jgs 121 counter = 0; /* counter for the number of types written to file */
406 jgs 113 fprintf(fileHandle_p, "<DataArray "
407     "Name=\"types\" "
408     "type=\"UInt8\" "
409     "format=\"ascii\">\n");
410     for (i=0; i<numCells; i++) {
411     fprintf(fileHandle_p, "%d ", cellType);
412 jgs 121 counter++;
413     /* if the counter gets too big (i.e. the line gets too long),
414     * then add a newline and reset */
415     if (counter > 30) {
416     counter = 0;
417     fprintf(fileHandle_p, "\n");
418     }
419 jgs 113 }
420     fprintf(fileHandle_p, "\n");
421     fprintf(fileHandle_p, "</DataArray>\n");
422    
423     /* finish off the <Cells> element */
424     fprintf(fileHandle_p, "</Cells>\n");
425 jgs 110 }
426    
427     /* data */
428     if (!isEmpty(data_p)) {
429 jgs 113 int rank = getDataPointRank(data_p);
430     int nComp = getDataPointSize(data_p);
431     /* barf if rank is greater than two */
432     if (rank > 2) {
433     Finley_ErrorCode = VALUE_ERROR;
434     sprintf(Finley_ErrorMsg,
435     "Vtk can't handle objects with rank greater than 2\n"
436     "object rank = %d\n", rank);
437     return;
438     }
439     /* if the rank == 0: --> scalar data
440     * if the rank == 1: --> vector data
441     * if the rank == 2: --> tensor data
442     */
443     char dataNameStr[31], dataTypeStr[63];
444 jgs 123 int nCompReqd=1; /* the number of components required by vtk */
445 jgs 113 if (rank == 0) {
446     strcpy(dataNameStr, "escript_scalar_data");
447     sprintf(dataTypeStr, "Scalars=\"%s\"", dataNameStr);
448     nCompReqd = 1;
449     }
450     else if (rank == 1) {
451     strcpy(dataNameStr, "escript_vector_data");
452     sprintf(dataTypeStr, "Vectors=\"%s\"", dataNameStr);
453     nCompReqd = 3;
454     }
455     else if (rank == 2) {
456     strcpy(dataNameStr, "escript_tensor_data");
457     sprintf(dataTypeStr, "Tensors=\"%s\"", dataNameStr);
458     nCompReqd = 9;
459     }
460     /* if have cell centred data then use CellData element,
461     * if have node centred data, then use PointData element
462     */
463     if (isCellCentered) {
464     /* now for the cell data */
465     fprintf(fileHandle_p, "<CellData %s>\n", dataTypeStr);
466     fprintf(fileHandle_p,
467     "<DataArray "
468     "Name=\"%s\" "
469     "type=\"Float32\" "
470     "NumberOfComponents=\"%d\" "
471     "format=\"ascii\">\n",
472     dataNameStr, nCompReqd);
473     int numPointsPerSample = elements->ReferenceElement->numQuadNodes;
474     if (numPointsPerSample) {
475     for (i=0; i<numCells; i++) {
476     values = getSampleData(data_p, i);
477     double sampleAvg[nComp];
478     for (k=0; k<nComp; k++) {
479     /* averaging over the number of points in the sample */
480     rtmp = 0.;
481     for (j=0; j<numPointsPerSample; j++) {
482     rtmp += values[INDEX2(k,j,nComp)];
483     }
484     sampleAvg[k] = rtmp/numPointsPerSample;
485     }
486     /* if the number of required components is more than the number
487     * of actual components, pad with zeros
488     */
489     /* probably only need to get shape of first element */
490     int shape = getDataPointShape(data_p, 0);
491     if (shape > 3) {
492     Finley_ErrorCode = VALUE_ERROR;
493     sprintf(Finley_ErrorMsg,
494     "shape should be 1, 2, or 3; I got %d\n", shape);
495     return;
496     }
497     /* write the data different ways for scalar, vector and tensor */
498     if (nCompReqd == 1) {
499     fprintf(fileHandle_p, " %f", sampleAvg[0]);
500     }
501     else if (nCompReqd == 3) {
502     int shape = getDataPointShape(data_p, 0);
503     /* write out the data */
504     for (int m=0; m<shape; m++) {
505     fprintf(fileHandle_p, " %f", sampleAvg[m]);
506     }
507     /* pad with zeros */
508     for (int m=0; m<nCompReqd-shape; m++) {
509     fprintf(fileHandle_p, " 0");
510     }
511     }
512     else if (nCompReqd == 9) {
513     /* tensor data, so have a 3x3 matrix to output as a row
514     * of 9 data points */
515     int count = 0;
516     int elems = 0;
517     for (int m=0; m<shape; m++) {
518     for (int n=0; n<shape; n++) {
519     fprintf(fileHandle_p, " %f", sampleAvg[count]);
520     count++;
521     elems++;
522     }
523     for (int n=0; n<3-shape; n++) {
524     fprintf(fileHandle_p, " 0");
525     elems++;
526     }
527     }
528     for (int m=0; m<nCompReqd-elems; m++) {
529     fprintf(fileHandle_p, " 0");
530     }
531     }
532     fprintf(fileHandle_p, "\n");
533     }
534 jgs 110 }
535 jgs 113 fprintf(fileHandle_p, "</DataArray>\n");
536     fprintf(fileHandle_p, "</CellData>\n");
537     } else {
538     /* now for the point data */
539     fprintf(fileHandle_p, "<PointData %s>\n", dataTypeStr);
540     fprintf(fileHandle_p, "<DataArray "
541     "Name=\"%s\" "
542     "type=\"Float32\" "
543     "NumberOfComponents=\"%d\" "
544     "format=\"ascii\">\n",
545 jgs 121 dataNameStr, nCompReqd);
546 jgs 113 for (i=0; i<mesh_p->Nodes->numNodes; i++) {
547     switch (nodetype) {
548     case(FINLEY_DEGREES_OF_FREEDOM):
549     values = getSampleData(data_p,
550     mesh_p->Nodes->degreeOfFreedom[i]);
551     break;
552     case(FINLEY_REDUCED_DEGREES_OF_FREEDOM):
553     if (mesh_p->Nodes->toReduced[i]>=0) {
554     values = getSampleData(data_p,
555     mesh_p->Nodes->reducedDegreeOfFreedom[i]);
556     }
557     break;
558     case(FINLEY_NODES):
559     values = getSampleData(data_p,i);
560     break;
561     }
562     /* write out the data */
563     /* if the number of required components is more than the number
564     * of actual components, pad with zeros
565     */
566     /* probably only need to get shape of first element */
567     int shape = getDataPointShape(data_p, 0);
568     if (shape > 3) {
569     Finley_ErrorCode = VALUE_ERROR;
570     sprintf(Finley_ErrorMsg,
571     "shape should be 1, 2, or 3; I got %d\n", shape);
572     return;
573     }
574     /* write the data different ways for scalar, vector and tensor */
575     if (nCompReqd == 1) {
576     fprintf(fileHandle_p, " %f", values[0]);
577     }
578     else if (nCompReqd == 3) {
579     int shape = getDataPointShape(data_p, 0);
580     /* write out the data */
581     for (int m=0; m<shape; m++) {
582     fprintf(fileHandle_p, " %f", values[m]);
583     }
584     /* pad with zeros */
585     for (int m=0; m<nCompReqd-shape; m++) {
586     fprintf(fileHandle_p, " 0");
587     }
588     }
589     else if (nCompReqd == 9) {
590     /* tensor data, so have a 3x3 matrix to output as a row
591     * of 9 data points */
592     int count = 0;
593     int elems = 0;
594     for (int m=0; m<shape; m++) {
595     for (int n=0; n<shape; n++) {
596     fprintf(fileHandle_p, " %f", values[count]);
597     count++;
598     elems++;
599     }
600     for (int n=0; n<3-shape; n++) {
601     fprintf(fileHandle_p, " 0");
602     elems++;
603     }
604     }
605     for (int m=0; m<nCompReqd-elems; m++) {
606     fprintf(fileHandle_p, " 0");
607     }
608     }
609     fprintf(fileHandle_p, "\n");
610 jgs 110 }
611 jgs 113 fprintf(fileHandle_p, "</DataArray>\n");
612     fprintf(fileHandle_p, "</PointData>\n");
613     }
614 jgs 110 }
615    
616 jgs 113 /* finish off the piece */
617     fprintf(fileHandle_p, "</Piece>\n");
618 jgs 110
619     fprintf(fileHandle_p, "</UnstructuredGrid>\n");
620     /* write the xml footer */
621     fprintf(fileHandle_p, "</VTKFile>\n");
622     /* close the file */
623     fclose(fileHandle_p);
624     return;
625     }
626 jgs 121
627     /*
628     * $Log$
629 jgs 147 * Revision 1.6 2005/08/12 01:45:43 jgs
630     * erge of development branch dev-02 back to main trunk on 2005-08-12
631     *
632     * Revision 1.5.2.1 2005/08/10 06:14:37 gross
633     * QUADRATIC HEXAHEDRON elements fixed
634     *
635 jgs 123 * Revision 1.5 2005/07/08 04:07:55 jgs
636     * Merge of development branch back to main trunk on 2005-07-08
637     *
638 jgs 121 * Revision 1.4 2005/05/06 04:26:15 jgs
639     * Merge of development branch back to main trunk on 2005-05-06
640     *
641 jgs 123 * Revision 1.1.2.7 2005/06/29 02:34:54 gross
642     * some changes towards 64 integers in finley
643     *
644 jgs 121 * Revision 1.1.2.6 2005/05/06 01:17:19 cochrane
645     * Fixed incorrect reporting of number of components in PointData arrays for
646     * vector data.
647     *
648     * Revision 1.1.2.5 2005/05/05 05:38:44 cochrane
649     * Improved formatting of VTK file output.
650     *
651     * Revision 1.1.2.4 2005/02/22 10:03:54 cochrane
652     * Implementation of writing of vtk xml files from finley. This function will
653     * require more testing, but on the cases that I have tried (and with the help
654     * of Lutz and mayavi), it looks like it's producing the correct output. Testing
655     * with more realistic data would be good. I'm at least confident enough to
656     * commit my changes.
657     *
658     * Revision 1.1.2.3 2005/02/17 05:53:26 gross
659     * some bug in saveDX fixed: in fact the bug was in
660     * DataC/getDataPointShape
661     *
662     * Revision 1.1.2.2 2005/02/10 01:34:22 cochrane
663     * Quick fix to make sure that saveVTK compiles so that finley is still buildable. Apologies to those this has affected.
664     *
665     * Revision 1.1.2.1 2005/02/09 06:53:15 cochrane
666     * Initial import to repository. This is the file to implement saving finley/escript meshes out to vtk formatted files. It is basically just a hack of the opendx equivalent, with a lot of the opendx stuff still in the file, so it doesn't actually work just yet, but it probably needs to be added to the cvs.
667     *
668     * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
669     * initial import of project esys2
670     *
671     * Revision 1.1 2004/07/27 08:27:11 gross
672     * Finley: saveDX added: now it is possible to write data on boundary and contact elements
673     *
674     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26