| 1 |
Tests for MueLu::ShiftedLaplacian and Galeri-Helmholtz problems |
| 2 |
|
| 3 |
These tests exercise the functions in Galeri which produce finite difference and |
| 4 |
finite element discretizations of the Helmholtz equation on uniform quad/hex meshes. |
| 5 |
The model problem is an infinite domain homogeneous medium; the boundary conditions |
| 6 |
used to simulate the infinite domain are perfectly matched layers (on all sides). |
| 7 |
The matrices and right hand sides are fed to MueLu::ShiftedLaplacian, which solves |
| 8 |
the systems using MueLu as a preconditioner to Belos. The algebraic multigrid is set |
| 9 |
up in a few different ways, and for each method, certain matrices need to be set. |
| 10 |
|
| 11 |
In the following, it is assumed that for a stiffness matrix K, mass matrix M, |
| 12 |
and angular frequency omega, the Helmholtz operator is A = K - \omega^2 M, and |
| 13 |
the Shifted Laplacian operator is S = K - (1+ i \beta) (\omega^2) M. |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
1. For higher frequency problems, we suggest using Shifted Laplacians where the prolongation |
| 18 |
and restriction matrices are produced using the stiffness matrix; The reason the stiffness |
| 19 |
matrix is used is because it produces prolongation/restriction matrices for the Laplacian, |
| 20 |
i.e. the smoothed-aggregation basis functions look similar to geometric multigrid. This method |
| 21 |
can be done with either setupFastRAP() or setupSlowRAP(). In setupFastRAP(), the complex shift |
| 22 |
added to the Helmholtz operator for damping is the same at every level of the multigrid |
| 23 |
hierarchy, while in setupSlowRAP(), the complex shift can be varied. The initialization is the |
| 24 |
same for both methods: |
| 25 |
|
| 26 |
SLSolver = Teuchos::rcp( new MueLu::ShiftedLaplacian() ); |
| 27 |
SLSolver -> setstiff(...); |
| 28 |
SLSolver -> setParameters(...); |
| 29 |
SLSolver -> initialize(); |
| 30 |
|
| 31 |
This will construct the prolongation/restriction matrices with the stiffness matrix |
| 32 |
(which you put in through the setstiff() function). Now, once the Helmholtz operator |
| 33 |
and Shifted Laplacian operator are constructed, do the following for setupFastRAP(): |
| 34 |
|
| 35 |
SLSolver -> setProblemMatrix(...); |
| 36 |
SLSolver -> setPreconditioningMatrix(...); |
| 37 |
SLSolver -> setupFastRAP(); |
| 38 |
|
| 39 |
This will setup the level smoothers for multigrid, and also setup the Belos iterative |
| 40 |
solver with MueLu as the preconditioner. For setupSlowRAP(), the mass matrix and level |
| 41 |
complex shifts need to be defined; thus, the calls for setupSlowRAP() should go |
| 42 |
|
| 43 |
SLSolver -> setProblemMatrix(...); |
| 44 |
SLSolver -> setPreconditioningMatrix(...); |
| 45 |
SLSolver -> setmass(...); |
| 46 |
SLSolver -> setLevelShifts(...); |
| 47 |
SLSolver -> setupSlowRAP(); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
2. For lower frequency problems, regular smoothed-aggregation AMG for the Shifted Laplacian |
| 52 |
should suffice. This can be done with setupNormalRAP(). The calls for this mode are |
| 53 |
|
| 54 |
SLSolver = Teuchos::rcp( new MueLu::ShiftedLaplacian() ); |
| 55 |
SLSolver -> setPreconditioningMatrix(Pmat); |
| 56 |
SLSolver -> initialize(); |
| 57 |
SLSolver -> setProblemMatrix(Amat); |
| 58 |
SLSolver -> setupNormalRAP(); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
3. Once you've called setupSlowRAP(), setupFastRAP(), or setupNormalRAP(), you can solve for |
| 63 |
any RHS multivector using the solve function: |
| 64 |
|
| 65 |
SLSolver -> solve(B,X); |
| 66 |
|
| 67 |
Where B is the right hand side vector, and X is the solution vector. |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
4. For multiple frequencies, a sequence of linear systems needs to be solved. In this case, |
| 72 |
setupFastRAP() or setupSlowRAP() modes are best, since they keep the prolongation and restriction |
| 73 |
matrices around; this is because the stiffness matrix does not change even if the frequency |
| 74 |
changes. Thus, you should only call the initialize() function once for a multiple frequency |
| 75 |
problem; the calls to the Shifted Laplacian solver and loop over the frequencies should look |
| 76 |
like this: |
| 77 |
|
| 78 |
SLSolver = Teuchos::rcp( new MueLu::ShiftedLaplacian() ); |
| 79 |
SLSolver -> setstiff(...); |
| 80 |
SLSolver -> setParameters(...); |
| 81 |
SLSolver -> initialize(); |
| 82 |
|
| 83 |
for( int i=0; i < num_omegas; i++) { |
| 84 |
|
| 85 |
...(construct Helmholtz and Shifted Laplacian matrices)... |
| 86 |
SLSolver -> setProblemMatrix(...); |
| 87 |
SLSolver -> setPreconditioningMatrix(...); |
| 88 |
SLSolver -> setupFastRAP(); |
| 89 |
...(compute right hand side)... |
| 90 |
SLSolver -> solve(B,X); |
| 91 |
|
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
5. A summary of the tests: |
| 97 |
Helmholtz1D.cpp -> finite differences in 1D, regular AMG, one frequency |
| 98 |
Helmholtz2D.cpp -> finite differences in 2D, setupSlowRAP(), solves for multiple frequencies |
| 99 |
Helmholtz3D.cpp -> finite differences in 3D, setupNormalRAP(), one frequency |
| 100 |
HelmholtzFEM2D.cpp -> finite elements in 2D, setupFastRAP(), one frequency |
| 101 |
HelmholtzFEM3D.cpp -> finite elements in 3D, setupNormalRAP(), one frequency |