Skip to content

multigrid.f90

Jonathan Thurgood edited this page Dec 21, 2018 · 1 revision

Overview

This module solves elliptic equations on a 2D, cartesian cell-centred finite volume grid using an efficient algorithm based on multigrid V cycles. It currently implements:

  • Poisson L phi = f
  • Constant coefficient Helmholtz (alpha - beta L) phi(x,y) = f(x,y)
  • Variable coefficient D (eta(x,y) G) phi(x,y) = f(x,y)

The grid need not be square (Lx /= Ly) but cells must be square (dx == dy) and the number of cells (in both directions or just the shortest?) nx and ny must be a power of two.

There is some shared-memory parallelisation with OpenMP (fairly basic and naiive implementation, but with measurable gains).

Using the multigrid solver

The calling program use multigrid and be linked appropriately during compilation. It interacts with the multigrid solver through an object type, public :: mg_input

The user sets the module state (all arguments etc) through constructing this object, e.g.

input_and_output = mg_input(tol = 1e-12_num, nx=nx, ny = ny, dx=dx, dy=dy, f = divu, phi = phi, &
            & bc_xmin = 'periodic', bc_ymin='periodic', bc_xmax='periodic', bc_ymax = 'periodic')

And then solves by passing that object as the argument to the public interface

call mg_interface(input_and_output)

The output is passed back to that object, so then the code will need to put the output where it wants it, e.g.

phi = input_and_output%phi

I'll flesh out the wiki later but to see options for the input have a look at the various tests in the multigrid directory and the multigrid source itself.

Tests

Clone this wiki locally