TRIPIC: Triangular-mesh particle-in-cell code. A particle-in-cell code is developed making use of triangular space meshes. It is applied to study a self-consistent interaction between charged particles and a magnetostatic field. In the TRIPIC code the relativistic equation of motion is solved and the interaction between particles and space meshes is accomplished by a simple method. A subroutine of a magnetostatic field solver is based on a method developed by Winslow. An example of the charged-particle motion is presented for a barrel type of the light-ion beam diode.