A finite element discretization for two-dimensional MHD is described. The e
lements are triangles with piecewise linear basis functions. The main compu
tational difficulty is the accurate calculation of the current. The most ef
fective solution is to employ a current-vorticity advection formulation of
the equations. Acceptable results can also be obtained with a two-step calc
ulation of the current from the vector potential. Mesh operations are descr
ibed to reconnect and refine the mesh adaptively in the vicinity of nearly
singular currents to improve magnetic flux conservation. Example computatio
ns of the coalescence instability, tilt mode, and divertor tokamak equilibr
ium, validating and illustrating the method, are presented. The simulations
show the formation of current sheets, with the current density increasing
exponentially in time. During this increase, the grid of initially similar
to 10(4) points adapts to provide resolution comparable to a uniform grid o
f up to 1.6 x 10(8) grid points. (C) 1998 Academic Press.