# AMG preconditioning with physically distinct entities

Asked by Nico Schlömer on 2013-03-21

(This topic came up before in https://answers.launchpad.net/dolfin/+question/210832 but we somehow got carried away.)

This came up when solving a complex-valued problem with Dolfin. As is known, Dolfin doesn't support complex scalars, so the problem has to be converted into a real-imaginary formulation first. What comes out of this is a 2x2-block matrix (meaning that the matrix is made up from tiny little 2x2 blocks). Those type of block matrices come up whenever there are multidimensional entities living on the vertices (e.g., vectors).

What geometric multigrid naturally avoids is a mixing of the values of any of those separate entities, and AMG typically wants to do the same thing. Trilinos' ML has the option "PDE equations" for this; not sure about PETSc.

I suppose the easiest way to address this is would be to expose that option to the user.

I suppose it would also be possible to have this parameter automatically set by determining the (geometric) dimension of the space of test/trial functions.

## Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Nico Schlömer
Solved:
2013-03-23
Last query:
2013-03-23
2013-03-23
 Jan Blechta (blechta) said on 2013-03-21: #1

is this what are you searching for?

virtual void GenericPreconditioner::set_coordinates(const std::vector<double>& x, std::size_t dim)

 Garth Wells (garth-wells) said on 2013-03-23: #2

On 22 March 2013 06:06, Nico Schlömer
> New question #224865 on DOLFIN:
>
> (This topic came up before in https://answers.launchpad.net/dolfin/+question/210832 but we somehow got carried away.)
>
> This came up when solving a complex-valued problem with Dolfin. As is known, Dolfin doesn't support complex scalars, so the problem has to be converted into a real-imaginary formulation first. What comes out of this is a 2x2-block matrix (meaning that the matrix is made up from tiny little 2x2 blocks). Those type of block matrices come up whenever there are multidimensional entities living on the vertices (e.g., vectors).
>
> What geometric multigrid naturally avoids is a mixing of the values of any of those separate entities, and AMG typically wants to do the same thing. Trilinos' ML has the option "PDE equations" for this; not sure about PETSc.
>

I added some magic to DofMap a week or two ago to preserve blocks. I
tested it for elasticity. It needs to be checked for other equations.
Look in DofMap for a function called something like
compute_block_size.

> I suppose the easiest way to address this is would be to expose that option to the user.
>

You can pass a Teuchos::ParameterList to ML. The interface might not
be polished.

> I suppose it would also be possible to have this parameter automatically set by determining the (geometric) dimension of the space of test/trial functions.
>

Via PETSc, if the dofmap is blocked then this is set in the PETSc
matrix. I believe that PETSc passes this block info to ML. It
dramatically reduced to cost of the preconditioner construction.

You'll need to set the nullspace for ML. There are some handy
functions for this in DofMap.

I'll add a demo soon that uses smoothed aggregation AMG with setting
of the nullspace, block size, etc.

Garth

> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

 Nico Schlömer (nschloe) said on 2013-03-23: #3

> You can pass a Teuchos::ParameterList to ML. The interface might not be polished.

Found that, thanks! I was able to cut the number of Krylov iterations in half, in some cases even better, by setting "PDE equations" to 2.

> I added some magic to DofMap a week or two ago to preserve blocks. I tested it for elasticity. It needs to be checked for other equations.

I checked with my "complex-valued" problem, block size 2, and it's working well.

> I'll add a demo soon that uses smoothed aggregation AMG with setting of the nullspace, block size, etc.

That'd be perfect.