How can I plot the exported ASCII file from fluent?

Hello,
I have exported the data (ASCII) of a plane from fluent. I want plot the data in MATLAB. It would be great if you can give an idea or share any code to do that.
In that file the data are as following:
nodenumber, x-coordinate, y-coordinate, z-coordinate, phase-2-vof
1, 2.549813583E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
2, 2.569617473E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
3, 2.609225254E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
4, 2.648833034E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
5, 2.688440814E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
6, 2.728048594E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
7, 2.767656374E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
8, 2.807264154E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00
9, 2.846871934E+00, 3.150000000E+00,-2.192098192E-08, 0.000000000E+00

 Accepted Answer

The code below simply ignores the z-values, since there only seems to be a single line in the yz plane that was actually considered.
data = readtable('vof_data2.txt');
x = data.x_coordinate;
y = data.y_coordinate;
z = data.z_coordinate;
p2v = data.phase_2_vof;
resolution=[300 300];
figure(1),clf(1)
subplot(1,2,1)
plot3(x,y,p2v,'.')
xlabel('x')
ylabel('y')
zlabel('phase value')
v=[];[v(1),v(2)]=view(180,90);
title('point cloud')
axis tight
axlim=axis;
%ignore z for now
F=scatteredInterpolant(x,y,p2v,'linear','none');
[X,Y]=ndgrid(linspace(min(x),max(x),resolution(1)),linspace(min(y),max(y),resolution(2)));
Z=F(X,Y);
subplot(1,2,2)
surf(X,Y,Z,'EdgeColor','none')
view(v(1),v(2))
axis(axlim)

6 Comments

mathru
mathru on 12 Jun 2020
Edited: mathru on 13 Jun 2020
Much appreciated ! Thank you so much Rik.
I have same problem with this, but i wanted to plot it in 4D. Is it possible?
You were you planning to display the 4th dimension?
Yes. x-coordinate, y-coordinate, z-coordinate, and data that indicate the color. Really appreciated if it can be done using ASCII data as above.
It can probably be done. First you need to load the data, then transform it into a format a display function can understand. The answer above interpolates the data to a surface, but that might not be required for your application.
Please post a separate question, in which you attach an example file, give an outline of what you want to achieve, and show what you have tried so far. Feel free to post a link here.

Sign in to comment.

More Answers (1)

If this is stored in a .txt file, then you can use readtable like this
data = readtable('test.txt');
x = data.x_coordinate;
y = data.y_coordinate;
z = data.z_coordinate;
p2v = data.phase_2_vof;

12 Comments

mathru
mathru on 12 Jun 2020
Edited: mathru on 12 Jun 2020
Thank you for your answer.
Then, how can I plot the above mentioned data which have been extracted form the following image?
It is not clear how x, y, and z are used to make this graph. Is there any equation for this surface, or how is it related to x, y, and z.
This image have taken from 3D simulation (fluent). This image is the symmetry plane. When I have exported the vof data of this plane it provides the corresponding coordinates x, y and z.
Can you attach the complete data file?
How do you want to convert your 4D dataset to 2D+color?
I just want to draw the wavy shaped liquid surface as shown by the red color in the image.
That doesn't answer my question. You have x,y,z,p2v data. How should that be transformed to row,column,pixelcolor data?
As Rik mentioned, you need to show how the colors are related to x, y, and z values. Without that, the data does not make any sense.
mathru
mathru on 12 Jun 2020
Edited: mathru on 12 Jun 2020
I also don't know how can I do that. I have shared what data I have, how exported and what I want to plot. I am looking for sugestions/idea to do that.
How would you do it in words? What is the meaning of your image? What do the dimensions and the colors represent?
Well, actually I am simulating (3D model using Fluent) gas jet -liquid interaction in a vessel. The image represents the deformation of liquid upon impinging of gas jet. I have draw a plane (YZ plane) and the image representing the contour of phases on that plane. The red color indicates liquid part of the vessel where blue part is gas phase.

Sign in to comment.

Categories

Asked:

on 12 Jun 2020

Commented:

on 25 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!