A two-layer model for coupled three-dimensional viscous and inviscid flow calculations