An object-oriented approach to the DSMC method

A Direct Simulation Monte Carlo (DSMC) code has been developed in Java 2, based on the original FORTRAN DSMC code of G.A. Bird [1] and extensions to it by Anderson and Dunn [2] and Long and Anderson [3]. Although these FORTRAN codes perform quite well, conversion to Java satisfies an initiative to develop a more maintainable DSMC code while retaining a high-performance numerical solution to rarefied gas dynamics problems. The code discussed in this paper was compiled using both GNU GCJ and Sun's Java Development Kit. Both serial and parallel performance testing showed this code to be comparable to the FORTRAN codes in all cases.By using Java's Vector foundation class, a method for creating one-dimensional, dynamically allocatable arrays, the complicated sort routine found in traditional DSMC codes [1] is greatly simplified. In an object oriented approach to DSMC calculations, it would be sensible for the domain object to have ownership of all of the cell objects, which in turn have ownership of a number of particle objects. Since particles are constantly moving from one cell to another, a constant-length array of particles in each cell is not a possibility. The traditional means of circumventing this problem is to allow the domain object to have ownership of all cell and particle objects and the DSMC methodology is applied as it would be in a procedural programming approach.It is proposed herein that the Vector class be used to store the particle objects, inside of the cell objects, essentially moving the responsibility of carrying out the move and collide computations from the domain object to the cell objects. The computational overhead associated with this change is minimal compared to the overall runtime since the decrease in operations required by the new sort routine helps to counterbalance the CPU time required for array-resizing. Although there is no immediate performance advantage, significant gains are made insofar as code readability and maintainability by eliminating the long series of complicated integer array computations contained in the traditional sort routine. The performance of the new code is explored in Figure 1 and is shown to be similar in performance to the baseline F-90 codes and even superior on some architectures. A more complete description of the performance testing exists in [4] and [5].In general, the DSMC method may have impractically large memory and CPU time requirements, in which case, a domain decomposition style parallelization strategy must be employed on large distributed memory systems. However, for the simple 2-D geometries discussed here, where the memory requirements are fairly low, a solution may be obtained by using a much simpler parallelization strategy. The ensemble-averaging technique used by all time- accurate DSMC codes motivates the implementation of a parallelization strategy based on the multiple serial jobs approach of [6]. Java multithreading is used to distribute the workload without the added complexity of MPI or OpenMP.Parallel performance was good, with demonstrated parallel efficiencies of around 75% for the two and four-processors cases tested. Although larger scale parallel jobs have yet to be tested, the outlook is favorable, since there is minimal communication involved in the algorithm, suggesting that a nearly ideal parallel speedup should be obtainable, even for massively parallel jobs.