Ceci est une ancienne révision du document !
Table des matières
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 matlabpath1).
- read_sunfluidh_data reads res* or rst* files
- read_sunfluidh_probes reads all probes files *_ins_*
- 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.
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 lastest 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)
Temporal series
The *ins* files or more generally temporal series are ascii 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.
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')
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 however quite fragile and may fail. Exemple using read_sunfluidh_probes.m that intend to make the same job a bit easier.
s = read_sunfluidh_probes; plot(s.time,s.u(:,2))
- fr