Contents

StabFem Demo script for concentric jets WITH TANH VELOCITY PROFILE

This case corresponds to the configuration of Canton et al. This scripts aims to reproduce figure 5 of the reference article : base flow for Re = 1000 and several values of U2/U1

clc
clear all
close all

format shorte

Chapter 0 : Initialization

close all;clear all; clc
addpath([fileparts(fileparts(pwd)), '/SOURCES_MATLAB']);
SF_Start('verbosity',2,'ffdatadir','./WORK_d4_5_adri/'); % NB use verbosity=2 for autopublish mode ; 4 during work
SF_core_setopt('ErrorIfDiverge',false); % this is to correctly report problems in cases of divergence
set(groot, 'defaultAxesTickLabelInterpreter','latex');
set(groot, 'defaultLegendInterpreter','latex');
 Warning  : SF_core_start was not previously lanched ; launching right now
WARNING - librairy ARPACK NOT available

First generate a mesh

% Parameters
U1Max=1.5;
U2Max=1.5; % first value
R1=0.5; distance=4.5; D2=1; Lpipe = 5.2;
Xmax = 100*(R1+distance+D2)     % 100*D
YMax = 20 *(R1+distance+D2)           % 20*D
bctype = 1; % select 0 for constant and 1 for Poiseuille and 2 for Tanh
% Mesh generation



paramMESH = [R1 distance D2 Lpipe Xmax YMax];
ffmesh = SF_Mesh('Mesh_ConcentricJets_Pipes.edp','params',paramMESH,'problemtype','axixr','cleanworkdir','no');

% Generation of an initial solution
bf = SF_BaseFlow(ffmesh,'Re',1,'bctype',bctype ,'U2',U2Max,'U1',U1Max);
bf = SF_Adapt(bf,'anisomax',4,'nbjacoby',3);
Xmax =

   600


YMax =

   120

WARNING -  Your program uses depreciated syntax 'Params' to pass parameters 
WARNING -  It is advised to switch to new method using 'Options', and modify your Freefem solvers to detect parameters using 'getARGV'  
WARNING -  Folder ./WORK_d4_5_adri/MESHBF not found : creating it !

Raise Re

ReTab = [5 10:10:50 53:0.05:53.2]

en = [];

for Re = ReTab
    bf = SF_BaseFlow(bf,'Re',Re); %NB it is not needed to specify other parameters U1,U2,bctype : values of previous bf are used as default
    if bf.iter==-1
        disp(['Divergence in Newton for Re =',num2str(Re),' ; U2/U1 = ',num2str(U2Max)]);
        break;
    end
    % Generation of a mask to refine a given region
    MaskReg = [-8.0 20.0 0.0 1.5*(R1+D2+distance) 0.1]; % [Xmin Xmax Ymin Ymax delta]
    Mask = SF_Mask(bf.mesh,MaskReg);
    % Adaptation with a Mask
    [bf] = SF_Adapt(bf,Mask,'Hmax',2,'anisomax',4,'nbjacoby',3);
    en = [en bf.Energy];


end
ReTab =

  Columns 1 through 6

   5.0000e+00   1.0000e+01   2.0000e+01   3.0000e+01   4.0000e+01   5.0000e+01

  Columns 7 through 11

   5.3000e+01   5.3050e+01   5.3100e+01   5.3150e+01   5.3200e+01

Contour Plots

figure;
SF_Plot(bf,'ux','title','Re = 53.2',...
                'xlim',[-0.1 10],'ylim',[0 8],'ColorMap','parula');
hold on;
SF_Plot(bf,'psi','contour','only','xlim',[-0.1 10],...
                'ylim',[0 8],'clevels',[-1.5:0.05:1.5],'CColor','white' );
WARNING -  Error in SF_Plot : Field psi does not exist

Energy Plot

figure();
subplot(1,2,1); plot(ReTab(1:length(en)),en,'r','LineWidth',2)
 xlabel('Re','FontSize',15); ylabel('Energy','FontSize',15);grid on

subplot(1,2,2); plot(ReTab(1:length(en)),en,'r','LineWidth',2)
xlim([52 55]); xlabel('Re','FontSize',15); ylabel('Energy','FontSize',15); grid on

