We present a machine learning-based mesh refinement technique for steady and unsteady incompressible flows. The clustering technique proposed by Otmani et al. (Phys Fluids 35(2):027112, 2023) is used to mark the viscous and turbulent regions for the flow past a cylinder at $$Re=40$$
R
e
=
40
(steady laminar flow), at $$Re=100$$
R
e
=
100
(unsteady laminar flow), and at $$Re=3900$$
R
e
=
3900
(unsteady turbulent flow). Within this clustered region, we use high mesh resolution, while downgrading the resolution outside, to show that it is possible to obtain levels of accuracy similar to those obtained when using a uniformly refined mesh. The mesh adaptation is effective, as the clustering successfully identifies the two flow regions, a viscous/turbulent dominated region (including the boundary layer and wake) that requires high resolution and an inviscid/irrotational region, which only requires low resolution. The new clustering sensor is compared with traditional feature-based sensors (Q-criterion and vorticity based) commonly used for mesh adaptation. Unlike traditional sensors that rely on problem-dependent thresholds, our novel approach eliminates the need for such thresholds and locates the regions that require adaptation. After the initial validation using flows past cylinders, the clustering technique is applied in an engineering context to study the flow around a horizontal axis wind turbine configuration which has been tested experimentally at the Norwegian University of Science and Technology. The data used within this framework are generated using a high-order discontinuous Galerkin solver, allowing to locally refine the polynomial order (p-refinement) in each element of the clustered region. For the laminar test cases, we can reduce the computational cost by 32% (steady $$Re=40$$
R
e
=
40
case) and 20% (unsteady $$Re=100$$
R
e
=
100
case), while we get a reduction of 33% for the $$Re=3900$$
R
e
=
3900
turbulent case. In the context of the wind turbine, a reduction of 43% in computational cost is observed, while maintaining the accuracy.