<div>You have uniform grid size. So what about using the binary .vti file for instance as follow:</div>
<div> </div>
<div>I have number of grid points: nx,ny</div>
<div>Coordinates of origin: ox,oy</div>
<div>Grid spacing: dx, dy </div>
<div>Scalar variable: treal[nx*ny]</div>
<div> </div>
<div>nvar=1; /* Plot only one variable set */<br>off[0]=0;<br>for (i=0; i<nvar; i++){<br> bytes[i]=(nx*ny)*sizeof(float);<br> if(i<nvar-1)off[i+1]=off[i]+sizeof(int)+bytes[i];<br> bytes[i]=bytes[i]+sizeof(int);<br>
}</div>
<div> </div>
<div>outf_tfield=fopen("arrival_time_field.vti","w");<br> fprintf(outf_tfield,"<?xml version=\"1.0\"?>\n");<br> fprintf(outf_tfield,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n");<br>
fprintf(outf_tfield,"<ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%f %f %f\" Spacing=\"%f %f %f\">\n",0,nx-1,0,ny-1,0,0<br> ,ox,oy,0.<br> ,dx,dy,0.);<br> fprintf(outf_tfield,"<Piece Extent=\"%d %d %d %d %d %d\">\n",0,nx-1,0,ny-1,0,0);<br>
fprintf(outf_tfield,"<PointData Scalars=\"Arrival time (s)\">\n");<br> fprintf(outf_tfield,"<DataArray type=\"Float32\" Name=\"Arrival time (s)\" format=\"appended\" offset=\"%d\" />\n",off[0]); <br>
fprintf(outf_tfield,"</PointData>\n");<br> fprintf(outf_tfield,"<CellData>\n");<br> fprintf(outf_tfield,"</CellData>\n");<br> fprintf(outf_tfield,"</Piece>\n");<br>
fprintf(outf_tfield,"</ImageData>\n");<br> fprintf(outf_tfield,"<AppendedData encoding=\"raw\">\n");<br> fprintf(outf_tfield,"_");<br> /* Write arrival time field */<br>
fwrite(&bytes[0],sizeof(int),1,outf_tfield);<br> for(i=0; i<nx*ny; i++){<br> fwrite(&treal[i],sizeof(float),1,outf_tfield);<br> }<br> fprintf(outf_tfield,"\n");<br> fprintf(outf_tfield,"</AppendedData>\n");<br>
fprintf(outf_tfield,"</VTKFile>\n");<br> fclose(outf_tfield);</div>
<div> </div>
<div>Good luck!</div>
<div>Hom Nath</div>