Lesson 6: Using Project File

We present here an example of use of the Project 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:

<?xml version="1.0" encoding="ISO-8859-1" ?>
     <title<Cavity Test</title>
     <date>January 1, 2000</date>
  <Project name="test">
     <verbose value="1"/>
     <output value="0"/>
     <save value="0"/>
     <tolerance value="1.e-5"/>
     <plot value="1000"/>
     <init value="1"/>
     <parameter label="density">1.0</parameter>
     <parameter label="viscosity">0.01</parameter>
     <mesh_file value="test.m"/>
     <parameter label="output_file" value="test.v"/>
     <save_file value="test.sav"/>

In the program that uses such a file, we have the following lines:

   IPF proj(argv[1]);
   double max_time = proj.getMaxTime();
   double deltat = proj.getTimeStep();
   int verbose = proj.getVerbose();
   int output_flag = proj.getOutput();
   int save_flag = proj.getSave();
   double tol = proj.getTolerance();
   int plot_flag = proj.getPlot();
   double dens = proj.getString("density");
   double visc = proj.getString("viscosity");
   Mesh ms(proj.getMeshFile());
   IOField vf(proj.getMeshFile(),data.getString("output_file"),ms,XML_WRITE);
   int init_flag = proj.getInit();

In this way, all these parameters are retrieved in a finite element program without any explicit i/o operation.

Copyright © 1998-2016 Rachid Touzani