1 Introduction

Computational fluid dynamics (CFD) seeks to simulate flow phenomena accurately at a minimum computational cost. To achieve this goal, local refinement is used to increase the quality of the mesh in some targeted elements (e.g., with large gradients). This can be achieved by increasing the number of elements in the targeted region, or in the context of high-order solvers, by locally increasing the polynomial order of approximation. Local adaptation allows to reduce the number of degrees of freedom (DoF) and the associated simulation cost while increasing the solution accuracy only in the regions of interest of the flow. The detection of the regions that require refinement is not always straightforward but can sometimes be predicted by our physical knowledge of the problem. This is the case for flows where viscous and turbulent regions can be clearly separated from inviscid regions. Flows belonging to this category include bluff bodies (e.g., cylinders) and aerodynamical shapes (e.g., airfoils). In these types of flows, the boundary layer and wake require local mesh refinement, while the potential flow regions, away from walls and the wake, can be resolved using a coarser mesh resolution.

To perform local refinement, it is necessary to define some criteria that will identify the location and the level of refinement required. These sensors can be classified, see [2], into three distinct categories. The feature-based indicators [3,4,5,6,7], the local error-based indicators [8,9,10] and the goal-oriented indicators [11,12,13]. The feature-based indicators are deduced from physical or theoretical properties of the flow, and by observation of how these influence the different aerodynamical quantities (e.g., lift, drag). These methods are deemed as inexpensive and straightforward to implement, but typically lack robustness and can be case-dependent. The second group of indicators, the local error-based, identifies regions that need to be refined depending on high values of quantified error. This can be defined as the difference between the numerical and the exact solution (or an approximation of it). It requires the solution in various levels of meshes and can become relatively expensive before reaching a suitable numerical setup. Goal-oriented indicators evaluate the contribution of the error related to a specific target functional (e.g., adjoint-based), but it is costly, as a new system of equations needs to be solved.

In this work, we concentrate on the first approach, the feature-based adaptation, since it constitutes a cost-effective method of locating the regions of interest and adjusting the local number of degrees of freedom. We propose a new robust methodology, which removes some of the drawbacks of feature-based methods. For instance, one of the drawbacks of feature-based adaptation is the use of sensors that relate to physical quantities. In these cases, an arbitrary threshold needs to be selected to define the isosurface based on the feature. That is, the isosurface defines the boundary between the regions that require refinement and coarsening in the domain. The threshold defining the isosurface is an arbitrary user-defined value that can be problem dependent, as it varies based on the specific characteristics of the flow under consideration. Feature-based adaptation typically needs an iterative trial-and-error process to define a suitable threshold parameter and to obtain convergence in the aerodynamic functionals (e.g., lift, drag). This paper employs a machine learning-based methodology to select refinement regions while avoiding the iterative process needed to specify them.

The development and use of machine learning (ML) techniques in the past decade is widespread within the natural sciences and engineering [14,15,16]. The field of CFD is no exception, and many examples of the successful coupling of ML with CFD have been presented. The current status and future perspectives of machine learning in the context of fluid mechanics have been covered in Refs [16,17,18,19,20]. Specifically, on the topic of flow region recognition, ML and CFD have been combined using a supervised machine learning-based framework [21] to identify the flow state (turbulent or non-turbulent flow). Different training datasets at different Reynolds numbers are used to train Extreme Gradient Boosting (XGBoost). This model can efficiently generate a robust detector for identifying turbulent regions for a flow past a circular cylinder. In the same context, a machine learning algorithm has been used in [22] to distinguish the grid cells that contain part of the boundary layer, shock waves, or external inviscid flow from RANS solutions.

Within the framework of mesh adaptation, Manevitz et al. [23] investigated the application of neural network time series forecasting for finite element mesh adaptation. More recently, Chen and Fidkowski [24] introduced artificial neural networks to perform h-adaptation by predicting the desired element aspect ratio from readily accessible features of primal and adjoint solutions. The neural network models not only reproduced the correct anisotropy for the cases in the training data set, but also could generalize to flow fields not considered during training. In [25] the same authors focused on output-based adaptive aerodynamic simulations using convolutional neural networks. Similarly, Wallwork et al. [26], introduced a data-driven goal-oriented mesh adaptation approach, using a neural network to replace the expensive error estimation step in adaptive simulations. Bohn and Feischl [27] showed that recurrent neural networks can learn an optimal mesh refinement algorithm for elliptic PDEs. Yang et al. [28] introduced a method for h-refinement that employs a feedforward neural network for adaptive mesh refinement. Gillette et al. [29] studied the robustness of marking policies for adaptive mesh refinement in the context of the Poisson equation.

In this work, we study the capabilities of the clustering technique developed in [1] as a sensor for mesh adaptation. This technique effectively separates the flow into two distinct regions: a region dominated by viscosity and turbulence (boundary layer and wake region) and an inviscid, irrotational region (outer flow region). The clustering technique demonstrates its effectiveness in reducing the computational cost of simulations, as showcased by the numerical experiments conducted in this paper, on both turbulent and laminar test cases. Furthermore, the Gaussian mixture model (GMM), utilized in conjunction with the feature space described in [1], operates without the need for any parameters or thresholds, eliminating the requirement for fine-tuning. Through a comparative analysis between our new sensor and traditional feature-based sensors (that is, the Q-criterion [30] and the new \(\Omega\) method [31]), our objective is to emphasize the advantages and improvements provided by our approach. Eliminating problem-dependent threshold values improves the applicability and robustness of our sensor, resulting in a more efficient and reliable mesh adaptation technique.

The viscous-dominated region requires a finer mesh than the inviscid region. Therefore, we propose to use a high-order polynomial approximation to solve the viscous-dominated region and a low-order polynomial approximation for the inviscid region. The aim is to accurately predict the flow features and get an equivalent solution to that of a uniform high polynomial order at a reduced cost. One advantage of having only two regions is that the computational overhead related to mortar computation is reduced (compared to other techniques that use different polynomial orders for every element in the domain [8, 32, 33]). Additionally, the clustering-adaptation is performed only once, when the flow is developed (for steady and unsteady simulations). This simplifies the load-balancing process required for parallel computations.

The rest of this paper is organized as follows. Initially, we present the methodology in Sect. 2, including the clustering technique and the adaptation algorithm. Then, in Sect. 3, we present the validation results for the flow past a cylinder at \(Re=40\) (steady laminar regime), \(Re=100\) (unsteady laminar regime) and \(Re=3900\) (unsteady turbulent regime). After the validation process, the clustering technique is used in an engineering context to investigate the flow around a wind turbine in Sect. 4.

2 Methodology

In this section, we first introduce several flow sensors commonly utilized for mesh adaptation in the literature (i.e., Q-criterion and vorticity based). Additionally, we will challenge a recently developed clustering technique that has been hypothesized to be effective for mesh adaptation. This technique enables the separation of the flow field into two distinct regions: viscous/rotational (viscous + turbulent) and inviscid/irrotational (potential flow), without the need for user-defined thresholds. Subsequently, we outline a methodology for mesh adaptation based on this clustering technique.

