Learn by examples 2 : heat exchanger

Contents

This example is taken from the "learning by examples" section from the FreeFem++ manual. We recommend that you study it after reading about it in the freefem manual, and after looking at the previous example SCRIPT_membrane.m.

Compared to this very first example, the present one introduces two additional functionalities : - Transmission of parameters through 'Options/getARGV' . - Usage of DataBase

Initialization

close all;
addpath('../../SOURCES_MATLAB');
SF_Start('verbosity',4);

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

In this second example, a DataBase directory is initiated in folder './WORK/'. All result files will be placed in this folder and subfolders. Compare with previous example SCRIPT_membrane.m to see the difference.

Generation of the mesh

Ndensity =50;
ffmesh = SF_Mesh('HeatExchanger_Mesh.edp','Options',{'meshdensity',Ndensity})
ffmesh = 

  struct with fields:

             points: [3x546 double]
             bounds: [3x135 double]
                tri: [4x980 double]
                 np: 546
                nbe: 135
                 nt: 980
             labels: [1 2 3 4]
        problemtype: 'unspecified'
           filename: './WORK/MESHES/FFMESH_000001.msh'
           meshtype: '2D'
           datatype: 'mesh'
    DataDescription: 'Mesh (generated by generic macro)'
     generationmode: 'initial'
    datastoragemode: 'unknown'
       TriangleSize: [546x1 double]
                np2: 2071
          Vh_P2P2P1: [14700x1 double]
        Vh_P2P2P2P1: [20580x1 double]
              Vh_P2: [5880x1 double]
     meshgeneration: 0
           symmetry: 'N'

Note that here an option 'meshdensity' is passed to the mesh generator. This is equivalent to lanching "FreeFem++ HeatExchanger_Mesh.edp -meshdensity 50" The parameter is detected through "getARGV" within the FreeFem program. (see program HeatExchanger_Mesh.edp)

See FreeFem doc about this.

Plot mesh

figure(1);SF_Plot(ffmesh,'mesh','title','Mesh for Heat Exchanger Problem','boundary','on');
pause(0.1);

Problem : HC

a1 = 1.;
Field = SF_Launch('HeatExchanger.edp', 'Mesh', ffmesh, 'Options', {'a1', a1},'store','Heat');
WARNING -  Folder ./WORK//Heat mentioned for database storing does not exist ; creating it

This is equivalent to launching "FreeFem++ HeatExchanger.edp -a1 1."

Here again an option 'a1' is passed to the solver. It is also detected through "getARGV" within the FreeFem program. (see program HeatExchanger.edp)

%
% Note the option 'store','Heat' which tells the driver that the resulting
% files will have to be displaced into folder 'Heat' of the database.

Plot the solution

figure(2);SF_Plot(Field,'T','title', 'Temperature of Heat Exchanger','contour', 'on');
hold on; plot([-1 1],[.5,.5],'r--')
hold off;

Demonstation of database

sfs = SF_Status
################################################################################
...  SUMMARY OF YOUR DATABASE FOLDER :    ./WORK/
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK/MESHES :
     (list of meshes previously created/adapted ; couples of .msh/.ff2m files )
 
Index | Name              | generation mode | Date                 | Nv      
1     | FFMESH_000001.msh | initial         | 08-sept.-2021 03:51:30 | 546     
 
#################################################################################
#################################################################################
 
.... CONTENT OF DIRECTORY ./WORK/Heat
     (couples of .txt/.ff2m files )
 
 Index | Name              | Type         | Date                 | Mesh file        
 1     | FFDATA_000001.txt | HC           | 08-sept.-2021 03:51:33 | FFMESH_000001.msh
 
#################################################################################

sfs = 

  struct with fields:

    MESHES: [1x1 struct]
      Heat: [1x1 struct]

we can see that the files 'mesh.msh' and 'Data.txt' have been renamed and displaced in folders 'MESHES' and 'Heat'.

[[PUBLISH]] -> tag for publication on website

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