  Direct numerical simulations are used to elucidate the interplay of
wettability and fluid viscosities on immiscible fluid displacements in a
heterogeneous porous medium.We classify the flow regimes based using
qualitative and quantitative analysis into viscous fingering (low $M$), compact
displacement (high $M$), and an intermediate transition regime ($M \approx 1$).
We use stability analysis to obtain theoretical phase boundaries between these
regimes, which agree well with our analyses. At the macroscopic (sample) scale,
we find that wettability strongly controls the threshold $M$ (at which the
regimes change). At the pore scale, wettability alters the dominant
pore-filling mechanism. At very small $M$ (viscous fingering regime), smaller
pore spaces are preferentially invaded during imbibition, with flow of films of
invading fluid along the pore walls. In contrast, during drainage, bursts
result in filling of pores irrespective of their size. As $M$ increases, the
effect of wettability decreases as cooperative filling becomes the dominant
mechanism regardless of wettability. This suggest that for imbibition at a
given contact angle, decreasing $M$ is associated with change in effective
wetting from neutral-wet (cooperative filling) to strong-wet (film flow).
