Physics 555B: Solution of Time-dependent PDEs using Multigrid

  • LCS MG code for 2D diffusion equation

    Note:
    This code is built using RNPL, which is a special-purpose language designed to facilitate the construction of finite-difference codes for solving time-dependent  partial differential equations. RNPL uses Fortran 77 or C as an intermediary language; that is, compilation of an RNPL source file results in the creation of several f77 or C source files that can then be compiled together to produce an executable.  In some instances RNPL is used to generate COMPLETE codes for the solution of a particular set of difference equations.  In other cases, however, such as the current one, RNPL is used to provide a basic "driver" program, that standardizes facilities common to any program for the FD solution of a time-dependent PDE. Such facilities include memory management, parameter definition, periodic ouptut to .sdf files and a mechanism to keep convergence testing as straightforward as possible. The code then uses the fact that RNPL provides an "escape mechanism" to allow the user to provide more or less arbitrary pieces of f77 (or C) code to perform the update and/or initialization of grid functions.

    Information concerning RNPL can be found HERE, for those of you  who are interested in the language.  It's use in this instance was primarily one of convenience for the instructor; one can equally well write the "driver" part of the program by hand, but RNPL makes this process more rapid and less error prone.

    Important Note:  I have not yet "bundled" this code for export so that it can be compiled as a "stand-alone" application.  Specifically, the code calls routines that are defined in some of my "personal" libraries that we have not discussed in this course.  If you are interested in actually building and using this code yourself, please contact me directly.

    • diff2dcn_rnpl: RNPL source which generates driver code, and incorporates "hand coded" update as defined in update0.inc
    • update0.inc: f77 fragment which is incorporated by RNPL into update routine,  Includes definition of fine grid source function, as well as call to LCS MG routine, mg2v0, as discussed in class.
    • mgapp.f: Application-dependent code for the LCS MG solver.
    • mglib.f: Application-independent code for the LCS MG solver.
    • mgcom.inc: Defines common block for communication of problem-specific parameters with MG routines
    • lnx_output: Sample build, usage and output on lnx machines
    • Animation of solution for "offset-ellipsoidal-gaussian" initial data: MPEG

Maintained by choptuik@physics.ubc.ca. Supported by CIAR, NSERC, CFI, BCKDF and UBC