In the de Broglie–Bohm formulation of quantum mechanics the time-dependent Schrödinger equation is solved in terms of quantum trajectories evolving under the influence of quantum and classical potentials. For a practical implementation that scales favorably with system size and is accurate for semiclassical systems, we use approximate quantum potentials. Recently, we have shown that optimization of the nonclassical component of the momentum operator in terms of fitting functions leads to the energy-conserving approximate quantum potential. In particular, linear fitting functions give the exact time evolution of a Gaussian wave packet in a locally quadratic potential and can describe the dominant quantum-mechanical effects in the semiclassical scattering problems of nuclear dynamics. In this paper we formulate the Bohmian dynamics on subspaces and define the energy-conserving approximate quantum potential in terms of optimized nonclassical momentum, extended to include the domain boundary functions. This generalization allows a better description of the non-Gaussian wave packets and general potentials in terms of simple fitting functions. The optimization is performed independently for each domain and each dimension. For linear fitting functions optimal parameters are expressed in terms of the first and second moments of the trajectory distribution. Examples are given for one-dimensional anharmonic systems and for the collinear hydrogen exchange reaction.