Chapter III.1. Using the existing Burgers solver

Table of Contents

III.1.1. Compiling
III.1.2. Initializing
III.1.3. Running
III.1.4. Plotting

III.1.1. Compiling

So, you have just extracted the source in a directory and you want to have fun ? Ok. This example doesn't require any external library except the Boost headers, which are assumed to lie in a standard include directory on your system. Boost.Build should be installed since you used it to build Boost. By the way, don't tell, but you don't need root access to install libraries.

We do need to set a few things up to begin with. First, be sure to set the BOOST_BUILD_PATH environment variable to point to your Boost.Build installation directory. Then, copy the site-config-sample.jam from your source directory to $BOOST_BUILD_PATH/site-config.jam. Have a look at the comment line documentation within this file and edit it if necessary. Then cd back to the source directory and type:

			bjam burgers-dist spatial-scheme=wavelets wavelet=dtcwt debug
		

Basically, you have asked bjam to make the target named "burgers-dist", with the feature "spatial-scheme" set to "wavelets", and "wavelet" set to "dtcwt", and to use the "debug" variant. You may have to add "mpi=on" if you have configured mpi, but this will not matter later since the application is not actually using MPI. Now if you are lucky the program should be compiled and stored in /tmp/bin/burgers-dtcwt-wavelets (or maybe $(install-prefix)/bin/burgers-dtcwt-wavelets if you have changed that in site-config.jam).

III.1.2. Initializing

What the program that we have just compiled does is to solve the initial value problem for the Burgers equation with periodic boundary conditions. We want to provide an initial condition to our Burgers solver in the form of an ASCII file called in.dat. The format that it expects is very simple :

  • the first line contains a single integer which says the number of gridpoints N to use,
  • the second line contains the N space-separated values of the initial condition at the gridpoints.

N can be any power of 2 that you like. If you want to go fast, just take 8 and enter some values by hand. If you want to see nice plots later, you can use a Perl script such as this one to generate the file:

			#!/usr/bin/perl
			my $N = 512;
			open OUT,">in.dat";
			print OUT "$N\n";
			print OUT sin(8*atan2(1,1)*$_/$N)." " foreach(1..$N);
		

III.1.3. Running

In the directory containing the input file, type: /tmp/bin/burgers-dtcwt-wavelets init=0 total_time=0.5 max_timestep=0.05 tplot=1

  • "init=0" means that we load the initial data from a file,
  • "total_time=0.5" says how long we want to integrate the equation,
  • "max_timestep=0.05" and "tplot=1" mean that we want to print the solution every 0.05 units of time.

Parameters are passed using the "name=value" syntax. Default values are usually provided for most parameters if you don't specify them on the command line, but a few important parameters may be mandatory.

You will see a lot of terminal activity when the program runs : that's because we compiled in debug mode. The program tells us every operation that it does: lots of wavelet transforms, reduction operations, decimations. The complete run should not take more than 1 minute on a standard 2009 computer.

III.1.4. Plotting

That's the easiest ! Just take your favorite plotting tool, load the file "velocity.txt", and plot the curves ! The file contains one line for each time that the solution was printed. In Scilab, the code would simply look like:

			load velocity.txt;
			plot(velocity');