Magnetic-flux penetration is theoretically evaluated for superconducting samples of cuboid shape in the critical state. Our variational statement in terms of the electric current density enables a practical algorithm which can efficiently tackle the fully three-dimensional problem. We have obtained the electric- and magnetic-field distributions within the sample. Exotic features of E W, inherent to the three-dimensional nature of the problem, are reported. We show that magnetic hysteresis is easily evaluated within this framework. (c) 2005 American Institute of Physics.