Velocity profiles

XposList = [-Lpipe 0 1]; Y=[0:0.001:8];
NPos = length(XposList);
uxProf = zeros(NPos,length(Y)); urProf = zeros(NPos,length(Y));
for index = 1:NPos
    uxProf(index,:)=SF_ExtractData(bf,'ux',XposList(index),Y);
    urProf(index,:)=SF_ExtractData(bf,'ur',XposList(index),Y);
end
figure; plot(uxProf,Y);xlabel('Ux(r,1)');ylabel('r');title('axial velocity');legend('x = -5.2','x = 0','x = 1')
figure; plot(urProf,Y);xlabel('Ur(r,1)');ylabel('r');title('radial velocity');legend('x = -5.2','x = 0','x = 1')
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c
Note: To improve runtime build MEX function fftri2gridfast() from fftri2gridfast.c

STABILITY ANALYSIS

MappingParams = [-10,30,-5,5,-0.3,5,-0.3,5];

[ev,em] = SF_Stability(bf,'m',0,'shift',0.05,'nev',1,'MappingDef','box','MappingParams',MappingParams);
[evA,emA] = SF_Stability(bf,'type','A','m',0,'shift',ev,'nev',1);


emS=SF_Sensitivity(bf, em, emA,'Type','S');

figure();
subplot(3,1,1);SF_Plot(em,'ux','xlim',[-0.5 10],'ylim',[0 8]);
title(['Direct Mode, \lambda = ',num2str(ev)]);
subplot(3,1,2);SF_Plot(emA,'ux','xlim',[-0.5 10],'ylim',[0 8]);
title(['Adjoint Mode, \lambda = ',num2str(ev)]);
subplot(3,1,3);SF_Plot(emS,'sensitivity','xlim',[-0.5 10],'ylim',[0 8],'colormap','ice');
title('Sensitivity');
WARNING -  baseflow.iter = 0 ! it seems your baseflow was projected after mesh adaptation but not recomputed !
ERROR   - SF_core_freefem: Error while using FreeFem++  ; file = StabAxi_m0.edp ; error code = 1 : Syntax error in your .edp program
WARNING - An error is encountered while publishing script. Launching SF_Status for diagnostics
################################################################################
...  SUMMARY OF YOUR DATABASE FOLDER :    ./WORK_d4_5_adri/
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK_d4_5_adri/MESHES :
     (list of meshes previously created/adapted ; couples of .msh/.ff2m files )
 