2.1 Feature-based mesh adaptation sensors

  • The Q-criterion, first introduced in [30], is the first sensor to be considered for comparison. This sensor utilizes the rotational and strain rate tensors and can be defined in non-dimensional form; see [6], as:

    $$\begin{aligned} f=\frac{1}{2}\left( \frac{||\mathbf {\Omega }||^2}{||\textbf{S}||^2}-1\right) . \end{aligned}$$
    (1)

    Here, \(\textbf{S}\) and \(\mathbf {\Omega }\) represent the strain and rotational rate tensors, respectively, which can be calculated as \(\textbf{S}=(\textbf{J}+\textbf{J}^T)/2\) and \(\mathbf {\Omega }=(\textbf{J}-\textbf{J}^T)/2\), where \(\textbf{J}=\nabla \textbf{U}\) denotes the gradient of the velocity field \(\textbf{U}=(u,v,w)\). Furthermore, it is worth emphasizing that the Q-criterion has been effectively utilized in previous studies, see [6], specifically for the purpose of mesh adaptation. The sensor f serves to identify rotations within the flow field. More precisely, when \(f\rightarrow -\frac{1}{2}\), the Q-criterion indicates areas of higher strain rate than vorticity in the flow, while values of \(f>>-\frac{1}{2}\) indicate dominance of rotation. The specific demarcation between these regions can be established using a threshold value, where values of \(f<K\) indicate an irrotational region, while values of \(f>K\) indicate a rotational region. As a result, the Q-criterion effectively partitions the flow into two distinct regions. The non-dimensional form of the Q-criterion has the advantage of minimizing the variability in Q-criterion values across different test cases. For instance, in [6], the authors employed a refinement threshold of \(K=1\) in their simulations. This threshold is designed to be applicable across a wide range of flow fields without the need for user intervention. However, a small change in the threshold value K significantly changes the detected regions, as will be shown in Sect. 3.2.

  • Next, we consider the “new \(\Omega\) method”, introduced in [31], specifically designed to detect vortices in wake flows. This sensor quantifies the ratio of the norm of the vorticity tensor to the sum of the norms of the vorticity tensor and the strain rate tensor:

    $$\begin{aligned} g =\frac{||\mathbf {\Omega }||^2}{||\mathbf {\Omega }||^2+||\textbf{S}||^2+\epsilon }, \quad \epsilon =10^{-3}. \end{aligned}$$
    (2)

    In this context, as \(g\rightarrow 0\), it indicates an irrotational region, while \(g>> 0\) implies high rotational regions. By employing this sensor, rotational-dominated regions which require mesh refinement [7] can be determined. Identification of elements within the domain that need refinement is achieved by adjusting a threshold \(K \in [0, 1]\) based on the function \(g>K\) or \(g<K\). The “new \(\Omega\) method” is also designed to minimize user intervention in the definition of the threshold value. A constant value of \(K=0.52\) is used in [31] for different test cases. Later, in [7], the authors employed a slightly different refinement threshold \(K=0.7\). In both cases, it is claimed that the threshold does not need much adjustment between simulations. However, the effectiveness of this identification method depends on the strength of the vortical structures in the flow, as will be shown in Sect. 3.2.

  • Finally, we consider the new Gaussian mixture model (GMM) clustering technique introduced in [1], where the principal invariants of the strain and rotational rate tensors were used as input to the GMM (see Appendix A for details on the GMM) to identify the two flow regions (a viscous rotational and inviscid irrotational region). The potential of this method for mesh adaptation has not previously been investigated. The feature space used as input to the GMM relies on Galilean invariants of the flow. The feature space is \({E=\left\{ Q_{\textbf{S}},R_{\textbf{S}},Q_{{\mathbf {\Omega }}}\right\} }\), where \(Q_{\textbf{S}}\) and \(R_{\textbf{S}}\) are the two principal invariants of the strain rate tensor \(\textbf{S}\) defined as

    $$\begin{aligned} Q_{\textbf{S}}&=\frac{1}{2}\left( (\textrm{tr}(\textbf{S}))^2 -\textrm{tr}(\textbf{S}^2)\right) , \end{aligned}$$
    (3)
    $$\begin{aligned} R_{\textbf{S}}&=-\frac{1}{3}\textrm{det}(\textbf{S}). \end{aligned}$$
    (4)

    The first invariant of the strain rate tensor \(Q_{\textbf{S}}\) is relevant in indicating regions with a high local viscous dissipation rate of the kinetic energy \(\epsilon = -4\mu Q_{\textbf{S}}\) [34], where \(\mu\) is the dynamic viscosity of the flow. \(R_{\textbf{S}}\) is the second strain rate tensor invariant and indicates strain production or destruction [35]. The rotational rate tensor \(\mathbf {\Omega }\) has one invariant defined as:

    $$\begin{aligned} Q_{\mathbf {\Omega }}=-\frac{1}{2}\left( \textrm{tr} ({\mathbf {\Omega }}^2)\right) . \end{aligned}$$
    (5)

    \(Q_{\mathbf {\Omega }}\) indicates rotational regions in the flow field, as it is proportional to enstrophy density \(\xi\) [34]. The GMM generates two variables, \(p_v\) and \(p_i\), which represent the probability that each point in the mesh belongs to a viscous rotational or inviscid irrotational region. It is important to note that the feature space used in this method consists of variables that are discriminative for the viscous-dominated rotational regions. As a result, this method operates based on the observation that variables in the feature space have higher values in viscous rotational regions and lower values in inviscid irrotational regions. A point is classified as viscous if \(p_v \ge p_i\), and inviscid otherwise. More detailed information can be found in [1]. Unlike previous sensors, this method does not require any user-defined threshold. As a result, the effectiveness of this identification is not influenced by the strength of vortices within the flow, as will be shown in Sect. 3.2.

2.2 Cluster-based adaptation

The main idea behind the cluster adaptation methodology is to enhance the mesh resolution in regions that exhibit complex flow features. This can be achieved by using any of the sensors discussed earlier. The clustering technique has a significant advantage: it eliminates the need for user-defined thresholds that are specific to the problem being solved. As a result, we focus on this particular sensor for our analysis.

The number of normal components (clusters) is two as we want to identify two distinct flow regions, a viscous/turbulent-dominated rotational region (boundary layer and wake region) and an inviscid irrotational region (outer region). Therefore, each degree of freedom in the mesh is assigned two membership probabilities: \(p_v\) for the clustered viscous/turbulent region and \(p_i\) for the outer region. In the particular case of the high-order discontinuous Galerkin spectral element method (DGSEM), we compute the mean of the membership probabilities \({\bar{p}}_v\) and \({\bar{p}}_i\) within each element as follows:

