Outils pour utilisateurs

Outils du site


sunfluidh:sunfluidh_matlab

Ceci est une ancienne révision du document !


Reading output files with Matlab (examples)

Three different matlab functions can read sunfluidh output files. Download the files. Make sure the directory where you have untar these files is listed in the matlabpath. 1)

  1. read_sunfluidh_data reads res* or rst* files
  2. read_sunfluidh_probes reads all probes files *_ins_*
  3. read-sunfluidh-namelist reads check_namelist_data.dat

As for any matlab function, the documentation is built in. In the command window just type : help read_sunfluidh_data or doc read_sunfluidh_data.

Here, we assume you have already runned the case 2D laminar channel flow with a constriction. Make sure the current directory for matlab is also the directory where you have the output files.

Instantaneous (or statistical) fields

Visualisation of U velocity component.

f = read_sunfluidh_data(7) % read res_00000_0000007.d. If you omit (7), the function tries to read the last generated file.
pcolor(f.xu,f.yc,f.U') % Note the transpose ' for f.U
axis image
shading interp

Add a colorbar, labels and increase the font size.

colorbar
xlabel('x'); ylabel('y'), set(gca,'FontSize',16)

Add on the same figure the contour for the isovalue 0 for the U component. The isocontour is red with a thick line.

hold on
contour(f.xu,f.yc,f.U',[0 0],'r','linewidth',2)
hold off

Extract the profiles from the instantaneous field. For instance, the U profile as a function of x for the grid nodes 48 in the y direction.

plot(f.xu,f.U(:,48))

Add another profile for grid nodes 19, labels.

hold on
plot(f.xu,f.U(:,19))
hold off
xlabel('x'); ylabel('U(x)'), set(gca,'FontSize',18)
grid on

Add a legend retreiving the coordinates of the 19 and 48 grid nodes from f.yc.

legend(['y = ',num2str(f.yc(48))],['y = ',num2str(f.yc(19))] )

Plotting the profiles along the y direction is very similar. Here, the ghost cells are removed.

xind = 152; % pick an indice
plot(f.U(xind,2:end-1),f.yc(2:end-1))
xlabel('U(y)'),ylabel('y')

Retrieve from the namelists stored in check_namelist_data.dat the dynamic viscosity and the mesh size to make a title

nml  = read_sunfluidh_namelist
nx   = nml.DOMAIN_FEATURES.CELLS_NUMBER_I_DIRECTION;
ny   = nml.DOMAIN_FEATURES.CELLS_NUMBER_J_DIRECTION;
Rey  = 1/nml.FLUID_PROPERTIES.REFERENCE_DYNAMIC_VISCOSITY;
mystring = [' Profile at x= ',num2str(f.xu(xind)), ' Re = ',num2str(Rey), ...
              ', grid size = ' num2str(nx),'x', num2str(ny) ];
title(mystring)
For statistical fields you can use read_sunfluidh_data. You just need to add the 'stat' option (see doc read_sunfluidh_data). For statistical fields all data are centered on scalar grid points. It is also possible to center the instantaneaous fields with the option 'center'. This can be handy in a post processing when computing quantities with different velocity field components

Temporal series

The *ins* files or more generally temporal series are ascci files in which the first column is time and the first line is a header. There is no special needs to have a script for these files. You can use directly builtin matlab functions that you can taylor to your needs.

Conversely, you can use read_sunfluid_probes.m that attempts to read in the current directory all the *ins* files and build a structure with the variable names. It is quite fragile and may fail.

Reading the file resid_L2_Li.d with builtin matlab function

s =  importdata('resid_L2_Li.d');
time = s.data(:,1);
L2  = s.data(:,2);
Linf = s.data(:,3);
semilogy(time,L2)
grid on
xlabel('t'); ylabel('L2 norm')

Plotting the U velocity component for the second probe with builtin matlab function

s =  importdata('u_ins_00000.d',' ',1)
time = s.data(:,1);
u2  = s.data(:,3);
plot(time,u2)
grid on
xlabel('t'); ylabel('u probe2')

Using read_sunfluidh_probes.m makes the same job a bit easier.

s = read_sunfluidh_probes;
plot(s.time,s.u(:,2))
1)
For Unix system you can add a line in ~/.bashrc such as : export MATLABPATH='directory_where_the_files_are_stored'
Traductions de cette page:
  • fr
sunfluidh/sunfluidh_matlab.1548164165.txt.gz · Dernière modification : 2019/01/22 14:36 de witko

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki