Physics-consistent machine learning: output projection onto physical manifolds