Three-dimensional particle-in-cell modeling of terahertz gyrotrons with cylindrical and planar configurations of the interaction space