$$\begin{aligned} {\bar{p}}_v= & {} \frac{1}{N}\sum _{j=1}^N {p_v}_j, \qquad {p_v}_j \in [0,1], \end{aligned}$$
(6)
$$\begin{aligned} {\bar{p}}_i= & {} \frac{1}{N}\sum _{j=1}^N {p_i}_j, \qquad {p_i}_j \in [0,1], \end{aligned}$$
(7)

where \(N=(P+1)^{3}\) is the number of DoF of each element of the mesh, and P denotes the polynomial order associated with the high-order discretization. An element will be assigned to the region with the highest mean of membership probabilities \({\bar{p}}=\max {({\bar{p}}_i,{\bar{p}}_v)}\). The same process will be applied for all elements to supply each one with a region ID, viscous/turbulent or inviscid. Having marked the elements that belong in each region, we can now modify the polynomial order in all elements accordingly. Without loss of generality, we have used an arithmetic mean, but we could have considered any numerical quadrature to evaluate the element integral defining the average. Note that the effect of the quadrature rule, which is only used to categorize the elements that contain mixed contributions inside, is minimal. Its impact can be only noticed on a small subset of elements located at the verge between inviscid and viscous/turbulent regions.

The cluster-based adaptation involves three steps. In the first step, we run a simulation with polynomial order, \(P=P_\textrm{initial}\), until the flow is fully developed. In the second step, we perform the clustering as explained in the previous paragraph. Since the clustering is based on the \(\left\{ Q_S,R_S,Q_{\Omega }\right\}\) distribution, a high enough value of \(P_\textrm{initial}\) must be chosen so that the invariants are properly captured. The effect of the initial mesh resolution in the clustered region is analyzed in Sect. 3.2.3. Following [1], we use one single snapshot to calculate the clustered region (for steady and unsteady problems), as the addition of several snapshots results in comparable viscous/turbulent flow regions. The computational cost of the clustering step is lower than that of a single explicit iteration of the time stepper. Since the adaptation is performed only once, the overhead cost of clustering is negligible. In the third step, we use the ID of each element, depending on which region it belongs to, and assign the corresponding polynomial order within that element. In the present work, we use a low polynomial order in the inviscid regions, \(P_\textrm{inviscid}\), and a high polynomial order, \(P_\textrm{cluster}\), in the elements belonging to the viscous/turbulent region. Considering practical aspects, the DGSEM integrated into our numerical framework, HORSES3D (elaborated in the following section), exhibits its best performance with moderately high polynomial orders, typically around \(P=4\) or fifth order. The fifth order represents a sweet spot where we strike a balance between computational cost and accuracy. Consequently, we create an h-mesh that achieves good accuracy at \(P=4\). Then, we employ the p-adaptation methodology to utilize only \(P=4\) in the necessary regions (\(P_\textrm{cluster}=4\)). For the inviscid regions, it is advisable to select the minimum polynomial order that maintains stability. We suggest initially setting \(P_\textrm{inviscid}=1\) and only increasing it if numerical instabilities arise. Achieving the final ideal mesh involves an iterative process where the \(P_\textrm{cluster}\) can be incrementally raised until the accuracy requirements are fulfilled. Our methodology allows for selectively increasing the polynomial order solely within a subdomain of the computational domain, effectively reducing the overall simulation cost. Alternatively, one can complement this methodology with more advanced techniques, such as error-based adaptation [8,9,10] or output-based adaptation [11,12,13]. These methods enable the prediction of the required mesh resolution for a given error level but often come with significantly higher computational costs.

Finally, the simulation is restarted with the adapted polynomial order from the same instant until we reach the final solution. This process is summarized in Algorithm 1.

Algorithm 1
figure a

GMM mesh-adaptation algorithm

2.3 High-order discontinuous Galerkin solver

The data used in this work have been generated using the high-order spectral element CFD solver HORSES3D [36]. HORSES3D is a 3D parallel code developed at ETSIAE-UPM (the School of Aeronautics of the Polytechnic University of Madrid). This framework uses the high-order discontinuous Galerkin spectral element method—DGSEM and is written in modern Fortran 2003. It targets simulations of fluid-flow phenomena such as those governed by compressible and incompressible Navier–Stokes equations, and it supports curvilinear hexahedral meshes of arbitrary order. There are several options of subgrid turbulence models for the users to choose from for LES simulations such as the Smagorinsky subgrid model, WALE and Vreman. One of the main features offered in HORSES3D is its support for anisotropic p-non-conforming elements, as the polynomial order can be varied independently in each element in each direction. In this work, we make use of the adaptation capability to increase/decrease the polynomial order uniformly within each element in the regions determined by the clustering technique. All cases are run with a low storage Runge–Kutta 3 time advancement [37].

3 Results and discussion

We start by introducing the test cases that are considered in Sect. 3.1. Then, in Sect. 3.2, we analyze the influence of the threshold value on region definition for traditional sensors. Additionally, we investigate the validity of the region marked for adaptation by the different methodologies and the effect of initial mesh resolution on the clustered regions. Finally, the results of the adaptation are presented in Sect. 3.3.

3.1 Description of test cases

The mesh refinement strategy is applied to a steady laminar flow test case around a cylinder at \(Re=40\), an unsteady laminar flow test case around a cylinder at \(Re=100\), and an unsteady turbulent flow around a cylinder at \(Re=3900\).

  • Reynolds 40: we first consider a steady laminar test case that has been extensively analyzed in the literature [38,39,40]. These data serve as a basis for comparison with our results. The steady flow data is generated on a mesh of 684 hexahedral elements.

  • Reynolds 100: in the second case, we analyze the clustering and mesh adaptation algorithm for an unsteady laminar case. We choose the flow past a circular cylinder at \(Re=100\), which is unsteady with a shedding frequency of \(T=6U_{c}/D\) non-dimensional time units. Various researchers have studied this flow regime in the context of numerical simulations [41,42,43,44,45] and are used for comparison. We use a mesh that comprises 1282 hexahedral elements.

  • Reynolds 3900: this case has been extensively considered by numerous researchers within the numerical [46, 47] and experimental spectrum [46, 48, 49]. For this case, we use a 2nd order mesh of 20,736 hexahedral elements. The mesh has been extruded in the spanwise direction as \(L_z/D=\pi\) and subdivided into 16 elements along this direction. To minimize aliasing errors and ensure robustness, we have employed a split-form discretization approach along with Pirozzoli averaging [50] and a Smagorinsky closure model. These techniques help to improve the accuracy and stability of the method.

3.2 Preliminary assessment of the feature-based adaptation sensors

In this section, we conduct a preliminary assessment of the three sensors that were introduced earlier. First, we focus on robustness with respect to the user-defined threshold. We compare the Q-criterion and the new \(\Omega\) method with the clustering technique to demonstrate how the new methodology outperforms the classical sensors for the three test cases considered, without the need to use a user-defined and problem-dependent threshold. Second, we study the robustness of the clustering technique with respect to the initial mesh resolution. We show how, for the test cases considered, the clustering method is relatively insensitive to the initial resolution of the problem.