Index | Name              | generation mode | Date                 | Nv      
1     | FFMESH_000001.msh | initial         | 22-mars-2023 17:28:51 | 20752   
2     | FFMESH_000002.msh | adapted         | 22-mars-2023 17:30:24 | 2942    
3     | FFMESH_000003.msh | adapted         | 22-mars-2023 17:30:45 | 25237   
4     | FFMESH_000004.msh | adapted         | 22-mars-2023 17:34:11 | 29723   
5     | FFMESH_000005.msh | adapted         | 22-mars-2023 17:38:05 | 30340   
6     | FFMESH_000006.msh | adapted         | 22-mars-2023 17:41:16 | 30876   
7     | FFMESH_000007.msh | adapted         | 22-mars-2023 17:44:16 | 30762   
8     | FFMESH_000008.msh | adapted         | 22-mars-2023 17:47:10 | 31003   
9     | FFMESH_000009.msh | adapted         | 22-mars-2023 17:49:43 | 31256   
10    | FFMESH_000010.msh | adapted         | 22-mars-2023 17:51:49 | 31202   
11    | FFMESH_000011.msh | adapted         | 22-mars-2023 17:54:00 | 31292   
12    | FFMESH_000012.msh | adapted         | 22-mars-2023 17:56:04 | 31202   
13    | FFMESH_000013.msh | adapted         | 22-mars-2023 17:58:19 | 31321   
#################################################################################
 
     (list of base flows associated to newly computed meshes ; couples of .txt/.ff2m files )
     NB : these base flows are most likely simply projected and not recomputed, it is not recommended to use them
 
 Index | Name              | Type         | Date                 | Mesh file         | Re         | beta       | Energy     | U1         | U2         | bctype    
 1     | FFDATA_000003.txt | BaseFlow     | 22-mars-2023 17:30:27 | FFMESH_000002.msh | 1          | 8.3249     | 8.3249     | 0          | 1          | 0         
 2     | FFDATA_000004.txt | BaseFlow     | 22-mars-2023 17:31:11 | FFMESH_000003.msh | 5          | 14.5258    | 14.5258    | 0          | 1          | 0         
 3     | FFDATA_000005.txt | BaseFlow     | 22-mars-2023 17:34:36 | FFMESH_000004.msh | 10         | 69.574     | 69.574     | 0          | 1          | 0         
 4     | FFDATA_000006.txt | BaseFlow     | 22-mars-2023 17:38:27 | FFMESH_000005.msh | 20         | 277.335    | 277.335    | 0          | 1          | 0         
 5     | FFDATA_000007.txt | BaseFlow     | 22-mars-2023 17:41:42 | FFMESH_000006.msh | 30         | 463.855    | 463.855    | 0          | 1          | 0         
 6     | FFDATA_000008.txt | BaseFlow     | 22-mars-2023 17:44:39 | FFMESH_000007.msh | 40         | 624.694    | 624.694    | 0          | 1          | 0         
 7     | FFDATA_000009.txt | BaseFlow     | 22-mars-2023 17:47:37 | FFMESH_000008.msh | 50         | 764.215    | 764.215    | 0          | 1          | 0         
 8     | FFDATA_000010.txt | BaseFlow     | 22-mars-2023 17:50:07 | FFMESH_000009.msh | 53         | 802.408    | 802.408    | 0          | 1          | 0         
 9     | FFDATA_000011.txt | BaseFlow     | 22-mars-2023 17:52:14 | FFMESH_000010.msh | 53.05      | 803.05     | 803.05     | 0          | 1          | 0         
 10    | FFDATA_000012.txt | BaseFlow     | 22-mars-2023 17:54:23 | FFMESH_000011.msh | 53.1       | 803.654    | 803.654    | 0          | 1          | 0         
 11    | FFDATA_000013.txt | BaseFlow     | 22-mars-2023 17:56:29 | FFMESH_000012.msh | 53.15      | 804.337    | 804.337    | 0          | 1          | 0         
 12    | FFDATA_000014.txt | BaseFlow     | 22-mars-2023 17:58:42 | FFMESH_000013.msh | 53.2       | 804.95     | 804.95     | 0          | 1          | 0         
 
