Programming exercises and homework 217
approach allows us to reach computer accuracy solution within a finite amount
of iterations, even for very large viscosity contrasts (Fig. 14.13). An example
of using such algorithm (Fig.14.13) is given in the program Variable_viscosity_
MultiMultigrid_arbitrary.m.
Finally, it is also important to mention that besides large viscosity contrasts,
further convergence problems can be caused by strongly irregular grid spacing, by
significant differences in grid spacing used for different dimensions, by strong (e.g.
plastic) localisation of deformation characterising a mechanical solution at the finest
grid which is not captured on coarser levels etc. Therefore, be prepared that some
of your thermomechanical models which utilise multigrid will be ‘demanding’,
and will require special efforts in tuning and adjusting the iteration procedures.
Programming exercises and homework
Exercise 14.1
Program the multigrid solution based on a V-cycle for solving the Poisson equation
in 2D for the case of a circular planetary body embedded in a mass less-like
medium (Eqs. (14.6)–(14.16), Figs. 14.6–14.7). Use a ghost-node approach to
define the boundary conditions =0, along a circular boundary located at a
distance from the planet. Program a Poisson equation smoother based on Gauss–
Seidel iteration (Exercise 3.3 for Chapter 3) as an external MATLAB function and
call it for different levels of resolution. Program external functions for restriction
(Eq. (8.18), Fig. 8.8) and prolongation (Eq. (8.19), Fig. 8.9) operations to be
called for different multigrid levels. Model parameters: radius of the planet =
6000 km, density of the planet = 6000 kg/m
3
, model size = 18000 ×18000 km,
radius for gravity potential boundary = 8999 km, number of resolution levels =
4, resolution on the coarsest (last) grid = 7 ×7 nodal points, factor of increase in
resolution between the levels =2, relaxation coefficient for Gauss–Seidel iterations,
θ
Poisson
relaxation
= 1.5, number of smoothing iterations on the finest level = 5, factor of
increase in the number of iterations with the level coarsening =2. An example is in
Poisson_Multigrid_planet.m.
Exercise 14.2
Program a multigrid solution for solving the Stokes and continuity equations in 2D
for a constant viscosity case using a pressure–velocity formulation and a ghost-
node approach (Eqs. (14.20)–(14.44), Figs. 14.8–14.9). The setup corresponds to a
dense rectangular block sinking in the lower density medium. Model parameters:
model size = 100 ×100 km, block size =20 ×20 km (located in the middle of the
model), block density = 3100 kg/m
3
, medium density = 3000 kg/m
3
, acceleration
of gravity (vertical) =9.81 m/s
2
, model viscosity =10
20
Pa s, boundary conditions