CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Viewing the 3D plot in matlab

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 10, 2017, 07:37
Default Viewing the 3D plot in matlab
  #1
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Dear members

I am using an open source code COULWAVE to run the wave propagation in a wave flume around a conical island.

In the first case I used the Solitary wave and used the MATLAB code to get the 3D plot and it is shown below.

Fig 2.jpg

In the second case I used the Sinosidal wave for the same conical island as in the first cased and used the same MATLAB code to get the 3D plot but this time in the 3D plot the conical island is not distinctly visible. It is shown below.
Fig 1.jpg

I am unable to understand the reason for the same.

Please help me out.

your sincerely

Karan Gupta

The MATLAB code used for plotting is given below.

clear all
clf

load time.dat
nt=length(time);
if nt==0
nt=10000;
end

load s.dat

N_levels=s(2);
num_procs=s(3);


wave_map=zeros(63,3);
wave_map(1,=[0 0 .5625];
wave_map(64,=[1 1 1];

for i=2:63
for n=1:3
wave_map(i,n)=wave_map(1,n)+(i-1)*(wave_map(64,n)-wave_map(1,n))/63;
end
end

colormap(wave_map) % for blue / water-like surface
%colormap(jet)

for rank=0:num_procs-1
ind=['00' num2str(rank)];
file_ind=ind(length(ind)-2:length(ind));

eval(['load xloc' file_ind '.dat'])
eval(['load yloc' file_ind '.dat'])

filename=['dpth' file_ind '.dat'];
fid(5*rank+1)=fopen(filename, 'r');

filename=['zeta' file_ind '.dat'];
fid(5*rank+2)=fopen(filename, 'r'); % open the file

filename=['velo' file_ind '.dat'];
fid(5*rank+3)=fopen(filename, 'r'); % open the file

filename=['blvs' file_ind '.dat'];
fid(5*rank+4)=fopen(filename, 'r'); % open the file

filename=['vort' file_ind '.dat'];
fid(5*rank+5)=fopen(filename, 'r'); % open the file
end



% plot initial depth and determine glocal axis limits
clf
mx_x=0;
mn_x=1e6;
mx_y=0;
mn_y=1e6;

for rank=0:num_procs-1
ind=['00' num2str(rank)];
file_ind=ind(length(ind)-2:length(ind));

eval(['x=xloc' file_ind ';'])
eval(['y=yloc' file_ind ';'])

mx_x=max(mx_x,max(x));
mx_y=max(mx_y,max(y));

mn_x=min(mn_x,min(x));
mn_y=min(mn_y,min(y));

nx=length(x);
ny=length(y);

ho=zeros(nx,ny);

dum=fread(fid(5*rank+1),1,'int32');
ho(:,=fread(fid(5*rank+1),[nx,ny],'single');
dum=fread(fid(5*rank+1),1,'int32');

surf(x,y,transpose(ho(:,))
view(20,150)
shading flat

hold on
end
colorbar
pause(.1)

% plot various surfaces
% mov =
% avifile('example.avi','FPS',41,'COMPRESSION','Cine pak','Quality',100); %
% to create movie inside matlab (Doesnt work that well)
for n=1:nt
clf
[n,nt]
for rank=0:num_procs-1
ind=['00' num2str(rank)];
file_ind=ind(length(ind)-2:length(ind));

eval(['x=xloc' file_ind ';'])
eval(['y=yloc' file_ind ';'])

nx=length(x);
ny=length(y);

zeta=zeros(nx,ny,N_levels);
tmp=zeros(nx,ny);
bl_hor_wall=zeros(nx,ny);
t_break=zeros(nx,ny);
h=zeros(nx,ny);
u=zeros(nx,ny,N_levels);
v=zeros(nx,ny,N_levels);
vort=zeros(nx,ny,N_levels);
us=zeros(nx,ny,N_levels);
vs=zeros(nx,ny,N_levels);

for s=1:N_levels
dum=fread(fid(5*rank+3),1,'int32');
u(:,:,s)=fread(fid(5*rank+3),[nx,ny],'single'); % read x-velocity array, at z_alpha
v(:,:,s)=fread(fid(5*rank+3),[nx,ny],'single'); % read y-velocity array, at z_alpha
dum=fread(fid(5*rank+3),1,'int32');

dum=fread(fid(5*rank+2),1,'int32');
zeta(:,:,s)=fread(fid(5*rank+2),[nx,ny],'single'); % read free surface array
dum=fread(fid(5*rank+2),1,'int32');

dum=fread(fid(5*rank+5),1,'int32');
vort(:,:,s)=fread(fid(5*rank+5),[nx,ny],'single'); % read surface vorticity array
us(:,:,s)=fread(fid(5*rank+5),[nx,ny],'single'); % read x-velocity array, at zeta
vs(:,:,s)=fread(fid(5*rank+5),[nx,ny],'single'); % read y-velocity array, at zeta
dum=fread(fid(5*rank+5),1,'int32');
end


dum=fread(fid(5*rank+4),1,'int32');
bl_hor_wall=fread(fid(5*rank+4),[nx,ny],'int32'); % location of wet=0 and dry=99 cells
t_break=fread(fid(5*rank+4),[nx,ny],'single'); % breaking locations
h=fread(fid(5*rank+4),[nx,ny],'single'); % water depth, only different from h0 for landslide
dum=fread(fid(5*rank+4),1,'int32');

hold on

surf(x,y,transpose(-h+max(max(abs(ho)))/100.),'CData',zeros(ny,nx,3)+.4,'EdgeAlpha',0.0,'B ackFaceLighting','reverselit')
surf(x,y,transpose(zeta(:,:,1).*(1-bl_hor_wall/99)-(bl_hor_wall/99).*h));

end
shading flat
axis equal
% axis([10 45 mn_y mx_y -10 10])
xlabel('x (m)')
ylabel('y (m)')
% % title(['Free Surface Elevation, Time (sec) = ', num2str(time(n))])
view(20,150)
% % zoom(2.7)
caxis([-.05 .5])
light
% axis off


% fname=['im' num2str(10000+n)]
% print('-djpeg100 ',fname)
pause(0.1)
end


fclose all;
KaranG is offline   Reply With Quote

Old   April 10, 2017, 08:02
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,882
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
why don't you first fix the same ranges ans scales?
FMDenaro is offline   Reply With Quote

Old   April 10, 2017, 08:55
Default Reply
  #3
New Member
 
Karan Gupta
Join Date: Dec 2016
Location: IIT BOMBAY
Posts: 13
Rep Power: 9
KaranG is on a distinguished road
Since there is no change in the code. The scales are apparently the same in both the cases. I have attached the code. Can you specify in which part of the code, the changes are suggested?
KaranG is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Viewing a scatter plot of points overlayed on my paraFoam flow visualization karma15 ParaView 1 April 15, 2016 15:17
[swak4Foam] Foam warnings - related to swak4Foam Salam-H OpenFOAM Community Contributions 20 August 2, 2015 16:40
How to plot FLUENT contours on MATLAB Thiago Combustion FLUENT 1 October 10, 2013 15:13
Matlab PP: Generating X-vel Contour Error Plot Bennp2000 FLUENT 5 March 4, 2011 16:58
How to plot results in MATLAB risklotus Main CFD Forum 0 January 17, 2010 00:33


All times are GMT -4. The time now is 01:03.