3.2.1 Analysis of the effect of the user-defined threshold

The three test cases presented in Sect. 3.1 were simulated until the wake reached its fully developed state. All simulations were performed with a grid resolution of \(P=4\). These data are used to compute the sensors (Q-criterion, new \(\Omega\) method, and clustering), and the results are compared. For unsteady test cases, we used a single snapshot of the fully developed flow, following the approach described in [1]. It is worth mentioning that we examined various snapshots and found no significant differences in the clustered regions.

  • Q-criterion: We performed the detection of flow regions using various thresholds denoted as K for the Q-criterion in three different test cases: \(Re=40\), \(Re=100\) and \(Re=3900\). The results are shown in Figs. 1, 2, and 3. For reference, we include the regions detected by the clustering technique, which employs GMM with the feature space denoted as E in Figs. 1d, 2d, and 3d. Initially, setting the threshold at \(K=1\), as suggested in [6], resulted in the selection of very few elements suitable for adaptation across our test cases, as observed in Figs. 1c, 2c and 3c. Subsequently, to ensure a similar number of selected elements for refinement as the clustering technique, we adjusted the threshold values for the Q-criterion. Specifically, for \(Re=40\), we set \(K=-0.453\), for \(Re=100\), \(K=-0.193\), and for \(Re=3900\), \(K=-0.4679\). This adjustment effectively increased the number of elements marked for refinement, as depicted in Figs. 1a, 2a and 3a. However, the region marked for refinement is significantly different when using the Q-criterion with these thresholds or when using the clustering technique. In an attempt to automate the threshold selection process for the Q-criterion, we implemented the GMM algorithm utilizing the Q-criterion as feature space, resulting in values of \(K=-0.4909\) for \(Re=40\), \(K=0.343\) for \(Re=100\), and \(K=0.4014\) for \(Re=3900\). The marked elements identified for refinement through this automated process are illustrated in Figs. 1b, 2b and 3b. For \(Re=100\) and \(Re=3900\), where we observe more vortices, our automated approach yielded threshold values closer to those denoted in the literature. However, at \(Re=40\), where the flow remains steady, the GMM automatic threshold selection differs significantly from the literature. This suggests that the literature threshold value struggles to accurately distinguish regions in cases of steady flow.

  • New \(\Omega\) method: Similar to the Q-criterion, we performed the detection of flow regions using various thresholds for the new \(\Omega\) method in the three test cases. The results are shown in Figs. 4, 5 and 6. For reference, we also include the regions detected by the clustering technique, which employs GMM with the feature space denoted as E in Figs. 4d, 5d and 6d. Initially, we set the threshold at \(K=0.7\), as suggested in [7], which results in the selection of very few elements for adaptation across our test cases, as observed in Figs. 4c, 5c and 6c. Subsequently, to ensure a comparable number of selected elements for refinement as the clustering technique, we adjusted the threshold values. Specifically, for \(Re=40\), we set \(K=0.1\), for \(Re=100\), \(K=0.04625\), and for \(Re=3900\), \(K=0.03278\). This adjustment effectively increased the number of elements marked for refinement, as depicted in Figs. 4a, 5a and 6a. Also in this case, the regions marked for refinement are different for the new \(\Omega\) method with these thresholds and the clustering technique. Subsequently, the use of the GMM algorithm to automatically determine thresholds for the new \(\Omega\) method yielded values of \(K=0.0156\) for \(Re=40\), \(K=0.0013\) for \(Re=100\), and \(K=0.0003\) for \(Re=3900\). The resulting marked elements for refinement using this automatic process are depicted in Figs. 4b, 5b and 6b. Similarly to the case of the Q-criterion, at \(Re=40\) where the flow remains steady, there is significant disparity between the threshold selected by the GMM and the literature default. The disparity persists at \(Re=100\), where the automated threshold also includes more elements for refinement than the literature default. This discrepancy arises because elements in the far field exhibit similar levels of new \(\Omega\) as some elements in the wake, making it difficult to differentiate between them. This behavior is more noticeable at \(Re=3900\), resembling the \(Re=100\) case, where a large number of far-field elements are included for refinement due to difficulties in distinguishing between their new \(\Omega\) levels. This section demonstrates the considerable variability in the detected regions when altering the thresholds of traditional feature-based sensors (such as the Q-criterion and the new \(\Omega\) method). On the contrary, our proposed GMM clustering with the feature space E constitutes an unsupervised method that circumvents the need to manually set a threshold value. It can automatically detect cells close to the wall and wake regions for adaptation. These are the crucial areas that include viscous/turbulent effects within the flow. The following section will dive into a comparative analysis to evaluate the validity of the identified adaptation regions of the clustering technique against these traditional feature-based sensors.

Fig. 1
figure 1

Flow past a cylinder at \(Re = 40\): flow regions selected for adaptation using the Q-criterion sensor f, \(K=-0.453\) (a), \(K=-0.4909\)—automatic threshold computed with GMM (b), \(K=1\) - threshold literature default (c) and GMM clustering with feature space E (d). Red: regions selected for adaptation, blue: non-adapted region

Fig. 2
figure 2

Flow past a cylinder at \(Re = 100\): flow regions selected for adaptation using the Q-criterion sensor f, \(K=-0.193\) (a), \(K=0.343\)—automatic threshold computed with GMM (b), \(K=1\)—threshold literature default (c) and GMM clustering with feature space E (d). Red: regions selected for adaptation, red: non-adapted region

Fig. 3
figure 3

Flow past a cylinder at \(Re = 3900\): flow regions selected for adaptation using the Q-criterion sensor f, \(K=-0.4679\) (a), \(K=0.4014\)—automatic threshold computed with GMM (b), \(K=1\)—threshold literature default (c) and GMM clustering with feature space E (d). Red: regions selected for adaptation, red: non-adapted region

Fig. 4
figure 4

Flow past a cylinder at \(Re = 40\): flow regions selected for adaptation using the \(\Omega\) sensor g, \(K=0.1\) (a), \(K=0.0156\)—automatic threshold computed with GMM (b), \(K=0.7\)—threshold literature default (c) and GMM clustering with feature space E (d). Red: regions selected for adaptation, red: non-adapted region

Fig. 5
figure 5

Flow past a cylinder at \(Re = 100\): flow regions selected for adaptation using the \(\Omega\) sensor g, \(K=0.04625\) (a), \(K=0.0013\)—automatic threshold computed with GMM (b), \(K=0.7\)—threshold literature default (c) and GMM clustering with feature space E (d). Red: regions selected for adaptation, red: non-adapted region

Fig. 6
figure 6

Flow past a cylinder at \(Re = 3900\): flow regions selected for adaptation using the \(\Omega\) sensor g, \(K=0.03278\) (a), \(K=0.0003\)—automatic threshold computed with GMM (b), \(K=0.7\)—threshold literature default (c) and GMM clustering withfeature space E (d). Red: regions selected for adaptation, red: non-adapted region

