4.1 The direct method

The most direct method of solving the wave equation with RNPL is by implementing the auxiliary functions as grid functions. Sample code can be found here, but as mentioned before this method is generally not good practice as the program will use considerably more RAM than by declaring the auxiliary functions in an external file. However, the direct method can be used successfully when the number of auxiliary functions is small and memory constraints are not a problem.

The auxiliary functions are updated by metricandsource.inc and initialized in the RNPL source file. Thus, when changing the metric, it is necessary to replace both the include file and the auxiliary function initialization in WKG_rnpl. Sample metrics for Minkowski space and for compactified Minkowski space can be found in the two folders. They contain code that can be copy-pasted straight in the main folder and in the RNPL source.

The sample code has Dirichlet boundary conditions, in that phi and mu are set to 0 on the boundaries of the domain. Also, the current implementation uses a Kreiss-Oliger dissipation operator, which is only defined for points (px, py, pz) with 2 < pi < Ni - 1. The Kreiss-Oliger operator dissipates the high-frequency modes, essentially acting like a low-pass filter. Because of the introduction of the KO operator, the spatial domain has been split into three subdomains: an outer shell on which the grid functions are set to 0, an inner shell on which the evolution equations take their usual form, but there is no dissipation operator, and the bulk of the region, consisting of points (px, py, pz) with 2 < pi < Ni - 1, on which the evolution equations take their usual form and there is also dissipation.

A final note: As seen from the mathematical introduction, the residual formula for mu is quite long. For ease of implementation, it has been divided into 7 terms, T1 through T7, which are given in this document. The residual formula in the RNPL source has also been split into these terms.

4.2 Using an external file

When using many grid functions, it may be convenient to move the auxiliary functions to external files, to reduce memory usage. Due to the exponential nature of memory usage this will not provide a substantial increase in performance, but it may nonetheless be desirable in certain situations. A sample RNPL program which solves the wave equation using external auxiliary functions can be downloaded here.

The source file of this program contains four grid functions: phi, mu RHSphi and RHSmu. RHSphi and RHSmu are the right hand sides of the residual equations, and they are updated in the rhs.inc include file. The metric is stored in the metrics.f file and it is called with the function getmet(). To call a desired metric, simply change that metric's name to getmet. Note how the make file has been modified to include rhs.inc and to compile metrics.f as well.

In the RNPL source file, the updates of all the grid functions are called with the sequence:

auto update phi, mu

rhs.inc update_rhs updates RHSphi, RHSmu

header RHSphi, RHSmu, phi, mu, t, x, y, z, dx, dy, dz, dt

Note: To execute the iterative convergence mechanism properly, the updates of RHSphi and RHSmu must be called after the updates of phi and mu are called. When implementing external file schemes, it is a common mistake to call them in opposite order, which results in the program always converging in one iteration. Make sure you don't do this.

Some of the material presented on this web page is based upon work supported in part by the Princeton Applied and Computational Mathematics Program and by the National Science Foundation under Grant No. 0745779.