Gambit 2.1 and 2.2: How to import PLOT3D meshes


PLOT3D is a common mesh format typically coming from Overflow. It is a blockstructured format. In many cases Gambit is unable to import PLOT3D files due to formatting issues. The first step in order to solve this problem is to request the file in ascii, enabling to look at the formatting and see potential problems.

The required PLOT3D format for Gambit is:

1
89 257 1
4.914406e+02 4.912640e+02 4.910876e+02
4.909113e+02 4.907353e+02 4.905594e+02
. . .
. . .

where the first line is number of blocks (here 1), the second line is number of cells in x y z direction. Finally, ALL x coordinates are written followed by a block of ALL y and z coordinates.

In many cases the PLOT3D format that comes from Overflow looks like this:

1
89 257 1
.4914406E+03 .4912640E+03 .4910876E+03 .4909113E+03 .4907353E+03
.4905594E+03 .4903838E+03 .4902083E+03 .4900331E+03 .4898582E+03
. . . . .
. . . . .

Here 5 values per line are written (x1 x2 x3 x4 x5 etc). Often, more or less numbers per line are written. However, Gambit only works with 3 values per line and the file needs to be reformatted.
The following little c program does the reformatting of the example above. It is straightforward to modify for different formatting problems. It does not recognize EOF and thus

float data(xxxx) and
for(i=0; i<xxxx; i=i+x)

have to be adjusted for each case to reflect the number of values in the file and the number of values per line.



#include<stdio.h>

void main()
{
int l1, l2[3], i;
float data[100010];
FILE *fp;
printf("format n");

fp = fopen("wall.fplot3d_multblock","r");
printf("here n");
fscanf(fp,"%dn",&l1);
fscanf(fp,"%d %d %dn",&l2[0],&l2[1],&l2[2]);
for(i=0; i<68619; i=i+5)
{
fscanf(fp,"%f %f %f %f %fn",&data[i],&data[i+1],&data[i+2],&data[i+3],&data[i+4]);
}
fclose(fp);


fp = fopen("test.unf","w");
fprintf(fp,"%dn",l1);
fprintf(fp,"%d %d %dn",l2[0],l2[1],l2[2]);
for(i=0; i<68619; i=i+3)
{
fprintf(fp,"%14.6e %14.6e %14.6en",data[i],data[i+1],data[i+2]);
}
fclose(fp);


printf("%dn",l1);
printf("%d %d %dn",l2[0],l2[1],l2[2]);
for(i=0; i<68619; i=i+3)
{
printf("%14.6e %14.6e %14.6en",data[i],data[i+1],data[i+2]);
}
}





Show Form
No comments yet. Be the first to add a comment!