Formulation of a variable-function three-dimensional model, with applications to the M2 and M4 tide on the North-West European Continental Shelf