post processing in viv

post-processing in VIV

1 delete duplicate rows in fluent output file

data: time history of force, displacement package: excel

steps:

  1. selete all, select tab
  2. Data/revove duplicates

3.select default columns, and press ok

https://www.howtogeek.com/198052/how-to-remove-duplicate-rows-in-excel/

2 image and video

 

2.1 crop images

start point: 5D, 4D upstream

mogrify -crop 388x148+380+622 *.jpg

mogrify -crop 388x168+380+622 *.jpg

2.2 image2video

clc
clear
step=63;
for i=3:step
    h=figure(1); % ÏÂÃæÒ»ÐÐÌ滻ΪÏëÒªÏÔÊŸµÄÄÚÈÝ
%     set(0,'defaultfigurecolor','w')
    f_name=strcat('AnimationFrame',num2str(i,'%.6d'),'.jpg')
    aa=imread([f_name]);
    cc=imcrop(aa,[20 20 2000 800]);
    imshow(cc)
%     imshow([f_name]);
%   imshow([num2str(i),'.jpg']);
    frame = getframe(h);
    im = frame2im(frame);
    [imind,cm] = rgb2ind(im,256);
    % Write to the GIF File?
    if i==1
        imwrite(imind,cm,['Frame','.gif'],'gif', 'Loopcount',inf,'DelayTime',0.1);
    elseif i==step
        imwrite(imind,cm,['Frame','.gif'],'gif','WriteMode','append','DelayTime',0.1);
    else
        imwrite(imind,cm,['Frame','.gif'],'gif','WriteMode','append','DelayTime',0.1);
    end
end

2.3 combine videos

3 vorticity contour

 

3.1 Goal:

get vorticity contour at every time step

3.2 Steps

  1. load one case and data file
  2. display vorticity contour with code

a) Select "command editor" and paste the following code

b) change expression if needed

# Session file started:  2019/11/12 15:12:02
# CFX-15.0 build 2013.10.10-08.49-130242

# To avoid unnecessary file pre-processing and modifications, include
# COMMAND FILE at the top of your session file.
# If it is not included, the file is assumed to be older and will be
# modified for backward compatibility.
COMMAND FILE:
  CFX Post Version = 15.0
END

VIEW:View 1
  Camera Mode = User Specified
  CAMERA:
    Option = Pivot Point and Quaternion
    Pivot Point = 2, 0.6, 0.3
    Scale = 0.749315
    Pan = 0, 0
    Rotation Quaternion = 0, 0, 0, 1
  END
  
END

> update
LIBRARY:
  CEL:
    EXPRESSIONS:
      revortex = Velocity.Curl Z*0.1/1.1686
    END
  END
END

EXPRESSION EVALUATOR:
  Evaluated Expression = revortex
END

> forceupdate EXPRESSION EVALUATOR

USER SCALAR VARIABLE:divortex
  Boundary Values = Conservative
  Calculate Global Range = Off
  Expression = revortex
  Recipe = Expression
  Variable to Copy = Pressure
  Variable to Gradient = Pressure
END