#################################################################################
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK_d4_5_adri/BASEFLOWS
     (couples of .txt/.ff2m files )
 
 Index | Name              | Type         | Date                 | Mesh file         | Re         | beta       | Energy     | U1         | U2         | bctype    
 1     | FFDATA_000001.txt | BaseFlow     | 22-mars-2023 17:30:20 | FFMESH_000001.msh | 1          | 8.3249     | 8.3249     | 0          | 1          | 0         
 2     | FFDATA_000002.txt | BaseFlow     | 22-mars-2023 17:30:39 | FFMESH_000002.msh | 5          | 14.5258    | 14.5258    | 0          | 1          | 0         
 3     | FFDATA_000003.txt | BaseFlow     | 22-mars-2023 17:33:41 | FFMESH_000003.msh | 10         | 69.574     | 69.574     | 0          | 1          | 0         
 4     | FFDATA_000004.txt | BaseFlow     | 22-mars-2023 17:37:33 | FFMESH_000004.msh | 20         | 277.335    | 277.335    | 0          | 1          | 0         
 5     | FFDATA_000005.txt | BaseFlow     | 22-mars-2023 17:40:48 | FFMESH_000005.msh | 30         | 463.855    | 463.855    | 0          | 1          | 0         
 6     | FFDATA_000006.txt | BaseFlow     | 22-mars-2023 17:43:46 | FFMESH_000006.msh | 40         | 624.694    | 624.694    | 0          | 1          | 0         
 7     | FFDATA_000007.txt | BaseFlow     | 22-mars-2023 17:46:40 | FFMESH_000007.msh | 50         | 764.215    | 764.215    | 0          | 1          | 0         
 8     | FFDATA_000008.txt | BaseFlow     | 22-mars-2023 17:49:12 | FFMESH_000008.msh | 53         | 802.408    | 802.408    | 0          | 1          | 0         
 9     | FFDATA_000009.txt | BaseFlow     | 22-mars-2023 17:51:19 | FFMESH_000009.msh | 53.05      | 803.05     | 803.05     | 0          | 1          | 0         
 10    | FFDATA_000010.txt | BaseFlow     | 22-mars-2023 17:53:30 | FFMESH_000010.msh | 53.1       | 803.654    | 803.654    | 0          | 1          | 0         
 11    | FFDATA_000011.txt | BaseFlow     | 22-mars-2023 17:55:34 | FFMESH_000011.msh | 53.15      | 804.337    | 804.337    | 0          | 1          | 0         
 12    | FFDATA_000012.txt | BaseFlow     | 22-mars-2023 17:57:47 | FFMESH_000012.msh | 53.2       | 804.95     | 804.95     | 0          | 1          | 0         
 
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK_d4_5_adri/MESHBF
     (couples of .txt/.ff2m files )
 
 Index | Name              | Type         | Date                 | Mesh file         | Re         | beta       | Energy     | U1         | U2         | bctype    
 1     | FFDATA_000001.txt | BaseFlow     | 22-mars-2023 17:30:19 | FFMESH_000001.msh | 1          | 8.3249     | 8.3249     | 0          | 1          | 0         
 
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK_d4_5_adri/MISC
     (couples of .txt/.ff2m files )
   NB this directory may contain various secondary files produced by StabFem,
      such as flowfields projected after adaptation but not recomputed, adaptation masks, etc... 
 
 Index | Name              | Type         | Date                 | Mesh file        
 1     | FFDATA_000001.txt | MASK         | 22-mars-2023 17:30:42 | FFMESH_000002.msh
 2     | FFDATA_000002.txt | MASK         | 22-mars-2023 17:34:00 | FFMESH_000003.msh
 3     | FFDATA_000003.txt | MASK         | 22-mars-2023 17:37:56 | FFMESH_000004.msh
 4     | FFDATA_000004.txt | MASK         | 22-mars-2023 17:41:08 | FFMESH_000005.msh
 5     | FFDATA_000005.txt | MASK         | 22-mars-2023 17:44:07 | FFMESH_000006.msh
 6     | FFDATA_000006.txt | MASK         | 22-mars-2023 17:47:02 | FFMESH_000007.msh
 7     | FFDATA_000007.txt | MASK         | 22-mars-2023 17:49:34 | FFMESH_000008.msh
 8     | FFDATA_000008.txt | MASK         | 22-mars-2023 17:51:41 | FFMESH_000009.msh
 9     | FFDATA_000009.txt | MASK         | 22-mars-2023 17:53:52 | FFMESH_000010.msh
 10    | FFDATA_000010.txt | MASK         | 22-mars-2023 17:55:56 | FFMESH_000011.msh
 11    | FFDATA_000011.txt | MASK         | 22-mars-2023 17:58:10 | FFMESH_000012.msh
 
 
#################################################################################
Error using SF_core_log
SF_core_freefem: Error while using FreeFem++  ; file = StabAxi_m0.edp ; error
code = 1 : Syntax error in your .edp program

Error in SF_core_freefem (line 420)
     SF_core_log(errortype, ['SF_core_freefem: Error while using FreeFem++  ; file = ', cmd,' ; error code = ',num2str(s) ,' : ' ,errormsg]);

Error in SF_Stability (line 758)
    status = SF_core_freefem(solver,'parameters',argumentstring,'arguments',ffargument,'bin',ffbin,'Include',Include,'ncores',p.Results.ncores);

Error in ConcentricJets_d4_5_adri (line 98)
[ev,em] = SF_Stability(bf,'m',0,'shift',0.05,'nev',1,'MappingDef','box','MappingParams',MappingParams);

SUMMARY OF ALL WE HAVE DONE SO FAR

SF_Status;


% [[PUBLISH]]






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