3.2.2 Assessment of the quality of the adapted regions

In the preceding section, we demonstrated the feasibility of achieving comparable refinement regions through the three methods under comparison. Initially, we derived the marked regions using GMM with feature space E. Subsequently, we adjusted the thresholds of both the Q-criterion and the new \(\Omega\) method until we achieved marked regions for refinement containing an identical number of elements to the clustering technique. However, this process yielded distinct regions for refinement for the clustering technique, the Q-criterion and the new \(\Omega\) method. In this section, we present a comparative analysis of these regions to assess their suitability for mesh adaptation. This comparison will underscore the noticeable disparities in the identified regions between traditional feature-based sensors and the new clustering technique.

We present scatter plots depicting the invariants \(Q_S\), \(R_S\), and \(Q_\Omega\) across the regions not selected for adaptation for \(Re=40\), \(Re=100\), and \(Re=3900\). The scatter plots are generated from the same snapshot of the fully developed flow used to mark the regions for adaptation. The data presented in the plots are normalized based on the maximum data value across the entire domain. This normalization enables a clear observation: regions with lower values in the scaled invariants correspond to areas that do not contain significant viscous/rotational effects.

For the cylinder at \(Re=40\), we have found that selecting \(K=-0.0453\) for the Q-criterion and \(K=0.1\) for the new \(\Omega\) method resulted in meshes possessing an equivalent number of degrees of freedom as those obtained through GMM clustering along the feature space \(E=(Q_S, R_S, Q_\Omega )\). Figure 7 shows the scatter map \((Q_\Omega , -Q_S)\) within the identified non-adapted region. For 2D flows, \(R_S=0\), as detailed in [1]. Consequently, the depiction of scatter plots for both \((-Q_S,R_S)\) and \((Q_\Omega ,R_S)\) is omitted. As illustrated in Fig. 7, the non-adapted region detected using the Q-criterion and the new \(\Omega\) method exhibit higher levels of viscous dissipation compared to the region identified using the clustering technique. Traditional sensors are less efficient in distinguishing viscous and inviscid flow regions compared to the GMM with the feature space E clustering. Therefore, using a lower polynomial order within the regions identified by traditional sensors with these thresholds results in decreased accuracy.

Fig. 7
figure 7

Scatter map \((Q_\Omega ,-Q_S)\) in the non-adapted region for the flow past a cylinder at \(Re=40\)

For the flow past a cylinder at \(Re=100\), the Q-criterion and the new \(\Omega\) sensors are calibrated with the values \(K=-0.193\) and \(K=0.04625\), respectively. These thresholds result in adapted meshes with an equivalent number of degrees of freedom as obtained through the clustering technique. Figure 8 illustrates the scatter map \((Q_\Omega , -Q_S)\) within the non-adapted region for both traditional sensors and GMM clustering.

Fig. 8
figure 8

Scatter map \((Q_\Omega ,-Q_S)\) in the non-adapted region for the flow past a cylinder at \(Re=100\)

Similar to the \(Re=40\) case, elevated levels of viscous dissipation are noticeable in the non-adapted regions identified by traditional sensors when compared to those identified by GMM clustering. However, in this instance, the new \(\Omega\) method exhibits superior performance to the Q-criterion but falls short compared to the clustering technique.

For the \(Re=3900\) flow past a cylinder, Fig. 9 displays the scatter maps \((Q_\Omega ,-Q_S)\), \((-Q_S,R_S)\), and \((Q_\Omega ,R_S)\) within the non-adapted regions identified using the Q-criterion and new \(\Omega\) sensors tuned with \(K=-0.4679\) and \(K=0.03278\), respectively, alongside the GMM clustering technique. The non-adapted regions delineated by the Q-criterion and new \(\Omega\) sensors display significantly high levels of viscous dissipation, depicted in Fig. 9a, b, when compared to the clustering technique. Furthermore, the non-adapted regions identified using traditional sensors demonstrate elevated levels of strain production/destruction, with values of \(\frac{R_S}{max(R_S)}\) reaching 0.2, as illustrated in Fig. 9b, c. Consequently, these detected regions contain significant viscous effects compared to those identified by the clustering technique.

Fig. 9
figure 9

Scatter maps \((Q_\Omega ,-Q_S)\), \((R_S,-Q_S)\) and \((Q_\Omega ,R_S)\) in the non-adapted regions for the flow past a cylinder at \(Re=3900\)

The adapted regions predicted by the clustering technique, without threshold tuning, demonstrate superior behavior for performing adaptation compared to those obtained by traditional feature-based methodologies. Although it would be plausible to adjust the thresholds in feature-based approaches to include more elements for refinement and achieve better suited regions for refinement, these would entail a higher computational cost compared to those obtained by the clustering methodology. To further support this conclusion, a comparative study is included in Appendix B, specifically focusing on the \(Re=40\) test case. It comprehensively explores various threshold values to showcase the optimality of the regions identified by the clustering technique. Henceforth, the paper will exclusively employ the new clustering-based adaptation methodology.

3.2.3 Analysis of the effect of the initial mesh resolution

The adaptation methodology described in Sect. 2.2 includes running an initial simulation to compute the clustered region. This simulation is run with a polynomial order \(P=P_\textrm{initial}\), which should be high enough to capture the invariants of the flow. In this section, we study the effect of \(P_\textrm{initial}\) in the clustered region for the three test cases: circular cylinder at Reynolds 40, 100, and 3900.

Initial simulations are performed with \(P_\textrm{initial}=2\) and \(P_\textrm{initial}=4\) for laminar test cases (\(Re=40\) and 100) and \(P_\textrm{initial}=3\) and \(P_\textrm{initial}=4\) for turbulent test case (\(Re=3900\)). In Fig. 10, we compare the clustered regions obtained using the different values for \(P_\textrm{initial}\). The clustered regions and the adapted meshes are very similar, suggesting a small influence of the initial mesh resolution for the three cases considered in this work.

Fig. 10
figure 10

Clustering and regions marked for adaptation when considering various polynomial orders to train the clustering GMM algorithm (\(P_\textrm{initial}\in [2,4]\) for \(Re=40\), \(Re=100\) and \(P_\textrm{initial}\in [3,4]\) for \(Re=3900\)). Flow past a cylinder at \(Re=40\) (a), \(Re=100\) (b) and \(Re=3900\) (c). Red line: boundary of the viscous/turbulent region detected with GMM using \(P=4\). Dashed blue line: boundary of the viscous/turbulent region detected with GMM using \(P=2\) for the flow at \(Re=40\), \(Re=100\) and \(P=3\) for the flow at \(Re=3900\). Dark grey: elements marked for adaptation when using either the red or blue clustered regions. Light grey: elements marked for adaptation which are selected only by one of the clustered regions (no overlapping)