PLANE:Plane 1
  Apply Instancing Transform = On
  Apply Texture = Off
  Blend Texture = On
  Bound Radius = 0.5 [m]
  Colour = 0.75, 0.75, 0.75
  Colour Map = Default Colour Map
  Colour Mode = Constant
  Colour Scale = Linear
  Colour Variable = Pressure
  Colour Variable Boundary Values = Conservative
  Culling Mode = No Culling
  Direction 1 Bound = 1.0 [m]
  Direction 1 Orientation = 0 [degree]
  Direction 1 Points = 10
  Direction 2 Bound = 1.0 [m]
  Direction 2 Points = 10
  Domain List = /DOMAIN GROUP:All Domains
  Draw Faces = On
  Draw Lines = Off
  Instancing Transform = /DEFAULT INSTANCE TRANSFORM:Default Transform
  Invert Plane Bound = Off
  Lighting = On
  Line Colour = 0, 0, 0
  Line Colour Mode = Default
  Line Width = 1
  Max = 0.0 [Pa]
  Min = 0.0 [Pa]
  Normal = 1 , 0 , 0
  Option = XY Plane
  Plane Bound = None
  Plane Type = Slice
  Point = 0 [m], 0 [m], 0 [m]
  Point 1 = 0 [m], 0 [m], 0 [m]
  Point 2 = 1 [m], 0 [m], 0 [m]
  Point 3 = 0 [m], 1 [m], 0 [m]
  Range = Global
  Render Edge Angle = 0 [degree]
  Specular Lighting = On
  Surface Drawing = Smooth Shading
  Texture Angle = 0
  Texture Direction = 0 , 1 , 0
  Texture File =
  Texture Material = Metal
  Texture Position = 0 , 0
  Texture Scale = 1
  Texture Type = Predefined
  Tile Texture = Off
  Transform Texture = Off
  Transparency = 0.0
  X = 0.0 [m]
  Y = 0.0 [m]
  Z = 0.3 [m]
  OBJECT VIEW TRANSFORM:
    Apply Reflection = Off
    Apply Rotation = Off
    Apply Scale = Off
    Apply Translation = Off
    Principal Axis = Z
    Reflection Plane Option = XY Plane
    Rotation Angle = 0.0 [degree]
    Rotation Axis From = 0 [m], 0 [m], 0 [m]
    Rotation Axis To = 0 [m], 0 [m], 0 [m]
    Rotation Axis Type = Principal Axis
    Scale Vector = 1 , 1 , 1
    Translation Vector = 0 [m], 0 [m], 0 [m]
    X = 0.0 [m]
    Y = 0.0 [m]
    Z = 0.0 [m]
  END
END

# Sending visibility action from ViewUtilities
>show /PLANE:Plane 1, view=/VIEW:View 1


CONTOUR:Contour 1
  Apply Instancing Transform = On
  Clip Contour = Off
  Colour Map = Default Colour Map
  Colour Scale = Linear
  Colour Variable = divortex
  Colour Variable Boundary Values = Conservative
  Constant Contour Colour = Off
  Contour Range = User Specified
  Culling Mode = No Culling
  Domain List = /DOMAIN GROUP:All Domains
  Draw Contours = On
  Font = Sans Serif
  Fringe Fill = On
  Instancing Transform = /DEFAULT INSTANCE TRANSFORM:Default Transform
  Lighting = On
  Line Colour = 0, 0, 0
  Line Colour Mode = Default
  Line Width = 1
  Location List = /PLANE:Plane 1
  Max = 2 [s^-1]
  Min = -2 [s^-1]
  Number of Contours = 100
  Show Numbers = Off
  Specular Lighting = On
  Surface Drawing = Smooth Shading
  Text Colour = 0, 0, 0
  Text Colour Mode = Default
  Text Height = 0.024
  Transparency = 0.0
  Value List = 0 [s^-1],1 [s^-1]
  OBJECT VIEW TRANSFORM:
    Apply Reflection = Off
    Apply Rotation = Off
    Apply Scale = Off
    Apply Translation = Off
    Principal Axis = Z
    Reflection Plane Option = XY Plane
    Rotation Angle = 0.0 [degree]
    Rotation Axis From = 0 [m], 0 [m], 0 [m]
    Rotation Axis To = 0 [m], 0 [m], 0 [m]
    Rotation Axis Type = Principal Axis
    Scale Vector = 1 , 1 , 1
    Translation Vector = 0 [m], 0 [m], 0 [m]
    X = 0.0 [m]
    Y = 0.0 [m]
    Z = 0.0 [m]
  END
END

# Sending visibility action from ViewUtilities
>show /CONTOUR:Contour 1, view=/VIEW:View 1

# Sending visibility action from ViewUtilities
>hide /DEFAULT LEGEND:Default Legend View 1, view=/VIEW:View 1


# Session file stopped:  2019/11/12 15:16:00
  1. add time value
  2. animation

timestep selector >> animation>> animation options

4 time histories of displacement, lift and drag

FFT– find the frequency

package: matlab

