We present the theory, algorithms and implementation of a parallel
finite-volume algorithm for the solution of the incompressible
magnetohydrodynamic (MHD) equations using unstructured grids that are
applicable for a wide variety of geometries. Our method implements a mixed
Adams-Bashforth/Crank-Nicolson scheme for the nonlinear terms in the MHD
equations and we prove that it is stable independent of the time step. To
ensure that the solenoidal condition is met for the magnetic field, we use a
method whereby a pseudo-pressure is introduced into the induction equation;
since we are concerned with incompressible flows, the resulting Poisson
equation for the pseudo-pressure is solved alongside the equivalent Poisson
problem for the velocity field. We validate our code in a variety of geometries
including periodic boxes, spheres, spherical shells, spheroids and ellipsoids;
for the finite geometries we implement the so-called ferromagnetic or
pseudo-vacuum boundary conditions appropriate for a surrounding medium with
infinite magnetic permeability. This implies that the magnetic field must be
purely perpendicular to the boundary. We present a number of comparisons
against previous results and against analytical solutions, which verify the
code's accuracy. This documents the code's reliability as a prelude to its use
in more difficult problems. We finally present a new simple drifting solution
for thermal convection in a spherical shell that successfully sustains a
magnetic field of simple geometry. By dint of its rapid stabilization from the
given initial conditions, we deem it suitable as a benchmark against which
other self-consistent dynamo codes can be tested