Movement of a 2D elliptical body falling in a viscous fluid

Contents

This example is adapted from the example "NS-falling-ellipse-adapt-moving.edp" from the FreeFem++ repository.

Chapter 0 : initialization

addpath('../../SOURCES_MATLAB');
SF_Start('verbosity',4);
if (SF_core_getopt('isoctave'))
  warning(' This script may take a very long time if using octave because reading .txt files and generating movie is very slow')
end

SF_DataBase('create','./WORK/');
NOTICE  - Initialization already done
WARNING - Detected verbosity = 4 in Publish mode ; not recommended ! switching to 2 instead

Chapter 1 : launching the DNS

First setting the paremeters.

DNSParams.dt = 0.1; DNSParams.Niter = 200; DNSParams.theta = 20;

Launching simulation

Run1 = SF_TS_Launch('TimeStepper_NS_Falling_Ellipse.edp','Options',DNSParams);
WARNING - FUNCTION SF_TS_Launch : normally you should specify either a mesh  ('mesh') or a initial condition  ('Init') ! 

Importing results

[TimeStats,Snapshots] = SF_TS_Check(Run1);
#################################################################################
.... CONTENT OF  ./WORK/TimeStepping/RUN000001/ : 
 Simulation completed

 Time-stepping simulation started 11-Jul-2021 20:02:44
 Solver                      : TimeStepper_NS_Falling_Ellipse.edp
 Mesh file name              : 
 Initial condition file name : 
 Argument string             :   -dt 0.1  -Niter 200  -theta 20 
 -> Found time series spaning from iter = 1 to 200 ; time = 0.1 to 20
 -> Found 20 Snapshots in this folder. Importing them....

Chapter 2 : postprocessing

Plotting the trajectory

figure;  plot(TimeStats.Xe,TimeStats.Ye);
title('trajectory of the ellipse');xlabel('x');ylabel('y');

Generating a movie

h = figure;
mkdir('html');
filename = 'html/SCRIPT_Falling_Ellipse_movie.gif';
for i=1:length(Snapshots)
    SF_Plot(Snapshots(i),'uy','colorrange',[-1.5 1.5],'title',['t = ',num2str(Snapshots(i).t)],'boundary','on');
    pause(0.1);
    frame = getframe(h);
    im = frame2im(frame);
    [imind,cm] = rgb2ind(im,256);
    if (i==1)
       imwrite(imind,cm,filename,'gif', 'Loopcount',inf,'DelayTime',0.1);
       set(gca,'nextplot','replacechildren');
    else
       imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',0.1);
    end
end
Warning: Directory already exists. 

Here is the movie

Summary

sfs = SF_Status
################################################################################
...  SUMMARY OF YOUR DATABASE FOLDER :    ./WORK/
#################################################################################
 
.... NO MESH FOUND IN DIRECTORY ./WORK/MESHES :
 
 
#################################################################################
#################################################################################
.... Checking for simulation results in folder ./WORK/TimeStepping
#################################################################################
.... CONTENT OF  ./WORK/TimeStepping/RUN000001/ : 
 Simulation completed

 Time-stepping simulation started 11-Jul-2021 20:02:44
 Solver                      : TimeStepper_NS_Falling_Ellipse.edp
 Mesh file name              : 
 Initial condition file name : 
 Argument string             :   -dt 0.1  -Niter 200  -theta 20 
 -> Found time series spaning from iter = 1 to 200 ; time = 0.1 to 20
 -> Found 20 Snapshots in this folder.
#################################################################################
 
.... SNAPSHOTS FOUND IN DIRECTORY ./WORK/TimeStepping/RUN000001/
     (couples of .txt/.ff2m files )
 
Total : 20 files. Displaying only first and last ones
Name                     | Type         | Date                 | t          | it        
Snapshot_00000010.txt    | DNSField     | 11-juil.-2021 20:02:50 | 1          | 10        
Snapshot_00000020.txt    | DNSField     | 11-juil.-2021 20:02:57 | 2          | 20        
(skipping intermediate)    |
Snapshot_00000190.txt    | DNSField     | 11-juil.-2021 20:04:46 | 19         | 190       
Snapshot_00000200.txt    | DNSField     | 11-juil.-2021 20:04:54 | 20         | 200       
 
 To import one snapshot, use SF_Load. For instance to import last one : "Snap = SF_Load('TimeStepping',1,200)"
#################################################################################

sfs = 

  struct with fields:

    TimeStepping: [1x1 struct]

[[PUBLISH]]

%
fclose(fopen('SCRIPT_Falling_Ellipse.success','w+'));