KyleVaughn / UM2

An unstructured mesh library for automated method of characteristic mesh generation
https://univeristy-of-michigan-unstructured-mesh-code.readthedocs.io/en/main/index.html#
MIT License
7 stars 2 forks source link

Accelerate the computation of 1D, 1 group CMFD spectral radius #157

Open KyleVaughn opened 3 months ago

KyleVaughn commented 3 months ago

It currently takes far too long to compute the spectral radius data for problems with a large number of unique coarse cells. https://github.com/KyleVaughn/UM2/issues/153 should help with this issue, but it does not eliminate the need for faster computation of these values.

Potential solutions

1) Parallelism

The current implementation computes each of the spectral radii one at a time. It should be possible to restructure the code to allow a simple #pragma omp parallel for to speed up the computation. However, one should by wary of each thread calling BLAS routines, which are multithreaded by default.

2) Small Fixed-size matrix operations (Mat)

To predict the spectral radius of 2D multigroup CMFD, we compute the 1D, 1 group CMFD spectral radius for each coarse cell at each energy. The process of finding the 1D spectral radius boils down to a few matrix operations, solving a linear system, and solving for the eigenvalues of a matrix.

Technically, the matrix size should be proportional to the number of fine cells per coarse cell. However, since number of fine cells only marginally changes spectral radius beyond num_fine_cells = 4, but the matrix operations become prohibitively expensive, we always solve for the case of num_fine_cells = 4.

But, since the implementation was designed to handle arbitrarily large matrices, the matrix operations all use BLAS, which has unnecessary overhead for small, fixed size matrices. As an example, 4 by 4 matrix multiplication with BLAS is around 60 times slower than the naive implementation with matrices whose size is known at compile time.

Therefore, it would be beneficial to shift one or more of the matrix operations from the Matrix class to the Mat4x4 class.