CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Post-Processing

Some scripts for GNU/Octave or Matlab Post-processing

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   December 17, 2013, 13:14
Default Some scripts for GNU/Octave or Matlab Post-processing
  #1
New Member
 
Antonio
Join Date: Jan 2013
Posts: 9
Rep Power: 4
avigrod is on a distinguished road
In case you want to read xyz coordinates of cell centers, and simulated scalars or vectors, here I paste some easy function which could help someone, they are used as follows:

phase = readEscalarOF('alpha1',510)
[xCell,yCell,zCell] = readCellCentersOF(510)
V=readVectorOF('U',510)


Code:
function seriededatos = readEscalarOF (variable,tiempo)
% seriededatos = leeescalarOF (variable,tiempo)
% lee tiempo/variable o tiempo/variable.gz
  
  if !ischar(tiempo), tiempo = num2str(tiempo); end
  fichero = [tiempo '/' variable]

descomprimido = length( dir(fichero));

if !descomprimido,
  ficherogz = [fichero '.gz']
  check = length( dir(ficherogz));
  system(['gunzip ' ficherogz]);
else
  check = 1;
end

if check,
  FID = fopen(fichero,'r');

  for i=1:20,
    fgetl(FID);
  end

  num_celdas = fscanf(FID,'%d',1);
  fgetl(FID);fgetl(FID);

  seriededatos = fscanf(FID,'%f\n',num_celdas);

  check = fgetl(FID);

  if !strcmp(check,')'),
    display('\nposible error tamanho variable!!\n')
  end

  fclose(FID);

  if !descomprimido,
     system(['gzip ' fichero]);
  end
else
  fprintf(1,'\nfichero no encontrado\n\n')
end
Code:
function seriededatos = readVectorOF (variable,tiempo)
% seriededatos = leeescalarOF (variable,tiempo)
% lee tiempo/variable o tiempo/variable.gz
  
  if !ischar(tiempo), tiempo = num2str(tiempo); end
  fichero = [tiempo '/' variable]

descomprimido = length( dir(fichero));

if !descomprimido,
  ficherogz = [fichero '.gz']
  check = length( dir(ficherogz));
  system(['gunzip ' ficherogz]);
else
  check = 1;
end

if check,
  FID = fopen(fichero,'r');

  for i=1:20,
    fgetl(FID);
  end

  num_celdas = fscanf(FID,'%d',1);
  fgetl(FID);fgetl(FID);

  datos = fscanf(FID,'(%f %f %f)\n',3*num_celdas);
  seriededatos = [datos(1:3:end) datos(2:3:end) datos(3:3:end)]; 
  check = fgetl(FID);

  if !strcmp(check,')'),
    display('\nposible error tamanho variable!!\n')
  end

  fclose(FID);

  if !descomprimido,
     system(['gzip ' fichero]);
  end
else
  fprintf(1,'\nfichero no encontrado\n\n')
end
Code:
function [xCell, yCell, zCell] = readCellCentersOF (tiempo)
% seriededatos = leeescalarOF (tiempo)
% lee tiempo/ccx o tiempo/ccx.gz ccy y ccz
  
    
if !ischar(tiempo), tiempo = num2str(tiempo); end

  
if  !length( dir([tiempo '/ccx*'])),
  system(['writeCellCentres -time ' tiempo]);
end

xCell= readEscalarOF('ccx',tiempo);
yCell= readEscalarOF('ccy',tiempo);
zCell= readEscalarOF('ccz',tiempo);

%seriededatos =[x y z];
avigrod is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wind turbine - post processing er_ijaz FLUENT 0 September 30, 2013 05:28
post processing for CEL expressions Niru CFX 0 May 10, 2013 13:13
Automated post processing using CFD Post shreyasr ANSYS 0 January 28, 2013 07:21
CFD post processing techniques & streamlining klk Main CFD Forum 0 October 19, 2010 07:37
post processing in CFD MANISH BHARGAVA Main CFD Forum 0 October 17, 1998 20:51


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