Lesson 6 : Using Data Parameter File

We present here an example of use of the Parameter Data File. This powerful tool simplifies for a user the introduction of input data specific to . The idea is very simple : you have to write a text file following some simple rules and declare, in your code, an instance of class IPF. Each parameter introduced in your file is then recovered from a specific member function from your instance. We shall illustrate hereafter this through an example of a fluid flow code. Note that a precise description of the input file can be found in this page.

An Input Data File

Consider the following text file:


#PARAM!
# Cavity test
Proj        test
MaxTime      1000
TimeStep    0.01
Verbose        1
Output         0
Save           0
Tolerance  1.e-5
Plot        1000
Init           1
DoublePar      1    # Density
DoublePar   0.0001  # Viscosity
MeshFile     test.m
AuxFile      test.v
AuxFile      test.sav
EOF

Let us make some comments about the structure of this file:

In the program that uses such a file, we have the following lines:
   IPF data(argv[1]);
   double max_time = data.getMaxTime();
   double deltat = data.getTimeStep();
   int verbose = data.getVerbose();
   int output_flag = data.getOutput();
   int save_flag = data.getSave();
   double tol = data.getTolerance();
   int plot_flag = data.getPlot();
   double dens = data.getDoublePar(1);
   double visc = data.getDoublePar(2);
   ms.Get(data.getMeshFile());
   FDF vf(data.getAuxFile(1),"w");
   FDF sf(data.getAuxFile(2),"w");
   int init_flag = data.getInit();
In this way, all these parameters are retrieved in a finite element program without any explicit i/o operation.

 
Copyright © 1998-2007 Rachid Touzani