The main contribution of this paper is a procedure for the control by energy shaping via Casimir generation of high-order port-Hamiltonian systems obtained from the spatial discretization of infinite dimensional dynamics. Beside the intrinsic difficulties related to the large number of state variables, the finite element model is generally given in terms of a Dirac structure and is completely a-causal, which implies that the plant dynamics is not given in standard input-state-output form, but as a set of DAEs. Consequently, the classical energy-Casimir method has to be extended in order to deal with dynamical systems with constraints, usually appearing in the form of Lagrangian multipliers. The methodology is illustrated with reference to a particular example, i.e. an hinged-hinged Timoshenko beam with torque actuators at both sides.