%% inputs: time, displacement, lift and drag coefficents
% author: guofei, kaiming ai 
% output: normalised displacement vs time
clear;
clc;
%% read data
data=xlsread('gap0.005ur7.xlsx');
A1=data(800:4233,1); % time on one cycle
A2=data(800:4233,2); % displacement
A3=data(800:4233,3); % lift
A4=data(800:4233,4); % drag
% plot(A1,A2)
%% plot data
figure(1);
U=1.1686;       %free stream velocity
fig_hei=0.28;
fig_wei=0.9;
lef_cor_x=0.08;
lef_cor_y=0.1;

% sub-figure1: drag history
subplot(3,1,1,'position', [lef_cor_x lef_cor_y+fig_hei+fig_hei fig_wei fig_hei])
plot(A1*U/0.1,A4,'b-');
ylabel('\itC_{D}','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([20,400,-inf,inf])
set(gca,'xticklabel',[])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
%sub-figure2: Cl, lift coefficient history
subplot(3,1,2,'position', [lef_cor_x lef_cor_y+fig_hei fig_wei fig_hei])
plot(A1*U/0.1,A3,'r-');
ylabel('\itC_{l}','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([20,400,-inf,inf])
set(gca,'xticklabel',[])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
%subplot 3: A/D, normalised displacement history
subplot(3,1,3,'position', [lef_cor_x lef_cor_y fig_wei fig_hei])
plot(A1*U/0.1,A2/0.1,'r-');
ylabel('\itA/D','fontsize',20,'fontname','Times New Roman');
xlabel('\ittU/D','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([20,400,-inf,inf])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FFT
Data_FFT=[A2,A3,A4];
S=[Data_FFT(:,1)-mean(Data_FFT(:,1)),Data_FFT(:,2)-mean(Data_FFT(:,2)),Data_FFT(:,3)-mean(Data_FFT(:,3))];
Fs=200;% sample freq
N=9000;% number of sample
t=[0:1/Fs:N/Fs];
Y=fft(S,N);
Ayy=(abs(Y));
%Ayy=Ayy/(N/2);
Ayy_1=Ayy(:,1);
Ayy_2=Ayy(:,2);
Ayy_3=Ayy(:,3);
F=([1:N]-1)*Fs/N;
%%%%%%%%%% 
% plot 2
%%%%%%%%%%%%%
figure(2);
%FFT of cd
subplot(3,1,1,'position', [lef_cor_x lef_cor_y+fig_hei+fig_hei fig_wei fig_hei])
plot(F(1:N/2),Ayy_3(1:N/2),'b-','linewidth',2);
ylabel('\itAmplitude','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([0,10,0,inf])
set(gca,'xticklabel',[])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
%FFT of cl
subplot(3,1,2,'position', [lef_cor_x lef_cor_y+fig_hei fig_wei fig_hei])
plot(F(1:N/2),Ayy_2(1:N/2),'b-','linewidth',2);
ylabel('\itAmplitude','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([0,10,0,3e3])
set(gca,'xticklabel',[])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
% subplot 3 : dis
subplot(3,1,3,'position', [lef_cor_x lef_cor_y fig_wei fig_hei])
plot(F(1:N/2),Ayy_1(1:N/2),'b-','linewidth',2);
xlabel('\itf','fontsize',20,'fontname','Times New Roman');
ylabel('\itAmplitude','fontsize',20,'fontname','Times New Roman');
set(gca,'fontsize',20,'fontname','Times New Roman')
axis([0,10,0,100])
box off
ax2 = axes('Position',get(gca,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
set(ax2,'YTick', []);
set(ax2,'XTick', []);
box on
%% mean value of Cd
mean_Cd = mean(A4)
%% rms_Cd
rms_Cd = rms(A4)
%% rms_cl
rms_Cl = rms(A3)
%% displacement
A2_mean = A2(A2>0.06);
s = sum(A2_mean);
l = length(find(A2>0.06));
dis_ave = s/l;
%% RMS of displacement, max displacement
Rms = rms(A2);
dis = Rms*(2)^0.5
max_dis = max (A2)
K = F';
C = data(:,1)*U/0.1;

Author: ka

Created: 2020-04-07 二 21:18

Emacs 24.5.1 (Org mode 8.2.10)

Validate

猜你喜欢

转载自www.cnblogs.com/code-saturne/p/12656074.html