AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
540 stars 344 forks source link

Linear Solver for quasi-singular equation #452

Closed mzl13 closed 5 years ago

mzl13 commented 5 years ago

I'm solving a equation del dot b grad phi = rhs by using Linear solver. In a 2D domain, rhs = 0, b = 1e7 in the right and b = 1 in the left, whose interface is defined by another multifab. I found the convergence of the equation is fable as high sigularity. Is there any method to solve the problem? like adding a mask or other method.
Thanks!

WeiqunZhang commented 5 years ago

Geometry multigrid methods may have difficulties when there are big jumps in the b coefficient. You may try Hypre's BoomerAMG, an algebraic multigrid method. See amrex/Tutorials/LinearSolvers/ABecLaplacian_C/ for an example. Compile with USE_HYPRE=TRUE. You can add the following to the inputs file there.

use_hypre = 1
max_coarsening_level = 0  # send the problem to hypre without coarsening
hypre_interface = 3             # IJ Matrix interface
GumpXiaoli commented 5 years ago

Weiqun, when building the matrix A, can AMReX mask the area where b is too large or too small?

WeiqunZhang commented 5 years ago

I don't understand what this means. Suppose there are 2 x 2 cells in a 2D domain and you want to mask out the lower left cell. What does the linear system look like after the mask is applied? What's the size of the matrix?

GumpXiaoli commented 5 years ago

Yes, i wonder can we just solve then right part since it's highly possible that the solution of left part is the same with the left boundary for mzl13's case. Therefore, i think we don't need to solve the left part explicitly.

In my understanding, multigrid just solve Ax=b where A is N^2*N^2. In your above mentioned case, the A's size may be 2*2. For now, I can't find where the A matrix is built in AMReX.

drummerdoc commented 5 years ago

Weiqun was trying to have you specify a simple problem in order to be specific about "masking" out cells. In his question, assume the entire linear algebra problem has four unknowns, arranged on a 2x2 grid in 2D. If this was a "regular" problem, each cell of the 4 cells would satisfy a conservation equation. You have proposed to "mask" some of the cells out of the system solve. What does that do to the equations for the cells whose stencils involve that "masked out" cell/unknown, and how is this a solution to the original problem?

Where is the matrix? Normally, AMReX implements a geometric multigrid algorithm to solve linear systems, and the "matrix" appears in the code in the form of an "operator". The operator class takes an input state living on the cell-centered problem domain, and computes the action of the operator...conceptually this is a matrix-times-vector operation, but it is not stored/computed that way in GMG - it looks more like transport coefficients and flux divergences. That said, there are options to AMReX's GMG solver algorithm, including the "bottom solve" for the coarsest problem in a mg V-cycle hierarchy, where the operator can be converted explicitly into some kind of matrix format and the Ax=b problem can be passed to a different linear solver package to get the solution vector, x. The bottom solves or the entire problems can be translated and passed off this way, but that is a special operation explicitly requested by the user.