We present a method for calculating space-charge forces suitable for use in a particle tracing code. We solve Poisson's equation in three dimensions with boundary conditions specified on an arbitrary surface by using a weighted residual method. Using a discrete particle distribution as our source input, examples are shown of off-axis, bunched beams of noncircular crosssection in radio-frequency quadrupole (RFQ) and drift-tube linac geometries.