3.3 Adaptation results

In the previous section, we showed the benefits of the new clustering technique against traditional feature-based sensors. To conclude the study, we will utilize the adaptation regions identified through the clustering technique discussed in Sect. 3.2 to carry out mesh adaptation in the three test cases considered.

3.3.1 Flow past a cylinder at \(Re=40\)

The adaptation is carried out following the procedure described in Algorithm 1. The clustered region and the adapted mesh are presented in Fig. 11a. A high polynomial order is used in the selected elements in Fig. 11a based on the mean probability of belonging to the viscous rotational region. For this numerical experiment, we use \(P_\textrm{cluster}=4\) for the viscous regions and \(P_\textrm{inviscid} \in [1,2,3]\) for the inviscid ones. A visualization of the flow field is presented in Fig. 11b, where we show the norm of the velocity vector for the adapted solution \((P_\textrm{cluster}=4, P_\textrm{inviscid}=1)\).

Fig. 11
figure 11

a Presents the polynomial order distribution of the adapted mesh for the flow past a cylinder at \(Re=40\). Grey: \(P_\textrm{cluster}=4\), white: \(P_\textrm{inviscid}\in [1,2,3]\), red line: boundary of the viscous dominated, rotational region detected with GMM. b Presents the norm of velocity for the adapted flow field

We run all simulations until the maximum residuals decrease by a factor of 1000. At this point, the flow is not converged yet, but the wake has developed. We can use these data to perform the clustering and detect the regions that need adaptation/coarsening. Having adapted, we converge the simulation until the maximum residual is \(10^{-4}\). This adapt and converge technique reduces significantly the computational time. Figure 12 shows the convergence history of the homogeneous \(P=4\) solution and the clustering adapted solution (\(P_\textrm{cluster}=4\) and \(P_\textrm{inviscid}\in [1,2,3]\)), where it can be observed that convergence is accelerated when adaptation is performed. A constant CFL number of 0.4 has been used throughout all the different simulations. The computational savings and the corresponding DoF for each simulation are presented in Table 1. The adapted solutions for \(P_{\textrm{inviscid}} \in \{1, 2, 3\}\) exhibit \(32\%\), \(29\%\), and \(19\%\) reduction of computational time accordingly compared to the homogeneous \((P = 4)\) solution and \(67\%, 55\% \text { and }\) \(35\%\) less DoF. The uniform \(P=1\) solution is represented with crosses in Table 1 as it did not converge as a consequence of the lack of sufficient resolution.

Fig. 12
figure 12

Max residuals (the infinity norm of the temporal derivative in the semi-discrete Navier–Stokes equations) for homogeneous and p-adapted solutions

Table I Comparison of the degrees of freedom (DoF), computational cost and drag coefficient (\(C_d\)) for the uniform and adapted solutions for the steady flow past a circular cylinder at \(Re = 40\)

Finally, Table 2 reports drag values extracted from the literature. Comparing Tables 2 and 1, we observe that the baseline homogeneous (for \(P=4\)) and all clustered adapted solutions (\(P_\textrm{cluster}=4\) and \(P_\textrm{inviscid}\in [1,2,3]\)) provide accurate predictions for the drag coefficient.

Table II Comparison of the drag coefficient (\(C_d\)) results for flow past a cylinder at \(Re=40\) against experimental data

This first laminar steady case shows that the GMM clustering can separate the viscous region (the boundary layer and wake) from the outer inviscid. Refinement of the clustered region and coarsening of the inviscid outer region show that the detected clustered region is indeed responsible for errors in drag and that refining it increases the accuracy of the simulations. Additionally, in Appendix B, we compare the GMM clustering to the Q-criterion and the new \(\Omega\) methods, illustrating that the new methodology is more efficient than the traditional counterparts. Therefore, we conclude that the clustering adaptation is an efficient technique for mesh adaption in steady flows and can help to speed up convergence.

3.3.2 Flow past a cylinder at \(Re=100\)

In the second case, we analyze the clustering and mesh adaptation algorithm for an unsteady laminar case. As previously mentioned, we employ the adaptation algorithm to perform the p-adaptation based on a single snapshot of the fully developed flow. The final domain with the adapted region is presented in Fig. 13a. The velocity contour of the adapted solution with \(\left( P_\textrm{cluster}=4, P_\textrm{inviscid}=1 \right)\) is presented in Fig. 13b.

Fig. 13
figure 13

a Presents the polynomial order distribution of the adapted mesh for the flow past a cylinder at \(Re=100\). Grey: \(P_\textrm{cluster}=4\), white: \(P_\textrm{inviscid}\in [1,2,3]\), red line: boundary of the viscous dominated, rotational region detected with GMM. b Presents the norm of velocity contour for the adapted case

We run different simulations with uniform polynomial orders \(P_\textrm{uniform} \in [{1},2,3,4]\) and various adapted solutions with \(P_\textrm{cluster}=4\) in the viscous regions and \(P_\textrm{inviscid} \in [1,2,3]\) in the inviscid ones. A constant CFL value of 1.0 has been consistently applied across all simulations. To collect statistics, the time step remains fixed at the value dictated by the CFL condition when the statistical data collection begins. To post-process each simulation, we use an interval of \(T=150U_{c}/D\) non-dimensional time units and calculate the average drag coefficient, the amplitude of the oscillations of the lift coefficient, and the Strouhal number. The results are presented in Table 3 and show that the adapted solutions are very close to the reference uniform \(P=4\) solution. For completeness, in Table 5 we present numerical results from the literature. Comparing Tables 3 with 5, we observe that the simulations included in this work are well in line with the results presented in the literature. The proposed method is effective in identifying the region of interest and allows us to concentrate the degrees of freedom in the viscous part while coarsening in the inviscid part. By doing so, we can recreate the reference solution with a lower cost and minimal error in the unsteady functionals (lift, drag, and Strouhal number).

Table III Average drag coefficient, amplitude of the lift coefficient oscillations and Strouhal number results for the unsteady flow past a circular cylinder at \(Re=100\)

In Table 4, we present the DoF and cost of the uniform and adapted simulations. We can verify that a simulation using adaptation \(\left( P_\textrm{cluster}=4, P_\textrm{inviscid}=1 \right)\) has a smaller error compared to a uniform \(P=3\) solution with lower number of DoF and similar computational cost. The adapted solutions with \(P_\textrm{cluster}=4\) and \(P_\textrm{inviscid}\in [1,2,3]\) have \(61\%\), \(46\%\) and \(26\%\) fewer DoF compared to the reference \(P=4\) solution and can achieve a reduction of \(20\%\), \(18\%\) and \(2\%\) in computational cost accordingly.

This second laminar case shows that the clustering adaptation works for simple unsteady problems. The developed algorithm correctly marks viscous regions using a single snapshot of the fully developed flow. The adapted mesh is able to represent the solution with minimal error in the unsteady functionals considered.

