CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   ...converting PLOT3D mesh files by NASA? (

AleDR May 5, 2011 09:44

...converting PLOT3D mesh files by NASA?
Hi FOAMers!

I have some problems with mesh file conversion!!
I'm trying to import NASA grid for the flat plate test case in OpenFOAM... but I don't know how to!!
I am puzzled by the file extension... .p3dmft ? It should be a PLOT3D file format, but I couldn't handle it in ParaView.

I tried the plot3dToFoam but I got this error:

Create time

Attempt to get back from bad stream

file: flatplate_clust2_4levelsdown_35x25.p3dmft at line 1.

From function void Istream::getBack(token&)
in file db/IOstreams/IOstreams/Istream.C at line 38.

FOAM exiting

Can anybody help me? :confused: Thanks!

kiddmax January 18, 2014 06:29

Hey Alessandro

Did you solve the problem?


VincentHUBER January 27, 2015 10:38

I'm highly interested in the issue ! Have you successfully converted the mesh ?

alexeym January 27, 2015 15:14


I was not successful in converting meshes with OpenFOAM's plot3dToFoam (and any way there is not much sense in converting just geometry), so I have created Python script for conversion from Plot3D to Gmsh ( then you can use gmshToFoam to convert mesh into OpenFOAM's format.

In general you will need geometry file (*.p3dfmt) and Neutral Map File with description of boundary conditions. I have tested the script on verification cases from, it seems to be converting the meshes and BCs correctly.

VincentHUBER January 27, 2015 17:31

Wonderfull ! (Actually, I was planning to get Gmsh mesh files :-) )

Bonus questioon
- do you know a way to get the 3D gmsh mesh in 2D (cut along a plane) ?
- can your script (that I ran successfully) be applied to p2dfmt ... without the neutral map file ?

alexeym January 28, 2015 04:22

No, I don't know the way to flatten mesh in Gmsh. In OpenFOAM there us flattenMesh utility, though its output is a point field, i.e. there will be no information about edges, boundaries, etc. Also there is Gmsh plugins like CutPlane, but again it will lose boundary information.

Initially I started with p2dfmt files but then realized there is no information on boundary conditions, so I've abandoned the idea.

makayasa April 27, 2016 14:33

error when run ./
hi alexym, after seraching how to convet plot3dtoFoam finally I find this forum. But i get error message when running sript How do fix this?

Can't open [-o. Skipping.
Can't open naca0012]. Skipping.
Can't open [-m. Skipping.
Can't open n0012]. Skipping.

alexeym April 29, 2016 04:34


Your output suggests that you have decided to copy command line with brackets (i.e. [-o naca0012] instead of just -o naca0012), while command should be something like:


./ -o naca0012.msh -m naca0012.nmf naca0012.p3d
This is just a guess and could be irrelevant, since your post lacks information on the way you have got the error.

makayasa April 29, 2016 11:22

Thanks for reply alexym.
After run command ./ -o naca0012.msh -m naca0012.nmf naca0012.p3d
I am get error message :

Traceback (most recent call last):
File "./", line 585, in <module>
File "./", line 577, in main
nmf = NeutralMapFile(mapfile)
File "./", line 90, in __init__
fp = open(filename, 'r')
TypeError: coercing to Unicode: need string or buffer, list found

even tried the files in the folder test, but I still get the same error message. How to fix this?
Thank you

alexeym April 29, 2016 12:33


There was a bug (guess I have never really tested -o and -m flags). I have pushed fix to repository, so you need to re-download script.

makayasa April 30, 2016 15:15

Its work
So, I went on the next stage of the run command gmshToFoam but I get the following message

#0 Foam::error::printStack(Foam::Ostream&) in "/home/xxx/OpenFOAM/OpenFOAM-1.7.1/lib/linuxGccDPOpt/"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/xxx/OpenFOAM/OpenFOAM-1.7.1/lib/linuxGccDPOpt/"
#2 Uninterpreted:
in "/home/xxx/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linuxGccDPOpt/gmshToFoam"
#4 __libc_start_main in "/lib/i386-linux-gnu/"
in "/home/xxx/OpenFOAM/OpenFOAM-1.7.1/applications/bin/linuxGccDPOpt/gmshToFoam"
Segmentation fault (core dumped)

Thank you

alexeym April 30, 2016 17:01

This time I can not guess what went wrong, since I have never used version 1.7.1 (well, except certain portions of foam-extent 3.1, which turned your to be OpenFOAM 1.7.x) and you did not show the way to reproduce your error.

makayasa May 1, 2016 02:21

The way that I use :
1.from ( i get file to convert msh file
2. I used a python script from ( ) to convert msh file
3. I moved the msh file to folder $ FOAM_RUN
4. then use the command gmshToFoam . And I got a message as I have mentioned
whether there are less of these steps ? please correction

alexeym May 1, 2016 05:51

I can not reproduce the error neither with OpenFOAM 2.4.x, nor with 3.0.x. So I guess, it is specific to 1.7.1 and I do not know how to fix it.

makayasa May 1, 2016 06:04

Thank you so much for your help. Maybe I 'll try openfoam 2.4.0

Flowkersma July 22, 2016 03:34


Just for record. I have successfully converted the meshes from NASA page with plot3dToFoam converter by adding -noBlank parameter. For example:

2D mesh

plot3dToFoam naca0012.p2dfmt -2D 1 -noBlank
3D mesh

plot3dToFoam naca0012.p3dfmt -noBlank
I had also problems on converting the p3d meshes created by Construct2D.
I solved it by adding a line with 1 in the beginning of the p3d file. For boundary conditions, I use autoPatch and createPatch utilities.


All times are GMT -4. The time now is 08:30.