SourceForge

A TUTORIAL FOR FLUX CONSERVATION

In this tutorial you will be led through the process of modefying the code you created in the last 2 tutorials so that fluxes are 'fixed' at jumps in refinement so that conservation is maintained.

Since we use finite differences to represent derivatives, there is no guarantee that those derivatives so represented will be continuous at jumps in refinement in our mesh. In typical applications this manifests itself as a non-conservation of some conserved variable.

In this tutorial we describe how to make use of the PARAMESH subroutine 'amr_flux_conserve' which patches the fluxes at refinement jumps.


We start again with our simple 2D diffusion equation, but recast the equation in terms of fluxes.

If we define the fluxes at cell interfaces, then a finite difference representation of the above equations is,

  U(i,j,t+dt) = U(i,j,t) + dt * { (Fx(i+1/2,j,t) - Fx(i-1/2,j,t)/dx + (Fy(i,j+1/2,t) - Fy(i,j-1/2,t))/dy }

where,

Fx(i+1/2,j,t) = (U(i+1,j,t) - U(i,j,t))/dx

and,

Fy(i,j+1/2,t) = (U(i,j+1,t) - U(i,j,t))/dy

Step 1. - Create a subroutine to compute the fluxes at block boundaries.


Step 2. - Edit the file 'advance_soln_npgc.F90'.


Step 3. - Edit the makefile AMRDIR/your_tutorial/Makefile.gnu and add fluxes.F90 to the list of sources.


Step 4. - Re-compile and run it. The changes made should not change the output from the last time you ran it.


          gmake -f make_tutor clean (NOTE: not needed if using LIBRARY)
          gmake -f make_tutor your_tutorial
          mpirun -np X your_tutorial/tutor


Step 5. - Now add in the flux-fix code.


Step 6. - Re-compile and run it. The changes made should not change the output from the last time you ran it.


          gmake -f make_tutor clean (NOTE: not needed if using LIBRARY)
          gmake -f make_tutor your_tutorial
          mpirun -np X your_tutorial/tutor

Return to Main Page.