# HYPRE with multiple variables

Allison Baker abaker at llnl.gov
Wed Apr 25 15:44:59 CDT 2007

```Hi Barry and Nicolas,

To clarify,

HYPRE_BoomerAMGSetNumFunctions(solver, int num_functions) tells AMG to
solve a system of equations with the specified number of
functions/unknowns. The default AMG scheme to solve a PDE system is the
"unknown" approach. (The coarsening and interpolation are determined by
looking at each unknown/function independently - therefore you can
imagine that the coarse grids are generally not the same for each
variable. This approach generally works well unless you have strong
coupling between unknowns.)

HYPRE_BOOMERAMGSetNodal(solver, int nodal ) tells AMG to coarsen such
that each variable has the same coarse grid - sometimes this is more
"physical" for a particular problem. The value chosen here for nodal
determines how strength of connection is determined between the coupled
system.  I suggest setting nodal = 1, which uses a Frobenius norm.  This
does NOT tell AMG to use nodal relaxation.

If you want to use nodal relaxation in hypre there are two choices:

(1) If you call  HYPRE_BOOMERAMGSetNodal, then you can additionally do
nodal relaxation via the schwarz smoother option in hypre.  I did not
implement this in the Petsc interface, but it could be done easy enough.
The following four functions need to be called:

HYPRE_BoomerAMGSetSmoothType(solver, 6);
HYPRE_BoomerAMGSetDomainType(solver, 1);
HYPRE_BoomerAMGSetOverlap(solver, 0);
HYPRE_BoomerAMGSetSmoothNumLevels(solver, num_levels);  (Set
num_levels to number of levels on which you  want nodal smoothing, i.e.
1=just the fine grid, 2= fine grid and the grid below, etc.  I find that
doing nodal relaxation on just the finest level is generally
sufficient.)  Note that the interpolation scheme used will be the same
as in the unknown approach - so this is what we call a hybrid systems
method.

(2) You can do both nodal smoothing and a nodal interpolation scheme.
While this is currently implemented in 2.0.0, it is not advertised
(i.e., mentioned at all in the user's manual) because it is not yet
implemented very efficiently (the fine grid matrix is converted to a
block matrix - and both are stored), and we have not found it to be as
effective as advertised elsewhere (this is an area of current research
for us)..... If you want to try it anyway, let me know and I will

Hope this helps,
Allison

Barry Smith wrote:
>   Nicolas,
>
> On Wed, 25 Apr 2007, Nicolas Bathfield wrote:
>
>
>> Dear Barry,
>>
>> Using MatSetBlockSize(A,5) improved my results greatly. Boomemramg is now
>> solving the system of equations.
>>
>
>    Good
>
>
>> Still, the equations I solve are coupled, and my discretization scheme is
>> meant for a non-segregated solver. As a consequence (I believe), boomeramg
>> still diverges.
>>
>
>   How can "Boomeramg be now solving the system of equations" but also
> diverge? I am so confused.
>
>
>>  I would therefore like to use the nodal relaxation in
>> boomeramg (the hypre command is HYPRE_BOOMERAMGSetNodal) in order to
>> couple the coarse grid choice for all my variables.
>>
>
>   I can add this this afternoon.
>
>   I have to admit I do not understand the difference between
> HYPRE_BOOMERAMGSetNodal() and hypre_BoomerAMGSetNumFunctions(). Do you?
>
>    Barry
>
>> How can I achieve this from PETSc?
>>
>> Best regards,
>>
>> Nicolas
>>
>>
>>>   From PETSc MPIAIJ matrices you need to set the block size of the matrix
>>> with MatSetBlockSize(A,5) after you have called MatSetType() or
>>> MatCreateMPIAIJ(). Then HYPRE_BoomerAMGSetNumFunctions() is automatically
>>> called by PETSc.
>>>
>>>    Barry
>>>
>>> The reason this is done this way instead of as
>>> -pc_hypre_boomeramg_block_size <bs> is the idea that hypre will use the
>>> properties of the matrix it is given in building the preconditioner so
>>> the user does not have to pass those properties in seperately directly
>>> to hypre.
>>>
>>>
>>> On Fri, 13 Apr 2007, Shaman Mahmoudi wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> int HYPRE_BoomerAMGSetNumFunctions (.....)
>>>>
>>>> sets the size of the system of PDEs.
>>>>
>>>> With best regards, Shaman Mahmoudi
>>>>
>>>> On Apr 13, 2007, at 2:04 PM, Shaman Mahmoudi wrote:
>>>>
>>>>
>>>>> Hi Nicolas,
>>>>>
>>>>> You are right. hypre has changed a lot since the version I used.
>>>>>
>>>>> I found this interesting information:
>>>>>
>>>>> int HYPRE_BOOMERAMGSetNodal(....)
>>>>>
>>>>> Sets whether to use the nodal systems version. Default is 0.
>>>>>
>>>>>
>>>>> One interesting thing there is this,
>>>>>
>>>>> HYPRE_BoomerAMGSetDomainType(....)
>>>>>
>>>>> 0 - each point is a domain (default)
>>>>> 1 each node is a domain (only of interest in systems AMG)
>>>>> 2 ....
>>>>>
>>>>> I could not find how you define the nodal displacement ordering. But
>>>>>
>>>> it
>>>>
>>>>> should be there somewhere.
>>>>>
>>>>> I read the reference manual for hypre 2.0
>>>>>
>>>>> With best regards, Shaman Mahmoudi
>>>>>
>>>>>
>>>>> On Apr 13, 2007, at 1:40 PM, Nicolas Bathfield wrote:
>>>>>
>>>>>
>>>>>> Dear Shaman,
>>>>>>
>>>>>> As far as I could understand, there is a BoomerAMG?s systems AMG
>>>>>>
>>>> version
>>>>
>>>>>> available. This seems to be exactly what I am looking for, but I
>>>>>>
>>>> just
>>>>
>>>>>> don't know how to access it, either through PETSc or directly.
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Nicolas
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> You want to exploit the structure of the model?
>>>>>>> As far as I know, boomeramg can not treat a set of rows or blocks
>>>>>>>
>>>> as
>>>>
>>>>>>> a molecule,  a so called block-smoother?
>>>>>>> ML 2.0 smoothed aggregation does support it.
>>>>>>>
>>>>>>> With best regards, Shaman Mahmoudi
>>>>>>>
>>>>>>> On Apr 13, 2007, at 10:45 AM, Nicolas Bathfield wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I am solving the Navier-stokes equations and try to use Hypre as
>>>>>>>> preconditioner.
>>>>>>>> Until now, I used PETSc as non-segregated solver and it worked
>>>>>>>> perfectly.
>>>>>>>> Things got worse when I decided to use Boomeramg (Hypre).
>>>>>>>> As I solve a system of PDEs,  each cell is represented by 5 rows
>>>>>>>>
>>>> in my
>>>>
>>>>>>>> matrix (I solve for 5 variables). PETSc handles that without
>>>>>>>>
>>>> problem
>>>>
>>>>>>>> apparently, but the coarsening scheme of Boomeramg needs more
>>>>>>>>
>>>> input in
>>>>
>>>>>>>> order to work properly.
>>>>>>>>
>>>>>>>> Is there an option in PETSc to tell HYPRE that we are dealing
>>>>>>>>
>>>> with a
>>>>
>>>>>>>> system of PDEs? (something like:  -pc_hypre_boomeramg_...)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>>
>>>>>>>> Nicolas
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Nicolas BATHFIELD
>>>>>>>> Chalmers University of Technology
>>>>>>>> Shipping and Marine Technology
>>>>>>>> phone: +46 (0)31 772 1476
>>>>>>>> fax:   +46 (0)31 772 3699
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Nicolas BATHFIELD
>>>>>> Chalmers University of Technology
>>>>>> Shipping and Marine Technology
>>>>>> phone: +46 (0)31 772 1476
>>>>>> fax:   +46 (0)31 772 3699
>>>>>>
>>>>>>
>>
>>
>
>

```