Table IV Comparison of the degrees of freedom (DoF) and computational cost for the uniform and adapted solutions for the unsteady flow past a circular cylinder at \(Re=100\)
Table V Comparison of numerical results from the literature for the unsteady flow past a circular cylinder at \(Re=100\)

3.3.3 Flow past a cylinder at \(Re=3900\)

In our previous test cases, it has been observed that the resolution in the inviscid region does not have a substantial impact on the accuracy. Therefore, in this test case, the solution has been calculated using a uniform polynomial order of \(P\in {[{1,2,}3,4]}\), as well as an adapted solution defined with the clustering algorithm with \(P_\textrm{cluster}=4\) and \(P_\textrm{inviscid}=2\). In this turbulent case, using \(P_\textrm{inviscid}=1\) resulted in diverging simulations, probably due to aliasing instabilities at the interface between elements with different polynomial orders (mortar surfaces); for this reason, we only report results for \(P_\textrm{inviscid}=2\). The adaptation was performed using the clustering algorithm on a single instant of the flow field after the wake has developed. The adapted mesh is presented in Fig. 14a. A constant CFL value of 0.5 has been consistently applied across all simulations. To collect statistics, the time step remains fixed at the value dictated by the CFL condition when the statistical data collection begins. To minimize aliasing errors and ensure that the method is robust, a split form discretization with Pirozzoli averaging has been employed [50]. A visualization of the flow field of the adapted solution is presented in Fig. 14b.

Fig. 14
figure 14

a Presents the polynomial order distribution of the adapted mesh for the flow past a cylinder at \(Re=3900\). Grey: \(P_\textrm{cluster}=4\), white: \(P_\textrm{inviscid}=2\), red line: boundary of the viscous dominated, rotational/turbulent region detected with GMM. b Presents the contour of the spanwise velocity colored with the axial velocity u for the adapted solution

To measure statistical quantities, we follow [46] and allow the flow to develop for a time interval of \(t=150 D/U_{c}\) to remove the influence of the initial condition. Then the statistics are gathered for a time duration of approximately 100 shedding cycles for each of the simulations carried out, which is in line with the averaging intervals in the literature [46].

The results for the mean drag coefficient \(\textrm{C}_{d}\), Strouhal number St and the recirculation length \(\textrm{L}_{r}\) are presented in Table 6. This table does not include the lift coefficient \(\textrm{C}_{l}\) as it is not commonly documented for this test case. We compare the results obtained from HORSES3D with uniform \(P \in [1,2,3,4]\) solutions and a p-adapted mesh against numerical and experimental results from previous works. As presented, the uniform \(P=4\) and the adapted results fall well within what is reported in the literature. For the uniform \(P=3\) solution, we observe that the mean drag value is severely under-predicted due to the lack of sufficient resolution, even though the Strouhal number is close to the reported values. Lower polynomial orders show discrepancies both in the mean drag value and the Strouhal number.

Table VI Comparison of the mean statistical quantities for the cylinder at \(Re = 3900\) HORSES3D and the literature

The clustering algorithm is able to successfully track the region of interest and through local p-refinement we attain a solution with \(41\%\) fewer DoF, for a similar level of accuracy, compared to the uniform \(P=4\) solution, as presented in Table 7. The adapted solution has only \(16\%\) more DoF than the uniform \(P=3\) solution, but offers superior results as presented in Table 6 and Fig. 15. In terms of computational cost, as presented in Table 7, the adapted solution is \(33\%\) faster than the uniform reference solution \(P=4\) for any given simulation interval.

Table VII Comparison of DoFs and computational time for the cylinder at \(Re=3900\)

The statistics for this test case are presented in Fig. 15. The results of this work are compared with the experimental results (PIV) and numerical results (LES) presented in [46]. The uniform \(P=1\) results show significant discrepancies compared to the numerical and experimental findings because of the lack of sufficient resolution. Hence, these results have been omitted from the subsequent analysis. In Fig. 15a the results of the variance of the streamwise fluctuations for three different positions \(x/D=[1.06,1.54,2.02]\) are presented. The adapted and uniform \(P=4\) results are in good agreement with the PIV and LES data. It should be noted that in the position \(x/D=1.06\) the two strong peaks, due to the transitional state of the shear layer [46], are lower for the uniform \(P=3\) case, and nearly vanish in the \(P=2\) case, which can be attributed to the lack of proper resolution [46]. In Fig. 15b, we present the covariance of the fluctuations. In this case, we also have good agreement between the reference data and the adapted and uniform \(P=4\) solution. The uniform \(P={2,}3\) solutions deviate, indicating that this level of resolution is not sufficient to capture the correct phenomena. The differences are less pronounced in the results presented in Figs. 15d, e as we observe a good agreement for the mean streamwise and normal velocities between the reference results (LES, PIV) and the results of this work. The variance of the normal velocity fluctuations in Fig. 15f is in good agreement, although the uniform and clustering p-adaptation results of this work underestimate the peak along the position \(x/D=2.02\). Lastly, the mean streamwise velocity along the centerline, presented in Fig. 15c, is close to the reference data but we observe that the point of minimum velocity is over-predicted in the results from HORSES3D.

Fig. 15
figure 15

Statistical quantities of the wake for the unsteady turbulent case of a flow past a cylinder at \(Re=3900\). Comparison of experimental (PIV) and high resolution numerical (LES) results from [46] against uniform and adapted results from HORSES3D

This third turbulent case shows that the clustering adaption can be very useful for turbulent unsteady cases. The GMM clustering is able to mark viscous and turbulent regions in the boundary layer and wake, where higher resolution is required, and separate it from the outer inviscid region, where a lower resolution can be used.

4 Numerical experiments

In this section, we conduct a numerical experiment to demonstrate the practicality and effectiveness of the machine learning adaptation methodology developed in an engineering application. We simulate the experimental blind test (BT) of the Norwegian University of Science and Technology (NTNU), which is a three-bladed wind turbine with a diameter (D) of 0.894 m, which was tested in the wind tunnel of the Dept. Energy and Process Engineering, NTNU. The turbine blades were made up of NREL S826 airfoils [56]. The wind tunnel used for the experiment had dimensions of \([L \times W \times H] = [11.15 \times 2.71 \times 1.8]\) m. The inflow velocity profile was uniform, and the turbulence intensity levels were kept low at 0.3%.

For our analysis, we used the setup and data from the blind test, which provided information on the wake of a single wind turbine at various tip speed ratios (\(\lambda\)). Specifically, we focus on the results at the optimal tip speed ratio \(\lambda =\Omega D/2U_\textrm{ref} = 6\), with \(U_\textrm{ref}=10\) m/s and \(\Omega =134.228\) rad/s, to evaluate the effectiveness of our adaptation methodology. The blade tip Reynolds number for this case is \(Re_c = \lambda U_\textrm{ref} c_\textrm{tip}/\nu = 103600\), where \(c_\textrm{tip}=0.025926\)m is the tip chord length and \(\nu\) is the kinematic viscosity of air.

We model the turbine blades using a combination of the immersed boundary method [36, 57] to represent the tower and the nacelle and an actuator line method [58] to represent the rotating blades. To conduct the simulations, we utilize the LES computational fluid dynamics (CFD) and solve the compressible 3D Navier–Stokes equations with the Vreman turbulence closure using HORSES3D [36]. The wind tunnel walls are treated as free slip walls, and no inlet turbulence is introduced into the simulation.

A Cartesian mesh is generated with the same size as the wind tunnel, consisting of \([128 \times 24 \times 24]\) elements. This results in a \(D/\Delta x\) ratio of approximately 10, where D is the diameter of the turbine. It is important to note that, since we use a high-order method, the spatial resolution is also increased by raising the polynomial order. A constant CFL value of 0.4 has been used consistently in all simulations. To collect statistics, the time step remains fixed at the value dictated by the CFL condition when the collection of statistical data begins.

We first conduct four non-adapted simulations with a uniform polynomial order of \(P \in [1,2,3,4]\). These simulations are run for a duration of 2 s. During the first second, the wake fully develops and it needs one additional second to stabilize. Subsequently, we collect statistics over a period of 0.5 s, which is equivalent to 10 rotations. In addition, we perform one adapted simulation using Algorithm 1. Initially, a simulation is conducted for a duration of one second, allowing the wake to develop. This initial simulation employs a polynomial order of \(P_\textrm{initial}=4\), which ensures proper capturing of the wake. The next step is to adapt the simulation by setting \(P_\textrm{cluster}=\)4 and \(P_\textrm{inviscid}=1\), and continue the simulation for an additional 1 s. Again, we select the lowest possible resolution in the inviscid region, \(P_\textrm{inviscid}=1\), as we have observed that its impact in the accuracy of the simulation is minimum. Finally, we compute the statistics for a duration of 0.5 s. The adaptation has been performed using the clustering algorithm on a single instant of the flow field after the wake has developed. The adapted mesh is presented in Fig. 16a. In Fig. 16b, we show a visualization of the flow field for the adapted solution. We can see that the clustering algorithm correctly identifies the viscous/turbulent region.

In Fig. 17, we present horizontal profiles of the mean streamwise velocity deficit at various downstream positions (\(x/D=1\), 3, and 5). Vertical planes show these locations in Fig. 16b. The velocity deficit for different solutions with uniform meshes \(P \in [1, 2, 3, 4]\) is compared to experimental data [56]. We can see how solutions improve as the polynomial order increases. We observe a discrepancy between the numerical solutions and experimental data that persists even at higher polynomial orders. This is likely a result of modeling errors in representing the tower and the nacelle (using the immersed boundary method) and the rotating blades (utilizing the actuator line method). A similar behavior is reported in [59]. However, more important for this work is the fact that the adapted simulation is almost identical to the homogeneous \(P = 4\) solution, showing the potential of the clustering technique for complex cases.

Table 8 summarizes the computational cost advantages of cluster adaptation. Through the use of local p-refinement, we obtain a solution with 61% fewer degrees of freedom (DoF) and 43% faster computation while maintaining a level of accuracy similar to the uniform \(P = 4\) solution.

This numerical experiment shows that clustering adaptation is beneficial in the context of a general engineering application such as wind turbine simulations. The GMM clustering method accurately marks viscous and turbulent regions in the turbine wake, requiring higher resolution, while distinguishing them from the outer inviscid region, where lower resolution is sufficient. This approach optimizes computational resources and ensures an accurate representation of the flow characteristics.

Fig. 16
figure 16

Contours of the Q-criterion, with colors representing the L2 norm of the velocity, for the flow past a wind turbine at \(Re_c = 103,600\). Figure 16a also includes slices of the detected viscous dominated, rotational/turbulent region, highlighted in red, using the Gaussian mixture model (GMM) analysis. Figure 16b displays both horizontal and vertical planes. The intersection of these planes marks the positions where the velocity deficit at the horizontal axis is compared with experimental data

Fig. 17
figure 17

Horizontal profiles of mean streamwise velocity deficit at three downstream positions x/D for \(P \in [1,2,3,4]\) and adapted (\(P_\textrm{cluster}=4\) and \(P_\textrm{inviscid}=1\)) and comparison with experimental data [56]

Table VIII Comparison of DoFs and computational time for the turbine test case

5 Conclusion

This work presents an unsupervised learning GMM clustering that is used to perform local adaptation. The clustering distinguishes viscous/turbulent regions from inviscid regions allowing increased resolution in viscous/turbulent dominated regions. The presented methodology has been successfully applied and has resulted in the acceleration of the simulation of fluid flow around a circular cylinder at \(Re=40\) (steady laminar regime), \(Re=100\) (unsteady laminar regime) and \(Re=3900\) (unsteady turbulent regime) while maintaining the expected levels of accuracy. A final example of a wind turbine modeled through actuator lines is also included. The local adaptation strategy decouples the viscous/turbulent region from the outer inviscid regions, and through mesh refinement/coarsening it achieves comparable results to those with uniformly refined meshes.

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, clustering eliminates the need for such thresholds and locates the regions that require adaptation. For the laminar case of \(Re=40\), we have shown that the p-adapted solution with polynomial orders \((P_\textrm{cluster}=4, P_\textrm{inviscid}=[1,2,3])\) has the same accuracy as the homogeneous solution with a uniform polynomial order \((P = 4)\) while showing \(67\%\), \(55\%\) and \(35\%\) reduction in number of degrees of freedom and \(32\%\), \(29\%\) and \(19\%\) reduction of computational time, respectively. When considering an unsteady wake at \(Re=100\), we observe a reduction of \(61\%\), \(46\%\) and \(26\%\) in degrees of freedom and \(20\%\), \(18\%\) and \(2\%\) in computational cost for very similar accuracies. For the unsteady turbulent case at \(Re=3900\), the adapted solution through the clustering method is similar to the benchmark uniform solution (\(P=4\)), as well as the experimental and numerical results reported in the literature, while having \(41\%\) fewer degrees of freedom and \(33\%\) reduction in computational cost.

Moreover, we have demonstrated the applicability of this method to more complex unsteady turbulent flows, exemplified by the flow past a wind turbine at \(Re_c = 103,600\). The adapted solution achieved through the clustering technique closely aligns with the benchmark uniform solution (\(P=4\)) and agrees well with the experimental results found in the literature. Remarkably, this adapted solution requires \(61\%\) fewer degrees of freedom and leads to a \(43\%\) reduction in computational cost. This showcases the algorithm’s ability to accurately track regions of interest that require higher resolution while simultaneously enabling us to optimize computational efficiency.

We conclude that clustering-based adaptation is a useful tool within feature-based methods and overcomes some of the classic drawbacks present in feature-based approaches. For example, the presented methodology does not require any threshold or iterative adaptation process to determine the refinement regions.