1 Introduction

Computational fluid dynamics (CFD) has undoubtedly become an important prediction, analysis, and design tool in many engineering applications. New methods are continuously developed to better exploit computational resources, to increase solution accuracy, and to extend the range of applicability of CFD to diverse fields. For instance, the numerical simulation of fluid flows within the so-called non-ideal compressible fluid dynamics (NICFD) regime still represents some challenges for CFD experts, and it is a very active area of research [1,2,3,4,5,6,7].

NICFD deals with flows occurring within the thermodynamic region wherein the fluid thermodynamic behavior significantly departs from the one predicted by the ideal gas model, as occurs for dense vapors, supercritical flows, and compressible two-phase flows. In this region, the attractive and repulsive molecular forces are not negligible and non-ideal gas effects, such as non-monotone variations of the Mach number along isentropic expansions, or non-classical phenomena, such as rarefaction shocks, may occur [8,9,10].

Reliable simulations of NICFD flows require accurate thermodynamic models that are able to include non-ideal effects, but that are usually characterized by complex mathematical descriptions. The inclusion of such thermodynamic models in CFD software is not a trivial task and leads to a considerable increase in the computational time, especially when the flow states are in the neighborhood of the vapor–liquid equilibrium (VLE) curve [11].

In recent years, different efforts have been made to extend standard techniques usually adopted under the perfect, i.e., polytropic ideal, gas assumption to the NICFD regime. As a result, some CFD toolkits presently offer the capability to perform simulations of non-ideal compressible flows, such as the open-source multi-physics software suite SU2, which has been recently equipped with a varied thermodynamic library for pure fluids [1], and commercial software such as ANSYS CFD or STAR-CCM+.

In addition, new methods are continuously developed to tackle specific numerical tasks or applications. For example, several contributions have been dedicated to numerical schemes [12,13,14], to efficient evaluation of thermodynamic quantities [15, 16], and, more recently, to shock waves [2, 17, 18] and to turbulent flows [19, 20] in the NICFD regime. However, some numerical techniques widely used in ideal gas simulations have not been the subjects of an adequate investigation and assessment in the NICFD regime yet. In particular, in our opinion, an example of these shortcomings concerns mesh adaptation techniques in unsteady simulations.

Mesh adaptation is a valuable strategy for the simulation of flow fields characterized by different spatial scales and for unsteady simulations, where the position of the relevant flow features changes in space and/or time or the computational domain undergoes large deformations. In these situations, the grid spacing can be locally reduced or increased to efficiently optimize solution accuracy, while preventing an excessive growth of the number of grid nodes. Concerning the criteria used to modify the grid, different choices can be made, as for instance integral error indicators [21, 22], local a-posteriori error estimators based on interpolation error analysis [23, 24] or local indicators based on the behavior of the flow solution [25,26,27]. Similarly, various adaptation strategies have been proposed, such as node displacement at fixed connectivity (r-adaptation) [28], local grid connectivity modification (r-refinement) [29,30,31], partial or complete re-meshing, or modification of the polynomial order used to discretize the equations on each element (p-refinement) [32, 33], which can also be combined together, as hp-refinement. However, standard mesh adaptation techniques require the interpolation of the solution from the old to the adapted grid. As is well known, from a numerical point of view, solution interpolation in compressible flow is an undesirable operation, because it may undermine the accuracy of the solution and the properties of the scheme, such as stability and positivity-preserving properties, and it may introduce spurious oscillations. This latter fact can be particularly dangerous in NICFD simulations, where oscillations may bring the thermodynamic state of the fluid under the VLE curve, where the adopted single-phase equation of state (EoS) is invalid.

To overcome the difficulties related to the solution interpolation, the inviscid flow solver Flowmesh is currently under development at the Department of Aerospace Science and Technology of Politecnico di Milano [34]. The solver implements a finite-volume scheme for unstructured grids based on an innovative interpretation of the modification of grid elements due to mesh adaptation within the arbitrary Lagrangian–Eulerian (ALE) framework [35,36,37]. Thanks to a series of fictitious continuous deformations of the finite volumes, interpolation of the solution from the initial to the adapted grid is avoided, thus preserving the properties of the fixed-connectivity ALE scheme while guaranteeing conservativeness by construction. In our opinion, the absence in the proposed method of an explicit interpolation step has a favorable impact on NICFD simulations, where oscillations in the thermodynamic fluid state may undermine the robustness of the method to the point of jeopardizing the computation of the solution. In addition, the flow solver is linked to the VThermo library, now included in FluidProp [38], which offers the possibility of evaluating thermodynamic quantities by means of different EoSs, such as the van der Waals EoS [39], the Peng–Robinson EoS [40], the Martin–Hou EoS [41], the Redlich–Kwong EoS [42], and the Soave–Redlich–Kwong EoS [43]. For what concerns mesh adaptation strategies, node displacement, insertion, deletion, and edge swap are exploited to locally modify the grid spacing, with the support of the automatic triangular and tetrahedral re-meshers of the open-source library Mmg [44].

A natural application of a numerical tool with the outlined features is, in our opinion, the simulation of a flow inside a tube closed by movable pistons. Different types of piston motions can be enforced to generate various flow fields, which may include shock waves, contact discontinuities, and smooth regions. Indeed, this setup is often the core of experimental test-rig arrangements thanks to its feasibility and flexibility [45,46,47,48]. However, the numerical simulation of these flow fields is challenging due to the presence of traveling waves with different spatial scales, and it represents a valuable test to assess the capabilities of the proposed adaptive method.

In essence, this paper describes the assessment of an adaptive Euler solver over 2D and 3D unstructured grids for moving-body problems in the NICFD regime. To authors’ knowledge, this is the first application of unsteady mesh adaptation strategies to NICFD problems, and the interpolation-free approach here exploited represents an added value with respect to standard adaptation techniques in this peculiar thermodynamic regime. This work draws on the investigation of mesh adaptation criteria based on flow variables in the NICFD regime for bi-dimensional steady simulations described in [49].

The paper is organized as follows. Section 2 outlines the main features of the thermodynamic modeling in the NICFD regime and the polytropic Peng–Robinson model used in the simulation of the piston problems. Section 3 sketches the numerical method to solve the unsteady Euler equations over adaptive grids within the ALE framework. Then, the adopted mesh adaptation techniques are described in Sect. 4, along with a summary of the entire computational process. An assessment of the proposed unsteady method in 2D and 3D steady tests is given in Sect. 5. Section 6 describes the results of different piston problems. More specifically, Sects. 6.1 and 6.2 illustrate an oscillating piston in an infinite-length and in a closed tube in the NICFD regime, starting from two different initial conditions. Then, we show the results for an impulsively started piston in a closed tube. Section 6.4 displays the results of two tests about the piston experiencing harmonic motion in the non-classical region. Three-dimensional results are presented in Sect. 6.5. Finally, the conclusions of the present work are drawn in Sect. 7.

2 Thermodynamic modeling in NICFD regime

In NICFD, a quantitative measure of the deviation of the flow behavior from the ideal gas model is given by the value of the fundamental derivative of gasdynamics \(\varGamma \) [50],

$$\begin{aligned} \varGamma = 1 + \dfrac{\rho }{c} \left( \dfrac{\partial c}{\partial \rho } \right) _s, \end{aligned}$$
(1)

which expresses the isentropic variation of the sound speed, being \(\rho \), c, s the density, the sound speed, and the specific entropy, respectively.

The occurrence of non-ideal gas effects is determined by values of \(\varGamma \) less than unity. More specifically, the gasdynamic behavior of fluids characterized by \(0<\varGamma <1\) shows qualitative differences with respect to the ideal one. The most peculiar is the non-monotone dependence of the Mach number on the density along isentropic expansions because of the increase in the speed of sound [51, 52]. For thermodynamic states at \(\varGamma <0\), non-classical gasdynamic phenomena, such as rarefaction shock waves and composite waves, may occur [53, 54], although no experimental evidence of the existence of such exotic flow features in single-phase vapor flows is available. The value of the fundamental derivative varies over the thermodynamic plane, and some fluids have a finite region near the VLE curve where \(\varGamma <1\) [9]. However, recent advancements have predicted the possible occurrence of even non-classical phenomena near the critical point also for quite simple molecules [10, 55].

Given the inappropriateness for NICFD simulations of the perfect, or so-called polytropic ideal gas (PIG) model—which predicts a constant \(\varGamma ^{\mathrm {PIG}}=(\gamma +1)/2>1\), where \(\gamma =c_p/c_v>1\) is the constant ratio between the isobaric (\(c_p\)) and isochoric (\(c_v\)) specific heat capacities—a non-ideal thermodynamic model is required to describe the flow behavior. For pure fluids, the complete evaluation of the thermodynamic state can be obtained from a thermodynamic potential expressing directly the fundamental relation, as the Helmholtz free energy, or from two compatible equations of states [56].

Different modeling approaches have been proposed to describe the thermodynamic behavior of the flow in CFD simulations. For instance, the pressure P can be expressed in terms of temperature T and specific volume v by a cubic equation, generally composed by two terms, one accounting for the attractive intermolecular forces and one for the repulsive covolume effects. The simplest cubic EoS is the van der Waals EoS, but several different pressure EoSs have been proposed [40,41,42,43]. To have a complete thermodynamic description, the pressure EoS has to be complemented by a compatible caloric EoS [57]. A different approach may rely on an accurate multi-parameter EoS expressing the fundamental relation, see for instance [58, 59]. Because of their high nonlinearity and complexity, a direct implementation in CFD codes of such EoSs is practically unaffordable, but they can be used in a preceding step to build accurate lookup tables which are then recalled during the simulation to evaluate the thermodynamic state by interpolation [60,61,62].

2.1 Peng–Robinson equation of state model

In this work, to model the thermodynamic behavior of the flow, we use the pressure Peng–Robinson EoS [40]:

$$\begin{aligned} P(T,v) = \dfrac{R T}{v -b} - \dfrac{a \, \alpha _\omega (T_\mathrm {r})^2}{v(v+b) + b(v-b)}, \end{aligned}$$
(2)

where a and b are two fluid-specific constants given in terms of the critical pressure \(P_\mathrm {c}\) and temperature \(T_\mathrm {c}\),

$$\begin{aligned} a =0.45724 \, \dfrac{R^2 T_\mathrm {c}^2}{P_\mathrm {c}}, \qquad b =0.0778 \, \dfrac{R T_\mathrm {c}}{P_\mathrm {c}}, \end{aligned}$$

and \(\alpha _\omega \) is a dimensionless function of reduced temperature \(T_\mathrm {r}=T/T_\mathrm {c}\), namely

$$\begin{aligned} \alpha _\omega (T_\mathrm {r}) = 1 + f_\omega \left( 1-\sqrt{T_\mathrm {r}} \right) \, \end{aligned}$$

where \(f_\omega \) is a constant characteristic of the substance, defined in terms of the acentric factor \(\omega \),

$$\begin{aligned} f_\omega = 0.37464 + 1.54226\, \omega - 0.26699 \, \omega ^2. \end{aligned}$$

The acentric factor is a parameter that takes into account the polarity and the lack of spherical shapes of the molecules. In this work, its (approximate) value is computed by means of the Edmister’s equation [63]:

$$\begin{aligned} \omega = \dfrac{3}{7} \left( \dfrac{T_\mathrm {b}}{T_\mathrm {c}- T_\mathrm {b}} \right) \; \log _{10} \left( \dfrac{P_\mathrm {c}}{101325} \right) , \end{aligned}$$
(3)

where \(T_\mathrm {b}\) is the temperature at the normal boiling point.

Given the pressure EoS, the compatible caloric EoS for the internal energy per unit of mass \(e=e(T,v)\) can be derived by integrating the reciprocity relation

$$\begin{aligned} \left( \dfrac{\partial e(T,v)}{\partial v}\right) = T \left( \dfrac{\partial P(T,v)}{\partial T}\right) _v - P(t,v). \end{aligned}$$
(4)

However, the integration with respect to the specific volume allows the compatible EoS to be determined only up to an integration constant function of temperature, which is usually connected to the dependence of the energy on temperature in the dilute gas limit. In common practice, it is defined as

$$\begin{aligned} \phi (T) =\int _{T_{\mathrm {ref}}}^T c_{v_\infty }(\tau ) \, \mathrm {d} \tau , \end{aligned}$$
(5)

where \(c_{v_\infty }\) is the isochoric specific heat capacity in the ideal gas limit, that is for \(v \rightarrow \infty \). For more details, see Ref. [56].

The caloric EoS compatible to (2) is

$$\begin{aligned} e(T,v)= e_{\mathrm {ref}} + \phi (T) - \dfrac{a}{b}\dfrac{\alpha _\omega (T_\mathrm {r})}{2\sqrt{2}} \, \Bigl [\alpha _\omega (T_\mathrm {r})+ f_\omega \sqrt{T_\mathrm {r}} \, \Bigr ] \, \ln \dfrac{1+\sqrt{2} + v/b}{1-\sqrt{2} + v/b}\nonumber \\ \end{aligned}$$
(6)

where \(e_{\mathrm {ref}}\) is an arbitrary reference value for the specific energy, used in the integration of (4). In this work, we assume a polytropic behavior in the dilute gas limit (\(v \rightarrow \infty \)), and therefore \(\phi (T)\) is a linear function of the temperature, i.e., \(c_{v_{\infty }}\) is constant.

A convenient parameter that easily expresses the deviation of the pressure EoS from the ideal gas model is the compressibility factor \(Z=Pv/(RT)\), where R is the gas constant. For the PIG model, Z is constant and equal to 1. The Peng–Robinson EoS predicts the same compressibility factor at the critical point for all substances. Indeed, by evaluating (2) at \(P_\mathrm {c}=P(T_\mathrm {c}, v_\mathrm {c})\), a cubic equation for \(Z_\mathrm {c}\) is obtained, which has only one real root \(Z_\mathrm {c}^{\mathrm {PR}}=0.3214\). As a consequence, this EoS, as all the cubic ones, is not able to correctly compute all three critical point coordinates \(P_\mathrm {c}\), \(T_\mathrm {c}\), and \(v_\mathrm {c}\) [56].

3 Numerical method

The governing equations for unsteady inviscid compressible flows are provided by the Euler equations. For a control volume \(\mathcal {C}\) within the spatial domain \(\varOmega \) they read

$$\begin{aligned} \dfrac{\mathrm {d}}{\mathrm {d}t} \int _{\mathcal {C}} \! \mathsf {u}\; \mathrm {d}\mathbf {x}+ \oint _{\partial \mathcal {C}} \!\!\! \mathbf {f}(\mathsf {u}) \cdot \mathbf {n}\; d\mathbf {s} = 0, \end{aligned}$$
(7)

where \(\mathbf {x}\in {\mathbb {R}}^k \) and \(t>0\) are as usual the position and the time, \(\mathsf {u}= [ \rho , \, \mathbf {m}, \, E^\mathrm {t}]^{\mathrm {T}}\) is the vector of conservative variables (density, momentum density, and total energy density, respectively) and \(\mathbf {n}(\mathbf {x},t)\) denotes the outward unit vector normal to the boundary \(\partial \mathcal {C}\), over which the position vector is denoted \(\mathbf {s} \in {\mathbb {R}}^{k-1} \). The inviscid flux function \(\mathbf {f}(\mathsf {u})\) is defined as

$$\begin{aligned} \mathbf {f}(\mathsf {u}) = \left[ \mathbf {m}, \; \mathbf {m}\otimes \mathbf {m}/ \rho + \varPi (\mathsf {u}) {\mathbb {I}}^k,\; \left[ E^\mathrm {t}+ \varPi (\mathsf {u}) \right] \mathbf {m}/\rho \right] ^{\mathrm {T}}, \end{aligned}$$

where \(\varPi (\mathsf {u})\) is the pressure function and \({\mathbb {I}}^k\) is the \(k \times k\) identity matrix. Suitable initial and boundary conditions have to be specified to complement (7) [64].

The thermodynamic model completes the Euler equations through the pressure function \(\varPi \), which expresses the pressure P as a function of the conservative variables. Indeed, the pressure and caloric EoSs are manipulated so that

$$\begin{aligned} P= & {} P(e(T,v),v) = P(E, \rho ) \nonumber \\= & {} P\left( E^\mathrm {t}- \frac{\Vert \mathbf {m}\Vert ^2}{2\, \rho }, \rho \right) = \varPi (\mathsf {u}), \end{aligned}$$

where E is the internal energy density (per unit of volume).

3.1 Spatial and temporal discretization

The discrete form of the Euler equations is now briefly described. Since the focus here is on the influence of the thermodynamic model on the method, only the relevant results of the discretization process are illustrated. A detailed description of the scheme is given in [35, 36] for the 2D and in [37, 65] for the 3D cases.

A node-centered edge-based finite-volume scheme is exploited to spatially discretize the governing equations over the computational grid. Thus, the domain is split in a finite number of non-overlapping finite volumes \(\mathcal {C}_i\) so that \(\bigcup _i \mathcal {C}_i(t)= \varOmega (t)\), where \(\mathcal {C}_i\) is a volume surrounding the grid node i. By adopting the backward Euler scheme for time integration, the discretized governing equations can be written as

(8)

where \(V_i\) is the volume of the cell \(\mathcal {C}_i\), \(\mathsf {u}_i\) is the average solution \(\mathsf {u}\) over \(\mathcal {C}_i\), \(\mathcal {K}_{i,\ne }\) denotes the set of finite volumes different from \(\mathcal {C}_i\) that share a portion of their boundary with \(\mathcal {C}_i\); \(\varPhi \) and \(\varPhi ^\partial \) are suitable integrated numerical fluxes that represent, respectively, the flux across the domain cell interface \(\partial \mathcal {C}_{ik}=\partial \mathcal {C}_i \cap \partial \mathcal {C}_k\) and, if the node i lies on the boundary, across the boundary interface \(\partial \mathcal {C}_{i,\partial }=\partial \mathcal {C}_i \cap \partial \varOmega \). The superscripts n and \(n+1\) indicate variables evaluated at time \(t^n\) and \(t^{n+1}\), respectively, while \(\varDelta t\) is the time step in-between. Moreover, we have introduced the integrated normal vectors:

(9)

with \(\mathbf {n}_i\) denoting the outward normal with respect to the finite volume \(\mathcal {C}_i\).

A pseudo-time step method is used to solve the nonlinear (8) and the solution at time \(t^{n+1}\) is obtained through an iterative process. The pseudo-time derivative is discretized by means of the backward Euler scheme too, and the unsteady residual, containing the numerical fluxes at the actual pseudo-time step, is approximated by a Taylor expansion. Moreover, according to the defect correction approach, the exact Jacobian of the integrated fluxes is approximated by the Jacobian of the first-order fluxes only, to increase its diagonal dominance [66]. At each pseudo-time step, a symmetric Gauss Seidel method is used to solve the system of linear equations. Further details about the time integration are given in [67, 68].

3.1.1 Integrated numerical fluxes

For the integrated flux \(\varPhi \), a high-resolution scheme based on the total variation diminishing (TVD) approach [69] is used in the present work to correctly capture shock waves and contact discontinuities within the NICFD regime of interest. More specifically, near discontinuities the second-order centered approximation of the interface flux is replaced by the first-order monotonicity-preserving Roe scheme. The switch is controlled by the van Leer limiter. By denoting the limiter \(\varPsi = \mathrm {diag}\left\{ \varPsi _1 \cdots \varPsi _{k+2}\right\} \), the integrated numerical flux across the interface \(\partial \mathcal {C}_{ik}\) reads

where \({\widetilde{\mathsf {\Lambda }}}\) is the Roe matrix, defined here as the Jacobian of the flux function \(\mathbf {f}(\mathsf {u})\) projected along the normal direction and evaluated at the intermediate Roe state \({\tilde{\mathsf {u}}}={\tilde{\mathsf {u}}}(\mathsf {u}_i, \mathsf {u}_k)\).

Under the polytropic ideal gas assumption, only two variables are required to define the Roe matrix [70]. Conversely, if a non-ideal thermodynamic model is assumed, the Roe matrix is not uniquely determined by the conservation property [71] and several approaches were proposed to compute the Roe matrix. Most standard approaches rely on an augmented intermediate state, which includes the pressure derivatives as additional variables and aims at obtaining a quasi-Jacobian form of the Roe matrix [12, 13, 72, 73]. However, the average thermodynamic derivatives do not retain their proper significance and this may lead to inconsistencies whenever they are used to compute other thermodynamic quantities, such as the speed of sound [71, 74]. A different approach is proposed in [71], where the Jacobian form of the Roe matrix is enforced. This choice results in an intermediate state that is a one-parameter family of solutions, and the following additional condition is imposed to determine the intermediate density:

$$\begin{aligned} \left( \dfrac{\partial P}{\partial E}\right) _{\rho } \bigl (E_i - E_k \bigr ) + \left( \dfrac{\partial P}{\partial \rho }\right) _{E} \bigl (\rho _i - \rho _k \bigr ) = P_i - P_k. \end{aligned}$$

Unfortunately, when using complex EoSs the computation of the intermediate density from the previous relation is not easy, and it requires numerical techniques [75].

Nevertheless, it has been shown that no relevant differences can be appreciated in the results when using different, simpler approaches [75, 76]. Therefore, the generalized Roe matrix for non-ideal gas flows is computed here following the simplified approach proposed by Cinnella [77], which consists in selecting the intermediate density as \(\widetilde{\rho }=\sqrt{\rho _i \, \rho _k}\), and the intermediate velocity and total enthalpy through the same definitions used for the PIG model, which are valid also for non-ideal gases as proved in [71].

3.1.2 Boundary fluxes

The boundary conditions are imposed in a weak form, i.e., by evaluating the flux in a suitable boundary state \(\mathsf {u}^\partial _i= \mathsf {u}^\partial (\mathsf {u}_i, \mathbf {b})\), function of the solution on the boundary node \(\mathsf {u}_i\) and of the boundary data \(\mathbf {b}\).

In the present work, three types of boundary conditions are imposed: the slip wall, the normal inlet/outlet, and the non-reflecting free surface. The former one is imposed by setting the component of the fluid velocity normal to the boundary equal to the boundary velocity along the normal direction. The second condition models an infinite-length open-end tube, that does not influence the flow inside the domain but preserves only the flow direction parallel to the tube axis, without imposing the sense (inflow or outflow). Hence, this boundary condition simply nullifies the component of the fluid velocity tangential to the open-boundary (or, if need be, sets it equal to the tangential velocity of the boundary). For the latter case, the boundary state is computed via characteristic reconstruction, and the correct number of the physical variables that can be imposed is automatically computed by the eigenvalues analysis [1, 78].

Because an implicit pseudo-time method is adopted in this work and a Taylor expansion is used to approximate the residual terms containing the numerical fluxes, the evaluation of the Jacobian matrix at the boundary state and the derivative \(\frac{\partial \mathsf {u}^\partial _i}{\partial \mathsf {u}_i}\) are also required [67].

3.2 ALE framework for dynamic grids

Unsteady problems often require updating the computational domain to follow the boundary motion or deformation. In such situations, it is common practice to redistribute the displacement occurring at the boundary among the internal grid nodes depending on their shape and volume without modifying the grid connectivity; see for instance [79,80,81]. The same technique can be used to move grid nodes to better describe the local flow features, namely for r-adaptation. As a consequence, on a dynamic grid, the formulation of the flow equations has to be modified to account for the relative motion of the grid with respect to the fluid. The arbitrary Lagrangian–Eulerian (ALE) formulation is a widely used and effective strategy to accomplish this task [82, 83]. Within the ALE framework, the governing equations are enforced over control volumes that can move and deform independently of the fluid velocity.

The ALE formulation of the Euler equations reads

$$\begin{aligned} \dfrac{\mathrm {d}}{\mathrm {d}t} \int _{\mathcal {C}(t)} \!\!\!\!\! \mathsf {u}\; \mathrm {d}\mathbf {x}+ \oint _{\partial \mathcal {C}(t)} \!\!\!\!\!\!\! \left[ \mathbf {f}(\mathsf {u}) - \mathsf {u}\mathbf {v}\right] \cdot \mathbf {n}\; \mathrm {d}\mathbf {s} = 0, \end{aligned}$$
(10)

where \(\mathbf {v}\) is the velocity of the control volume. The previous equation can be discretized through the same strategy outlined in Sect. 3.1, provided that the contribution of the grid velocity is taken into account in the integrated fluxes. In this regard, two additional quantities labeled as interface velocities are defined as

$$\begin{aligned} \nu _{ik}=\int _{\partial \mathcal {C}_{ik}} \!\!\!\!\!\! \mathbf {v}\cdot \mathbf {n}_i \; \mathrm {d} \mathbf {x}\qquad \mathrm {and} \qquad \nu _i=\int _{\partial \mathcal {C}_{i,\partial }} \!\!\!\!\!\!\!\!\! \mathbf {v}\cdot \mathbf {n}_i \; \mathrm {d} \mathbf {s}, \end{aligned}$$
(11)

and the ALE formulation of (8) can be written as

(12)

The additional constraint known as the geometric conservation law (GCL) is beneficial to avoid spurious oscillations and instabilities [84,85,86]. The GCL states that the movement of the computational grid should not affect a uniform solution and it amounts to a suitable computation of the geometrical quantities involved in the grid movement [87]. In this work, the interface velocities defined in (11) are computed in a GCL-compliant fashion by means of the following relations:

$$\begin{aligned} \varDelta V_{ik}^{n+1}= \varDelta t \, \nu _{ik}^{n+1}\qquad \mathrm {and} \qquad \varDelta V_{i,\partial }^{n+1}= \varDelta t \, \nu _i^{n+1}, \end{aligned}$$
(13)

where \(\varDelta V_{ik}^{n+1}\) and \(\varDelta V_{i,\partial }^{n+1}\) are the volumes swept during the time step \(\varDelta t\) by the interfaces \(\partial \mathcal {C}_{ik}\) and \(\partial \mathcal {C}_{i,\partial }\), respectively. Assuming that the positions of the grid nodes at the beginning and at the end of the time step are given, the swept volumes can be easily computed by exploiting geometrical relations, as shown in [35] for triangular grids and in [37] for tetrahedral ones.

Fig. 1
figure 1

Three-step procedure applied to the split of edge \(e_{ik}\). The non-dimensional time \(0 \le \tau \le 1\) is used to describe the different fictitious steps. The dashed gray lines show the grid connectivity in the original/final configuration, while the portions of the finite volumes associated with i, k, and j are shown with light green , light blue , and orange , respectively. The label \(\mathbf {x}_{m_i}\) indicates the barycenter of the element \(m_i\). In the first row the collapse phase \(0< \tau < 0.5\) is depicted: the elements that share the edge \(e_{ik}\) at \(\tau =0\) are collapsed over its mid-point. When they reach a null area, the connectivity is changed (\(\tau =0.5\)): the new point j is inserted, the edge \(e_{ik}\) is split into two edges (ij and kj), and two new edges are created to connect j to \(v_1\) and \(v_2\). The second row displays the expansion phase \(0.5< \tau < 1\): the nodes i, k, \(v_1\), \(v_2\) return to their original positions to reach the final configuration (at \(\zeta =1\))

3.2.1 Extension to variable connectivity grids

The ALE scheme presented in the previous subsection has been extended also to variable connectivity grids. Previous works [35,36,37] detail how to compute the swept volumes \(\varDelta V_{ik}^{n+1}\) and \(\varDelta V_{i,\partial }^{n+1}\) when the local connectivity varies due to mesh adaptation. Connectivity changes are described as fictitious continuous deformations of the involved finite volumes through a series of collapse and expansion operations. More precisely, the following three steps can be defined with the aid of the fictitious dimensionless time \(\tau \) (see also Fig. 1 for an example about edge split in 2D).

  1. 1.

    Collapse, \(0< \tau < 0.5\): all elements involved in the local adaptation collapse into an arbitrary point.

  2. 2.

    Connectivity change, \(\tau = 0.5\): when all involved elements reach null volumes, nodes may be inserted or deleted.

  3. 3.

    Expansion, \(0.5< \tau < 1\): all elements still active (i.e., not deleted at \(\tau =0.5\)) expand to the final configuration.

The collapse and expansion phases are merely continuous deformations from the initial position to the pivotal point, and from it to the final position. Since the positions of these points are known, the volume swept by the involved interfaces can be easily computed from geometrical considerations. Moreover, the fictitious fluxes generated by these deformations can be expressed within the ALE framework as shown for standard fixed-connectivity deformation and included in (10). Conversely, the connectivity change at \(\tau = 0.5\) occurs while the elements have null volume, so no volume is swept by any interface and no flux is exchanged. In this way, we are able to compute the GCL-compliant interface velocities through (13) also when local grid topology is modified and to include the volume changes due to mesh adaptation into the standard ALE scheme, without undermining the fixed-connectivity properties and enforcing conservativeness.

The three steps and the core of the procedure are the same for node insertion, node deletion, or edge swap, both in 2D and 3D; only the involved elements depend on each specific grid modification. The three-step procedure is carried out immediately after each connectivity modification and it is instantaneous, i.e., it starts and ends during the same time step \(\varDelta t\) at which the grid is adapted. Finally, we remark on the local character of the three-step procedure. The interfaces that are not modified by the connectivity change do not take part in three-step procedure, as their contribution would be null since they would sweep the same volume but with different sign during the collapse and the expansion phase [37].

4 Mesh adaptation in unsteady NICFD simulations

The accuracy of the numerical solution of the flow equations is strongly influenced by the grid spacing. For simple geometries or in steady simulations, it is possible to generate a priori a mesh that provides sufficiently small numerical errors with respect to the modeling errors. This task becomes considerably more challenging or impossible for complex flow fields characterized by different spatial scales and in unsteady simulations, where the grid spacing has to be related to the behavior of the solution in an efficient way. Solution-dependent adaptive grid techniques represent a valuable tool to deal with this requirement. More specifically, in unsteady simulations, mesh adaptation techniques may be profitably used to tackle two different tasks: to handle large deformations of the boundaries, and to capture the relevant flow features that originate and move through the domain [80, 88, 89], as outlined in the following subsections.

4.1 Adaptation on flow features

The solution accuracy is here optimized following the equi-distribution principle, whereby the grid spacing is modified to equi-distribute the error over the mesh [90, 91]. The first step of this strategy consists in the definition of an error estimator, based upon the flow solution. It appears evident that an effective error indicator will be extremely advantageous to the entire adaptation process. In the NICFD regime, the error estimators based on the Mach number seem to be more efficient than the density-based ones because of the non-monotone dependence of the Mach number on density along isentropic expansions for supersonic flows at \(\varGamma <1\) [49].

A metric map is used to prescribe the size of grid elements during the mesh modification process. If anisotropic mesh adaptation is performed, the shape and the orientation of the elements are also prescribed [24, 90, 92]. Two different procedures are followed to build isotropic or anisotropic metrics. In the former case, a target grid spacing is computed at each grid node by reducing (or augmenting) the actual average size of the edges connected to the node if the error is greater (or less) than a refinement (coarsening) threshold, prescribed in terms of mean and standard deviation of the estimated error over the domain. Conversely, the anisotropic map is built on the basis of the eigenstructure of the Hessian matrix of a certain solution variable [93], as \({\mathcal {M}} = {R} {\widetilde{\varLambda }} L\), where R and L are the right and left eigenvectors and

$$\begin{aligned} {\widetilde{\varLambda }} ={\mathrm {diag}} \left\{ \min \left( \max \left( \dfrac{c |\lambda _p |}{\epsilon }, \dfrac{1}{\ell _{\mathrm {max}}^2} \right) , \dfrac{1}{\ell _{\mathrm {min}}^2} \right) \right\} , \end{aligned}$$

with \(\lambda _p\) the pth eigenvalue, \(\ell _{\mathrm {max}}\)/\(\ell _{\mathrm {min}}\) the maximum/ minimum edge length, \(c=\frac{k^2}{2(k+1)^2}\) a constant, and \(\epsilon \) a user-defined threshold for the maximum acceptable error, which in all presented computations ranges from \(10^{-7}\) to \(10^{-6}\). More details about the construction of the metric maps can be found in [65, 94, 95].

The metric \({\mathcal {M}}(\mathbf {x})\) is a field of symmetric positive matrices \({\mathbb {R}} ^{k\times k}\) that defines a Riemannian structure over \(\varOmega \). The length of a vector \(\mathbf {w}\) in terms of this map is given by

$$\begin{aligned} ||\mathbf {w} ||_{{\mathcal {M}}} = \sqrt{ \mathbf {w}{^\mathrm {T}} {\mathcal {M}} \mathbf {w} \,}. \end{aligned}$$
(14)

and the goal of mesh adaptation is to obtain a unit mesh with respect to this metric, i.e., a mesh such that \(||\mathbf {w} ||_{{\mathcal {M}}} = 1\) for all edges.

Given the initial grid and the metric \({\mathcal {M}}\), the open-source library Mmg [44, 96] performs automatically a series of different local modifications to make the initial grid as similar as possible to a unit mesh [31]. At first, the length of all grid edges is computed according to (14), then the grid is locally modified both on the interior and on the boundary. Where the edges are too long, the grid spacing is reduced by inserting a new node via element or edge split, or Delaunay triangulation. On the contrary, the nodes connected to edges having \( ||\mathbf {w} ||_{{\mathcal {M}}} \gg 1 \) are removed via edge collapse. Edge swapping and barycentric regularization are also used. In addition, the gradation control technique [97] is exploited to limit the variation in size among adjacent grid elements. All these operations are performed only if they lead to an improvement of the quality of the involved elements, which is defined as

  • for tetrahedra: \(\;Q_m = \alpha \, V_m / \big ( \, \textstyle {\sum }_{i=1}^6 \; \ell _i^2\, \big )^{3/2} \),

  • for triangles: \(\;Q_m = \ell _{\max } \; \sum _{i=1}^3 \; \ell _i \big / (2\;V_m) \),

where \(V_m\) is the volume (or area in 2D) of the element m, \(\ell _i\) is the edge length, \(\ell _{\max }\) is the longest edge in the triangle, and \(\alpha \) is a constant introduced to give \(Q_m=1\) for a regular tetrahedron. It is not possible to specify a maximum or minimum number of grid nodes, but the effect of mesh adaptation can be controlled through the parameter \(\epsilon \) in the anisotropic case, and through the refinement/coarsening thresholds in the isotropic case.

4.2 Large boundary displacements

Mesh adaptation here is exploited also to cope with large boundary movements. At each time step, after the boundary nodes are moved to the new positions, the internal nodes are redistributed keeping the grid connectivity fixed. According to the elastic analogy [79], the largest grid elements account for the major part of the deformation while the smallest ones move almost rigidly. However, when the displacements are large, this strategy may lead to badly shaped or null-volume elements. In such situations, mesh adaptation is exploited to restore grid quality.

As detailed in [94], the displacement to be imposed at the boundary nodes during the time step (labeled as \(\varDelta \mathbf {x}_\mathrm{B}^{n+1}\)) is parameterized by a linear function. If the elastic analogy fails in producing a valid mesh, the displacement is split into smaller portions and the largest portion of \(\varDelta \mathbf {x}_\mathrm{B}^{n+1}\) that leads to a valid mesh is imposed. Then, mesh optimization is carried out aiming only at increasing the quality \(Q_m\) of all elements, not at modifying the grid spacing. In this specific application of mesh adaptation, the edge swapping technique is particularly effective to restore the element quality, while keeping the number of grid nodes constant [29].

4.3 Summary of the computational procedure

Fig. 2
figure 2

Whole adaptive computational procedure for unsteady problems. Mesh deformation is performed: If elastic analogy fails, Mmg is used to modify grid connectivity. The grid \(\mathcal {K}^{n+}\) complies with the boundary displacement \(\varDelta \mathbf {x}_\mathrm{B}^{n+1}\), and over it the solution \(\mathsf {u}^{n+}\) is computed. The metric field \({\mathcal {M}}(\mathsf {u}^{n+})\) is passed as input to Mmg which communicates to the flow solver all performed modifications \(\varDelta \mathcal {K}^{n+}\), so that it can compute the swept volumes \(\varDelta V\). The mesh adaptation procedure, highlighted by the thick dashed line, can be repeated (loop s). Finally, the solution at \(t^{n+1}\) over the adapted grid \(\mathcal {K}^{n+1}\) is computed. The colored and bold symbols denote the variables changed at each step

To summarize, the main steps of the computational procedure adopted for unsteady adaptive simulations are outlined, with reference to Fig. 2. The generic time step \(t^n\le t \le t^{n+1}\) begins with the grid \(\mathcal {K}^n\) and the corresponding solution \(\mathsf {u}(t^n,\mathcal {K}^n)\). Then, the following operations are performed.

Mesh deformation The movement \(\varDelta \mathbf {x}_\mathrm{B}^{n+1}\) is imposed at the boundary and the internal nodes are consequently relocated. If the elastic analogy fails, a mesh optimization stage including edge swapping is performed (see Sect. 4.2). The resulting grid is labeled \(\mathcal {K}^{n+}\) to highlight that it is intermediate, namely it complies with the new geometry but the solution is the previous one.

Prediction The solution \(\mathsf {u}^{n+}=\mathsf {u}(t^{n+1}, \mathcal {K}^{n+})\) is computed over the new grid. This step prevents a delay between the solution-based mesh adaptation and the actual geometry.

Error estimate The metric map \({\mathcal {M}}\) is generated on the basis of the solution \(\mathsf {u}^{n+}\) as summarized in Sect. 4.1.

Mesh adaptation The grid \(\mathcal {K}^{n+}\) and the metric map are used as inputs to the library Mmg, which locally adapts the grid through node insertions, deletions, relocations, and edge swapping.

Mesh update The flow solver receives from Mmg all performed local modifications \(\varDelta \mathcal {K}^{n+}\), that are needed to update the finite-volume discretization and to compute the swept volumes \(\varDelta V_{ik}\), \(\varDelta V_{i,\partial }\) by means of the three-step procedure (see Sect. 3.2.1).

Solution The final solution \(\mathsf {u}^{n+1}\) on the grid \(\mathcal {K}^{n+1}\) is computed, using the solution \(\mathsf {u}^{n+}\) as initial guess.

Steps three to five can be repeated to perform multiple adaptation cycles, as indicated by the loop s in Fig. 2.

The use of the re-mesher library Mmg [44, 96] alleviates the inherent difficulties of mesh adaptation over unstructured three-dimensional grids, which, for instance, requires being able to deal with a variable number of elements involved in each local grid modification or with the multiple options that are available for an edge swapping. The choice to exploit an external library to cope with these tasks allows to implement mesh adaptation techniques into the flow solver efficiently, although some modifications to the Mmg library have been required to exploit the three-step procedure of Sect. 3.2.1.

5 Assessment of the unsteady adaptive method for in NICFD regime

This section presents the first validation of the proposed unsteady method for 2D and 3D problems in the NICFD regime. For the validation of the steady version, the reader is referred to [49]. The geometries of the test cases consist in a simple symmetric wedge in 2D and in a portion of a cone in 3D, exposed to a free stream. As it is known, a steady oblique (conical, in 3D) shock wave is generated to deflect the flow such that it is aligned with the downstream wall. This steady problem can be investigated by means of an unsteady approach if we consider the far-field quiet and the wedge (cone, in 3D) moving at the free stream velocity, namely, if we switch from the body to the laboratory reference frame. Obviously, the thermodynamic variables that are independent from the reference frame, such as the pressure, are the same in the steady and unsteady simulation.

Fig. 3
figure 3

Steady simulation of the non-ideal oblique shock: pressure, Mach contour plots, and grid after five adaptation cycles. Pressure is scaled with respect to the critical value

5.1 Unsteady simulations of an oblique shock

We selected a specific configuration that highlights the potential non-ideal effects in oblique shock waves. As shown in [2], when \(0<\varGamma <1\), the non-monotone variation of the speed of sound along isentropic expansions can result in an increase in the flow Mach number across oblique shock waves, contrary to what is predicted by the perfect gas model. Here, we reproduce one of the tests described in [2] to compare our results with the analytical and numerical solution presented therein. The working fluid is the siloxane \(\mathrm {MDM}\),Footnote 1 and the test conditions are detailed in Table 1. As in the reference, we adopt the polytropic van der Waals model. Further information about the implementation of this thermodynamic model in the flow solver can be found in [49].

Table 1 Test conditions for the oblique shock test, and thermodynamic properties of the working fluid \(\mathrm {MDM}\)

The domain extends from \(x=0\) to \(x=1.7\) and from \(y=-\,0.6\) to \(y=0.6\) (assuming a unitary dimensional reference length of \(1~\mathrm {m}\)). The leading edge of the wedge is at \(x=1.2\), \(y=0\). Although the domain is symmetrical with respect to the line \(y=0\), it is discretized by an unstructured grid, so the symmetry is lost from the numerical point of view. Inflow boundary conditions for density, velocity, and pressure are enforced on the right end-wall, while the far-field and the outflow are modeled by non-reflecting boundary conditions that, where possible, impose only pressure and density. Starting from an initial coarse grid, initialized everywhere with the upstream conditions, three adaptation strategies are performed by imposing three different minimal edge sizes: \(h_\mathrm {min}=\left\{ 0.0008, 0.0004, 0.0002\right\} \). In all cases, an isotropic adaptation criterion is built by blending together the Hessian of the pressure and the gradient of the Mach number. Five adaptation cycles (Prediction, Mesh adaptation, Solution) are performed, and all strategies successfully delivered a refinement of the shock region, up to the minimum prescribed edge size. The results obtained in the steady simulations with \(h_\mathrm {min}=0.0002\) are shown in Fig. 3. Remarkably, the post-shock Mach number is larger than the pre-shock one, thus pointing out the non-ideal nature of the shock. A comparison against the analytical solution is given in Fig. 4: An excellent agreement with the analytical solution is achieved.

Fig. 4
figure 4

Steady and unsteady simulations of the non-ideal oblique shock. Top: different minimal edge sizes at \(\mathrm {Co}=1\). Bottom: \(h_\mathrm {min}=0.0002\) at different Courant numbers. The pressure, scaled with respect to the critical value, is extracted at two locations \(\bar{y}=\pm 0.2\) and compared to the analytical one [2], at three different times: when the wedge displacement is \(\varDelta x =0\) (the results of the steady simulation), \(\varDelta x =-\,0.5\), \(\varDelta x =-\,1\). Only the last portion of the pressure is plotted (for \(x> x_\mathrm {R}-0.5\), with \(x_\mathrm {R}\) the position of the right boundary)

The steady solutions are then used to initialize the unsteady simulations. The free stream velocity is subtracted from the solution and a displacement of \(\varDelta x =-\,1\) at \(M=2\) is imposed to the wedge. With respect to the three different minimal edge sizes, the whole simulation time is divided in \(N_\mathrm {T}=\left\{ 1250, 2500, 5000 \right\} \) steps in order to have a Courant number \(\mathrm {Co}=1\). The top picture in Fig. 4 shows that the initial pressure profile (obtained in the steady simulation) is conserved well during the unsteady computations. As expected, the size \(h_\mathrm {min}=0.0002\) allows to achieve the best results, especially in terms of the post-shock state. The pressure is slightly over-predicted if one uses a lower resolution grid. The symmetry of the problem is recovered in the numerical results, since no differences between the profiles extracted from the lower and the upper part can be appreciated. Further simulations are performed with the highest grid resolution at \(\mathrm {Co}=\left\{ 2, 4 \right\} \), to assess the validity of the adaptive unsteady scheme also at higher Courant numbers. The results, plotted in Figs. 4 (bottom) and 5, agree well with the analytical ones, and the shock resolution is deteriorated only to a small degree by the high Courant number.

Fig. 5
figure 5

Unsteady simulation of the non-ideal oblique shock, with \(h_\mathrm {min}=0.0002\) and \(\mathrm {Co}=2\). Pressure contour plot and grid are shown at three different times, namely when the wedge displacement is \(\varDelta x =-\,0.1\), \(\varDelta x =-\,0.5\), \(\varDelta x =-\,1\)

Fig. 6
figure 6

Steady and unsteady simulations of the non-ideal conical shock, with \(h_\mathrm {min}=0.0002\) and \(\mathrm {Co}=2\). Pressure contour plot and the grid over the \(y=0\) plane are shown at the beginning of the unsteady simulation, i.e., the results of the steady one (left), when the cone displacement is \(\varDelta x =-\,0.1\) (in the middle), and when \(\varDelta x =-\,0.2\) (right)

5.2 Unsteady simulations of a conical shock

A test similar to the one described in the previous subsection is now presented to assess the validity of the proposed method in 3D. The geometry of the test can be viewed as the solid of revolution obtained by rotating half of the domain of the wedge test through 90 degrees about the x-axis. The starting wedge geometry used for the rotation is smaller than the one used in Sect. 5.1, and it extends from \(x=0\) to \(x=0.7\) and from \(y=0\) to \(y=0.3\). In the resulting three-dimensional domain, the far-field is represented by a quarter of a cylindrical surface, and the solid body by a quarter of a conical one. The lateral planes at \(y=0\) and at \(z=0\) are modeled as solid walls to respect the symmetry. For the inflow and the outflow, the same non-reflection conditions used in the oblique shock test are enforced.

An adaptive steady simulation with the free stream conditions given in Table 3 is first performed. Even though the upstream conditions are the same, the flow state downstream of the conical shock differs from the one downstream of the oblique shock, as is well known. No analytical solution of the conical shock waves with van der Waals EoS is available.

The steady results are then used to generate the initial solution for the unsteady computation, which starts from a grid made of 150,633 nodes and 882,581 elements, with a minimum edge size of \(h_\mathrm {min}=0.0002\). A displacement of \(\varDelta x = -\,0.2\) is imposed to the cone and a Courant number of \(\mathrm {Co}=2\) is enforced. The results are shown in Fig. 6. We can observe that the flow field is well conserved during the displacement thanks to the fine grid spacing obtained near the shock as a result of mesh adaptation. Figure 7 confirms the good agreement between the unsteady and the steady pressure fields. Moreover, three planes are sliced at different azimuth angles, and the resulting pressure contours are plotted in the xR plane, where \(R=\sqrt{y^2 + z^2}\). An almost perfect overlap between contour plots over the three planes is achieved, which confirms the capability of the proposed approach to correctly recover the cylindrical symmetry of the flow field. Mesh adaptation plays a crucial role to achieve this result, because only a proper refinement of the grid regions where the flow variations are significant can overcome the asymmetry of the unstructured grid.

6 Numerical investigation of unsteady piston problems

The adaptive computational procedure described in the previous sections is here further assessed through the simulations of different piston problems, in 2D and 3D. The piston problem is a standard gasdynamics test which presents diverse numerical challenges. It models the motion of a piston inside a tube with no gap between the tube and the piston itself. If the piston moves toward the right, the fluid lying in the right part of the tube is compressed, the compression wave moves away from the piston and travels rightwards. Correspondingly, in the left part of the tube an expansion wave is generated and travels toward the left. While these nonlinear waves propagate through the tube, their waveform is distorted. If \(\varGamma >0\), the compressive waves steepen, possibly forming a classical compression shock, and the rarefaction waves spread out. On the contrary, if \(\varGamma <0\), the compressive part of the wave spreads over a longer space as it moves, while the expansion part steepens and it may possibly form a rarefaction shock, the most representative flow structure of the non-classical regime. If the tube is closed, the waves are reflected at the tube ends and interact with the incoming waves, originating a complex flow pattern which contains compression and expansion waves of different intensities, shocks, and contact discontinuities. In addition, the intensity and the type of the perturbation waves can be roughly controlled by the piston motion, thus different tests can be performed. A flow field encompassing simultaneously all these flow features represent a valuable, challenging test to assess the proposed method, since the finite-volume solver is edge-based and the numerical simulations are performed over unstructured grids, so they are inherently multidimensional. Rather, this feature provides an additional opportunity to assess the validity of the proposed method.

Fig. 7
figure 7

Steady and unsteady simulations of the non-ideal conical shock. Contour lines of the pressure over the planes sliced at \(30^\circ \), \(45^\circ \), and \(60^\circ \) extracted at three different times, and plotted in the xR plane, where \(R=\sqrt{y^2 + z^2}\) is the radial distance. The black lines represent the edges of the plane. Five contour lines are plotted, which are \(P/P_\mathrm {c}=\left\{ 0.75, 0.8, 0.85, 0.9, 0.95 \right\} \)

Fig. 8
figure 8

Sketch of the reference piston problem. The piston (P) moves inside a tube, and no gap is modeled between the piston and the tube walls. The letters L and R indicate respectively the right and the left side of the tube, which, according to the test case, can be open-ends or solid walls. The x-axis is placed along the lower side of the tube and \(x=0\) is in the middle of the piston. The length and the height of the piston are \(L_{\mathrm {P}_x} = 0.1~\mathrm {m}\) and \(L_{\mathrm {P}_y} = 0.05~\mathrm {m}\), respectively. The initial position of the left and right piston faces are \(x_0^-= -\,0.05~\mathrm {m}\) and \(x_0^+= 0.05~\mathrm {m}\)

Table 2 Thermodynamic properties for \(\mathrm {MD_4M}\)
Table 3 Initial thermodynamic state for the three tests

The geometry of the reference piston problem is shown in Fig. 8. The tube has different lengths depending on performed tests. For 3D simulations, a square section is assumed, i.e., \(L_{\mathrm {P}_z} = L_{\mathrm {P}_y}\). The tube is filled with the linear siloxane \(\mathrm {MD_4M}\),Footnote 2 which is a high-molecular complexity fluid that presents a quite extended \(\varGamma <1\) region and a small one at \(\varGamma <0\). Table 2 summarized the relevant thermo-physical properties of \(\mathrm {MD_4M}\). As expected, the compressibility factor at the critical point is different from the one predicted by the Peng–Robinson EoS. Indeed, the specific volume computed through the adopted cubic thermodynamic model slightly deviates from the value reported in Table 2.

Initially, the fluid inside the tube is at rest (labeled with subscript 0). Three different initial states are used to investigate peculiar gasdynamic behavior of the fluid: The initial conditions for the dilute (Test\(\mathcal {D}\)) and the NICFD (Test\(\mathcal {NI}\)) regimes are selected along an isotherm above the critical one, while the initial conditions for the non-classical case (Test\(\mathcal {NC}\)) are selected along an isotherm below the critical one. The initial states in all tests are detailed in Table 3, and they are displayed on the \(P-v\) plane, along with the VLE curve, in Fig. 9.

Fig. 9
figure 9

Description of the tests. The thick crosses  display the initial states of the fluid at rest in the tube. For Test\(\mathcal {D}\) and Test\(\mathcal {NI}\), selected along the same isotherm at \(T_0=1.015 T_\mathrm {c}\) (dashed line ), the flow field resulting after one period of oscillation in the infinite-length tube is plotted and colored according to the value of \(\varGamma \). In addition, the VLE curve (black line ) and four curves at constant \(\varGamma \) are displayed. The coordinates are scaled with respect to the critical values reported in Table 2. Note that the critical point coordinates computed by the Peng–Robinson model are not unity, but \(v_c^{\mathrm {PR}}/v_c=1.149\)

In this work, two different types of motion are simulated: a harmonic motion which transfers to the fluid in contact with the piston a sinusoidal perturbation wave, and an impulsive start, which generates instantaneously a shock wave and a rarefaction fan which travel outwards. In the harmonic motion, the position of the piston is set as \( x(t) = x_0(t) + A \cos (2 \pi \,f \, t) \), where A is the amplitude and f the frequency (\(f=30~\mathrm {Hz}\) for all tests). In the other case, the piston impulsively acquires a constant positive velocity \(V_\mathrm {P}= \vert A \pi \,f\vert \), that is half of the maximum velocity experienced by the piston during the harmonic motion. The piston motion represents an additional challenge for the CFD software, as it requires dealing with large deformations, especially in the simulation of the impulsive start, where the piston displacement amounts to more than the \(40 \%\) of the length of the domain.

The harmonic motion is first simulated in a tube with infinite-length to assess the capability of reproducing both the expansion and compressive waves generated by the motion and to observe their distortion. Then, the simulation is repeated considering a closed tube, to assess also the capability to correctly model the interactions with solid boundaries and other waves.

Fig. 10
figure 10

Oscillating piston in an infinite-length tube, Test\(\mathcal {D}\): central portion of the domain, near the piston. Top: pressure contour plots during the first period, initial grid, and grid at \(t=0.2 T\). The motion of the piston is clearly visible (initial position \(x_0^- = -\,0.3\) and \(x_0^+= -\,0.2\)). Bottom: histogram of the number of grid nodes along x-axis, bin width \(\varDelta x=0.05\). A comparison between the grid histogram and the pressure plot highlights the effect of mesh adaptation. For instance, by looking at the right part, at \(t=0.8 T\) the almost equi-spatially distributed contour lines are reflected by the almost uniform grid density. In the left part of the domain, the mesh adaptation leads to an increase in the grid point density as the compressive waves coalesce

Fig. 11
figure 11

Oscillating piston in an infinite-length tube, Test\(\mathcal {NI}\): central portion of the domain, near the piston. Top: pressure contour plots during the first period, initial grid, and grid at \(t=0.2T\). The motion of the piston is clearly visible (initial position \(x_0^- = -\,0.3\) and \(x_0^+= -\,0.2\)). Bottom: histogram of the number of grid nodes along x-axis, bin width \(\varDelta x=0.05\). A comparison between the grid histogram and the pressure plot highlights the effect of mesh adaptation. The peaks in the right part of the domain correspond to the compression that reduces its strength as it travels outwards. The height of the peaks in the left part increases from \(t=0.6T\) to \(t=T\), leading to the strongest refinement in correspondence of the shock wave (around \(x=-\,0.9\) at \(t=T\))

In the following subsections, the exposition and discussion of the results starts from the 2D tests in the NICFD region, with the harmonic motions of the piston in an infinite-length tube and in a finite-length tube, followed by the impulsive start in a closed tube. Then, results concerning the non-classical region are shown for the harmonic motion of the piston in an infinite-length tube, with two different amplitudes. Finally, some 3D results are displayed to show the capability of tackling 3D problems. In all figures of this section, a reference length of \(1~\mathrm {m}\) is used to make all distances dimensionless.

6.1 2D oscillating piston in an infinite-length tube: dilute and non-ideal conditions

The first test case consists in the harmonic motion of the piston in an infinite-length 2D tube, with an amplitude \(A=-\,0.25~\mathrm {m}\). In these simulations, the focus is on the compressive and expansive waves generated by the harmonic motion, so we have limited the influence of the boundary on the flow field by modeling the left and right ends as normal inlets/outlets, and by imposing the tube lengths \(L_\mathrm {L}=L_\mathrm {R}=10~\mathrm {m}\). The initial grid is composed of 6998 triangles and 4502 nodes and three oscillation periods are simulated.

The piston starts moving toward the right. Its velocity progressively increases during the first quarter of the oscillation period, \(0<t<0.25T\), until \(V_{\mathrm {P},\mathrm {max}} = -\,2 \pi f \, A\). During this interval, a compressive wave is generated on the right side of the piston and moves toward the right end of the tube. In the next quarter of the period \(0.25T<t<0.5T\), the piston still moves toward the right but its speed reduces (\(V_\mathrm {P}=0\) at \(t=0.5T\)). This gives rise to an expansion on the right section and a compression on the left part, which continue also in the next quarter of period. At \(t=0.75T\) the velocity of the piston is minimum, \(V_{\mathrm {P},\mathrm {min}} =2 \pi f \, A\) (same magnitude of \(V_{\mathrm {P},\mathrm {max}}\) but negative), then, it increases leading to an expansion on the left side and a compression on the right side, similarly to the first quarter. The flow fields at different times during the first oscillation period are shown in Fig. 10 for Test\(\mathcal {D}\) and in Fig. 11 for Test\(\mathcal {NI}\). The solutions at \(t=T\) are shown also in the Pv plane in Fig. 9, from which the significant variation of \(\varGamma \) in Test\(\mathcal {NI}\) can be appreciated.

During the next periods, the flow field evolves in a similar way. Nevertheless, unlike the ones occurring in the right part at \(0<t<0.25T\), the following compressions are generated by the largest variation of the piston velocity, i.e., from the minimum to the maximum value, or vice versa. Therefore, these waves may coalesce together generating a shock far from the piston side.

Simulations with \(N_T=\left\{ 100, 200, 300 \right\} \) steps per period are carried out to estimate the minimum number that does not impair the solution accuracy. Figures 12 and 13 show the pressure profile obtained with at \(t=1.4 T\) and \(t=1.8 T\) for Test\(\mathcal {D}\) and Test\(\mathcal {NI}\), respectively. For both cases, we can observe that the largest time step leads to a loss of accuracy in proximity of the pressure maxima and minima, while no significant deviations can be noted for the other two time steps. Therefore, \(N_T=200\) steps per period are used in all following simulations. Although the resulting plots appear as single lines, Figs. 12 and 13 are in fact scatters of all points of the unstructured grids. The one-dimensional behavior of the flow is therefore perfectly recovered in both tests, and this gives the first, partial, assessment of the validity of the proposed scheme. Small symmetry disturbances that can be detected in the contour plots of Figs. 10 and 11 are not present in the pressure profiles, and they do not affect the symmetry of the results. In our opinion, they could be ineffective consequences of the unstructured grids, which do not undermine the validity of the proposed approach.

In these tests, an anisotropic metric is built on the basis of the Hessian of the Mach number and two adaptation cycles are performed every time step. More precisely, the estimator is obtained dividing the Hessian by the gradient to reduce the predominance of the strongest phenomena [49]. The beneficial effects of mesh adaptation are clearly displayed by Figs. 10 and 11, which, in addition to the pressure contours, show the histograms of the number of grid points along the x-axis, and two grids. As perturbation waves propagate outwards, mesh adaptation affects a larger portion of the domain, as it can be seen from the grids at \(t=0T\) and \(t=0.2T\) (grids at the next times are not shown since the node density in some regions becomes so high that mesh elements are indistinguishable at this resolution). Exploiting the one-dimensional character of the flow, the grid density at three subsequent times is represented by the histogram of the number of grid nodes in fixed-width bins. This type of graph allows to highlight the effect of mesh adaptation on a broad scale: the grid points are gathered where the flow field exhibits large variations, while the grid density is reduced in correspondence of almost uniform regions. Grid coarsening is of paramount importance in unsteady simulations, since it allows limiting the number of grid nodes. Mesh adaptation allows following flow variations as, for instance, occurs with the compression in the right part of the tube in Fig. 11: the peak in the histogram around \(x=1.15\) at \(t=0.6 T\) is progressively spread and moved toward the left, following the intensity and position of the compression. Moreover, the grid density reflects the strength of the flow variations, as it can be clearly noticed by looking at the compressive waves and the corresponding histogram peaks in the left part of the tube in both tests. Therefore, the proposed approach is capable of linking the grid spacing with the unsteady flow features.

Fig. 12
figure 12

Oscillating piston in an infinite-length tube, Test\(\mathcal {D}\): pressure at time \(t=1.4~T\) (top) and at \(t=1.8~T\) (bottom), obtained with three different numbers of time steps per period: \(N_T=100\) in black , \(N_T=200\) in dark gray  and \(N_T=300\) in light gray 

figure i
. Each point corresponds to a grid node

Fig. 13
figure 13

Oscillating piston in an infinite-length tube, Test\(\mathcal {NI}\): pressure at time \(t=1.4~T\) (top) and at \(t=1.8~T\) (bottom), obtained with three different numbers of time steps per period: \(N_T=100\) in black , \(N_T=200\) in dark gray  and \(N_T=300\) in light gray . Each point corresponds to a grid node

A minor remark about Figs. 10 and 11 concerns the coarsening of the unperturbed regions of the initial grid, resulting, for example, in the different grid spacing for \(x<-1.2\) between the grids at \(t=0\) and \(t=0.2T\) in Fig. 10. According to our experience, an extremely coarse initial grid may jeopardize the development of important flow features, so it is preferable to start with a barely coarse mesh and exploit mesh coarsening already in the first adaptation step, which is carried out after computing the solution in the Prediction step, as explained in Sect. 4.3. If, as in these tests, the maximum edge size allowed during the adaptation is different from the one of the initial grid, and the flow field at the beginning of the simulation embeds large uniform regions, the first adaptation step profoundly modifies the initial grid. The regions that remain uniform during the next time steps are not affected by the following mesh adaptations.

Analysis of the flow behavior in dilute regime. To better analyze the flow behavior, the values of different flow quantities are extracted at fixed locations during the whole simulation time. For Test\(\mathcal {D}\), these quantities are shown in Fig. 14. The results obtained with the Polytropic Peng–Robinson (PPR) EoS are compared to the ones obtained with the polytropic ideal gas (PIG) model, computed starting from the same \(P_0\) and \(T_0\). Although the initial condition of this test lies in the dilute regime where the flow behavior is expected to differ only quantitatively from the ideal gas model, a first, general observation of Fig. 14 reveals that the differences between the two thermodynamic models are significant. The most notable deviations affect the density and speed of sound profiles. We can interpret these deviations as a measure of the non-ideal gas effects. During the simulation, the value of \(\varGamma \) oscillates between 0.83 and 0.96, but the PIG model is not able to detect it, as it predicts a constant \(\varGamma =1.004\). This difference is extremely important, because it is reflected in the speed of sound. Indeed, reminding (1), a value of \(\varGamma \) constant and close to unity results in a constant value of the speed of sound along an isentropic expansion, as shown in the profile for the PIG model. Conversely, for the PPR model, the shape of the profile of c mirrors the one of \(\varGamma \).

The differences on c and \(\rho \) affect the propagation of the discontinuities originated on the piston surface. For weak discontinuities, the acoustic theory links the pressure and velocity perturbation (\(\delta P\) and \(\delta u\), respectively) through the initial acoustic impedance \(\rho _0 c_0\), namely \( \delta P = \rho _0 c_0 \delta u\). This relation suggests that, for the piston problem under investigation here where the only perturbation is the piston movement, if density and sound speed are inaccurate, the same velocity perturbation generates a very different pressure perturbation. For instance, defining the deviation on the pressure as \(E_P = 100 (P^\mathrm {PR} - P^\mathrm {IG})/(P^\mathrm {PR}-P_0)\), the deviations on the maximum and minimum values are

  • at \({\bar{x}}_1=1.0\):    \(E_{P,\mathrm {max}} = 51\%, \qquad E_{P,\mathrm {min}} = 42\%\),

  • at \({\bar{x}}_2=3.0\):    \(E_{P,\mathrm {max}} = 45\%, \qquad E_{P,\mathrm {min}} = 29\%\),

which show the failure of the PIG model to describe the flow behavior in this region, despite a value of \(\varGamma \) near 1.

Fig. 14
figure 14

Oscillating piston in an infinite-length tube, Test\(\mathcal {D}\): temporal evolution of eight thermodynamic quantities at two different locations in the right part of the tube, one near the piston (\({\bar{x}}_1\), dark lines ) and one farther (\({\bar{x}}_2\), light-colored lines ). From the first row to the last one: fundamental derivative, density, speed of sound, acoustic impedance, pressure, x-component of the fluid velocity, wave propagation speed, and Mach number. The results obtained with the polytropic Peng–Robinson EoS (solid lines) and the PIG model (dashed lines) are compared. Pressure, density, and velocities are scaled with respect to the initial values \(P_0\), \(\rho _0\), and \(c_0\) computed with the Polytropic Peng–Robinson model and reported in Table 3. Note that, having kept fixed \(P_0\) and \(T_0\), the initial density and speed of sound computed through the ideal gas are different from those used to scale the values

A further difference that can be observed in the profiles concerns the shape. In the PIG model, the perturbation is propagated from the piston surface through the tube with an almost constant shape, while according to the PPR model the initial sinusoidal shape loses its symmetry and the compression part becomes steeper. This can be explained by watching the quantity \(u+c\), which represents the wave speed in the right part of the piston. For a one-dimensional homentropic flow, the method of characteristics gives

$$\begin{aligned} \mathrm {d} \, (u+c)=\frac{\varGamma }{\rho c} \mathrm {d} P. \end{aligned}$$
(15)

Thus, for the PIG model the higher value of \(\varGamma \) and the lower value of the acoustic impedance generate much faster waves, which take shorter time to reach the same position. Finally, for both models, being \(\varGamma >0\) the compressive part of the wave becomes steeper, until a shock may form, generating a total pressure loss. This phenomenon is captured only by the PPR model, which predicts a faster increase in \(u+c\). For this reason, the profiles at the location farther from the piston surface (\({\bar{x}}_2=3.0\)) display different peak values, although these differences are limited since the shocks are quite weak.

For the sake of completeness, Fig. 14 reports also the Mach number profile, which embeds all the deviation explained above and clearly displays the loss of the initial sinusoidal shape as the maxima and the minima are not equally spaced.

Fig. 15
figure 15

Oscillating piston in an infinite-length tube, Test\(\mathcal {NI}\): temporal evolution of eight thermodynamic quantities at two different locations in the right part of the tube, one near the piston (\({\bar{x}}_1\), dark lines ) and one farther (\({\bar{x}}_2\), light-colored lines ). From the first row to the last one: fundamental derivative, density, speed of sound, acoustic impedance, pressure, x-component of the fluid velocity, wave propagation speed, and Mach number. Pressure, density, and velocities are scaled with respect to the initial values \(P_0\), \(\rho _0\), and \(c_0\) reported in Table 3. The vertical dotted lines () enclose the first region where \(\varGamma >1\), which occurs in the last part of the first compression and in the first part of the next expansion

Analysis of the flow behavior in NICFD regime. The same quantities analyzed for Test\(\mathcal {D}\) are shown in Fig. 15 for Test\(\mathcal {NI}\), which takes place in the core of the NICFD regime, as clearly displayed by Fig. 9. The variations of the fundamental derivative \(\varGamma \) profile are much more significant than the ones in Test\(\mathcal {D}\) and the supercritical regime is also reached, in which the behavior of the flow is more similar to the liquid than the vapor one. A peculiar phenomenon of the NICFD regime can be observed looking at the c profile. According to (1), the variation of the speed of sound during an isentropic expansion is proportional to \(\varGamma -1\). So, in the first part of the expansion where \(\varGamma >1\), the speed of sound decreases, as occurs in ideal gas, while it increases in the second part, where \(\varGamma <1\). Nevertheless, the increase is not sufficiently strong to result in a non-monotone Mach profile. Watching at the other quantities, a behavior similar to the one described for Test\(\mathcal {D}\) can be observed, although the shocks are now stronger, because the lower value of the speed of sound (see \(c_0\) in Table 3) leads, given the same piston velocity, to a higher Mach number. For the same reason, also the wave propagation speed is lower.

The results of the first tests and the previous analysis demonstrate that the proposed method is capable of detecting all expected NICFD phenomena, without introducing spurious oscillations due to mesh adaptation, and it is robust.

Fig. 16
figure 16

Oscillating piston in a finite-length tube, Test\(\mathcal {D}\): pressure contour plots and histograms of the grid nodes (bin width \(\varDelta x=0.05\)), near the right closed end, during the third oscillation period. The first compressive waves originated on the right piston side reach the solid wall after \(t=2T\). The reflected waves interact first with the rarefaction waves and then with the compressive waves, generating a strong shock (approximately around \(x=5.9\) at \(2.65<t/T<2.7\))

Fig. 17
figure 17

Oscillating piston in a finite-length tube, Test\(\mathcal {NI}\): pressure contour plots and histograms of the grid nodes (bin width \(\varDelta x=0.05\)), near the right closed end, during the third oscillation period. The first compressive waves originated on the right piston side reach the solid wall after \(t=2T\). The reflected waves interact first with the rarefaction waves and then with the compressive waves, generating a strong shock (approximately around \(x=4\) at \(2.75<t/T<3\))

6.2 2D oscillating piston in a finite-length tube

In the second type of test, presented here, the piston moves inside a finite-length tube, to simulate the reflection of the waves by solid walls and the interaction between waves with opposite directions. The harmonic motion imposed to the piston is the same one described in the previous section. In Test\(\mathcal {D}\), the lengths of the tube are \(L_\mathrm {L}=10~\mathrm {m}\) and \(L_\mathrm {R}=8~\mathrm {m}\) and the initial grid is composed of 4056 nodes and 6306 triangles. In Test\(\mathcal {NI}\), as the wave propagation speed is lower, the tube is shorter, \(L_\mathrm {L}=8~\mathrm {m}\) and \(L_\mathrm {R}=5~\mathrm {m}\), and the initial grid consists in 2927 nodes and 4548 elements.

The details of the reflection of the waves at the right wall are shown in Figs. 16 and 17. When a compressive wave reaches the right wall, it is reflected back and starts moving upstream, in the direction opposite to the flow. Thus, it interacts first with the expansion waves, reducing its intensity, then it comes into contact with the incoming compressive waves. The interaction between compressive waves of opposite family originates two compressions with different strength that move outwards from the interaction point.

Mesh adaptation is crucial to correctly detect such a complex, variable flow pattern, where the a priori determination of the locations of all relevant flow features is not practical. The histograms of the grid nodes along the x-axis in Figs. 16 and 17 highlight that the grid density is properly modified according to the position and the intensity of the flow variations. In particular, the histograms in Fig. 17 display at times \(t=2.25T\) and \(t=2.5\) two peaks corresponding to the incoming compressive waves (left) and to the reflected one (right) which move toward each other; as the waves coalesce at \(t=2.75T\) only one peak is present; but at \(t=3T\) when the compressive waves go in opposite directions, two refined regions are again generated. So, the present test assesses also the capability of the proposed adaptive method to deal with wave interactions and reflections in the NICFD regime, which is an essential feature to simulate more complex and realistic flow fields.

Fig. 18
figure 18

Impulsively started piston in NICFD regime (Test\(\mathcal {NI}\)): pressure contour plots and grids. At left: the whole computational domain at the initial time and at two instants before reflection of the waves. Right: details of the second shock reflection, which occurs on the right piston surface

Fig. 19
figure 19

Impulsively started piston in NICFD regime (Test\(\mathcal {NI}\)): temporal evolution of pressure (), Mach () and fundamental derivative () at \({\bar{x}}=1.6\) (top) and at \({\bar{x}}=-\,0.8\) (bottom). In the top plot, the dotted line displays the pressure trend obtained analytically. In the bottom plot, the dotted lines show the evolution of the same quantities in case of an open-end tube, i.e., with no reflection

6.3 2D impulsively started piston

The last 2D test case in the NICFD regime is the impulsively started piston in a closed tube, with sizes \(L_\mathrm {L}=1.5~\mathrm {m}\) and \(L_\mathrm {R}=2~\mathrm {m}\). For brevity, only Test\(\mathcal {NI}\) is shown. At time 0, the piston is instantaneously set into motion with a constant velocity \(V_\mathrm {P}=47.12~\mathrm {m/s}\), generating a shock wave in the right part of the tube and an expansion fan in the left part. The simulation is performed until the piston displacement is \(\varDelta x_\mathrm {P}=1.51~\mathrm {m}\), so that the shock is reflected twice, once by the right end of the tube and once by the piston face. The initial grid is composed of 789 nodes and 1574 elements and the whole simulation time is divided in \(N_T=1010\) time steps. On the smallest allowed edge (\(h_\mathrm {min}=0.008~\mathrm {m}\)), the Courant number is \(\mathrm {Co}=1.8\) with respect to the piston velocity, but \(\mathrm {Co}=3.1\) with respect to the velocity of the first generated shock.

Figure 18 displays the results of the flow field before the reflections of the shock and the expansion fan, and after the shock reflection on the piston surface. In these pictures the effectiveness of mesh adaptation is evident, especially after the second reflection, when the strongest shock occurs. A more quantitative view of the results is given by Fig. 19, which shows the pressure, Mach, and fundamental derivative profiles at two constant locations, in the left and right part of the tube. From the evolution of the fundamental derivative, we can say that the left part of the tube remains for the whole test in the NICFD region, \(0<\varGamma <1\), while the right part ends in the supercritical regime. For the location near the left end of the tube, the results of the open-end case are also shown to highlight the velocity decrease imposed by the no-penetration boundary condition. For the location near the right end, the pressure evolution is computed also analytically according to the shock conditions. A fairly good agreement between the analytical and the numerical result is obtained, although a deviation between the pressure values occurs after the second reflection and becomes larger with the third reflection.

This test proves the capability of the proposed adaptive scheme to deal with sudden generation of expansion fans and shock waves in the NICFD regime, as well as with their interaction with solid boundaries. The specification of the maximum tolerated error during the metric construction allows stronger or weaker grid refinement to be achieved according to the strength of the flow phenomena without requiring any user’s action.

Fig. 20
figure 20

Oscillating piston in non-classical region, Test\(\mathcal {NC}\): results of the motion with small (top) and large amplitude (bottom). The flow fields resulting after one period of oscillation in the infinite-length tube are plotted and colored according to the value of \(\varGamma \), by using the same color map. Pressure and specific volumes are scaled with respect to the critical values reported in Table 2

Fig. 21
figure 21

Oscillating piston in non-classical region, Test\(\mathcal {NC}\), small amplitude: temporal evolution of eight thermodynamic quantities at two different locations in the right part of the tube, one near the piston (\({\bar{x}}_1\), dark lines ) and one farther (\({\bar{x}}_2\), light-colored lines ). From the first row to the last one: fundamental derivative, density, speed of sound, acoustic impedance, pressure, x-component of the fluid velocity, wave propagation speed, and Mach number. Pressure, density, and velocities are scaled with respect to the initial values \(P_0\), \(\rho _0\), and \(c_0\) reported in Table 3. For \({\bar{x}}_1\), the vertical dotted lines () highlight the first two points where \(\varGamma =0\)

Fig. 22
figure 22

Oscillating piston in non-classical region, Test\(\mathcal {NC}\), large amplitude: temporal evolution of eight thermodynamic quantities at two different locations in the right part of the tube, one near the piston (\({\bar{x}}_1\), dark lines ) and one farther (\({\bar{x}}_2\), light-colored lines ). From the first row to the last one: fundamental derivative, density, speed of sound, acoustic impedance, pressure, x-component of the fluid velocity, wave propagation speed, and Mach number. Pressure, density, and velocities are scaled with respect to the initial values \(P_0\), \(\rho _0\), and \(c_0\) reported in Table 3. For \({\bar{x}}_1\), the vertical dotted lines () highlight the first three points where \(\varGamma =0\)

6.4 2D oscillating piston in non-classical region

A couple of tests inside and across the non-classical region, at \(\varGamma <0\), are now presented. The piston oscillates harmonically inside an infinite-length tube, but with respect to the previous test cases, the oscillation amplitude is now reduced. More specifically, a small amplitude \(A=-\,0.05~\mathrm {m}\) is selected to constrain the fluid state to lie inside or near the region at \(\varGamma <0\), and a large amplitude \(A=-\,0.15~\mathrm {m}\) is tested to generate stronger perturbations. The evolution of the flow field is shown in the Pv plane in Fig. 20. The flow state evolves in close proximity to the VLE curve, being the initial state on an isotherm below the critical one (\(T_0 = 0.996 T_c\)).

For the motion characterized by the small amplitude, the evolution of different thermodynamic quantities at two fixed locations is displayed in Fig. 21. Since this motion does not introduce strong perturbations, the flow field on the right side of the tube evolves approximately along an isentrope. During the first part of the compression, the flow state moves more inside the non-classical region (see also Fig. 20), reaching a minimum in the value of the fundamental derivative, but during the final part of the compression, \(\varGamma \) slightly increases, as the flow is leaving the core of the non-classical region. From here, the successive expansion crosses the core of the non-classical region and ends in the NICFD region, reaching the maximum value of \(\varGamma \) (equal to 0.187 for the location \(\bar{x_1}\)), from which the next compression starts. Comparing to the NICFD results of Sect. 6.1, the most notable differences concern the acoustic impedance and the wave propagation speed. Indeed, rewriting the fundamental derivative as \(\varGamma =\frac{1}{c}\left( \frac{\partial \rho c}{\partial \rho }\right) _s\), if an isentropic expansion starts in the non-classical region and evolves outwards, the acoustic impedance has a maximum at \(\varGamma =0\). In this specific test, since the initial value of \(\varGamma \) is close to 0, the maximum of the acoustic impedance is extremely close to the initial value, and \(\rho c < \rho _0 c_0\) everywhere. A similar evolution can be observed also for the wave speed, which remains almost everywhere smaller, though close, to the initial value. According to (15), \(\mathrm {d}(u+c)\) is positive in the first part of the expansion (\(\mathrm {d}P<0\) and \(\varGamma <0\)) and negative in the second, and vice versa for the compression. Observing that in this test all pressure maxima occurs at \(\varGamma <0\) and the minima at \(\varGamma >0\), the wave propagation speed has minima when \(\mathrm {d}P=0\) and maxima when \(\varGamma =0\). It is remarkable that such an “acoustic” behavior is obtained for finite amplitude waves because the value of \(\varGamma \) is close to zero [100].

Figure 22 shows the same quantities for the test in which the large oscillation amplitude is imposed. In this test, the flow state already exits the non-classical region during the first compression and most part of the motion occurs in the NICFD region. Therefore, both non-ideal and non-classical phenomena occur. We can observe the non-monotone variation of speed of sound during the isentropic expansion, as seen for Test\(\mathcal {NI}\) in Sect. 6.1. As highlighted for the small-amplitude test, the acoustic impedance has minima and maxima for \(\varGamma =0\) (see the vertical dotted lines in Fig. 22), but these are not the absolute extrema, which occur in correspondence of the extrema of \(\rho \) and c. Similarly, the wave propagation speed exhibits local minima and maxima for \(\varGamma =0\), but the absolute ones reflect the extrema of the pressure, since all points at which \(\mathrm {d}P=0\) fall in the region at \(\varGamma >0\).

Also in these two tests, the proposed mesh adaptation strategy allows the grid spacing to be automatically modified to increase the solution accuracy, without introducing oscillations due to solution interpolation. The importance of this feature can be appreciated by looking at Fig. 20: Some points of the flow field are very close to the VLE curve and oscillations may cause them to enter the two-phase region, where the speed of sound may become negative and ad hoc numerical tools are required for the thermodynamic modeling.

6.5 3D assessment in the NICFD regime

In this final subsection, we briefly present some 3D results to assess the proposed adaptive scheme also for tetrahedral grids. First, we reproduce an oscillating piston in an infinite-length tube, the Test\(\mathcal {NI}\) of Sect. 6.1. The initial grid is made of 27,806 nodes and 97,259 tetrahedra. Given that the physical problem is one-dimensional, we can make a comparison between the results obtained in the 2D and 3D simulations. Figure 23 shows the pressure fields at two different times during the second oscillation period, i.e., at \(t=1.4~T\) and \(t=1.8~T\), which are the same shown in Fig. 13. A good matching between the 3D and 2D pressure profiles is obtained. Furthermore, as observed already in the 2D tests, the profiles in Fig. 23 are in fact scatter plots of all grid points, and the method correctly reproduces the physical one-dimensional behavior of the flow assessing the validity of the proposed approach.

In this test, a target isotropic metric is defined by combining an adaptation criterion based on the Hessian of the Mach number and another criterion based on the gradient of the pressure. A portion of the resulting grids at the previous times is shown in Fig. 24 to highlight the crucial role of mesh adaptation also in 3D. By comparing them with the pressure fields shown in Fig. 23, the grids result to be refined near the sharper variations and coarse in quasi-uniform regions.

Fig. 23
figure 23

Oscillating piston in an infinite-length tube, Test\(\mathcal {NI}\), 3D: pressure contour plot and pressure profile at two different times during the second oscillation period. Pressure is scaled with respect to the critical value. To make clearer the 3D picture, the y- and z-axis have been multiplied by a factor 10 with respect to the x-axis. In the pressure profile, each point corresponds to a grid node

Fig. 24
figure 24

Oscillating piston in an infinite-length tube, Test\(\mathcal {NI}\), 3D: detail of the grid at two different times during the second oscillation period, at \(t=1.4 T\) and \(t=1.8T\). Watching also at the pressure fields shown in Fig. 23, we can notice how the grids are modified according to the solution behavior

Lastly, a test case of the impulsively started piston is performed. We simulate the same physical features described in Sect. 6.3 to be able to compare 2D and 3D results. As in the previous test, three-dimensional isotropic mesh adaptation is performed by exploiting a compound error estimator that includes the Hessian of the Mach number and the gradient of the pressure. The pressure field and the computational grid are shown in Fig. 25 before any wave interaction with the solid wall, and in Fig. 26 after the reflection of the expansion fan on the left side of the tube and the second shock reflection, which occurs on the piston right face. The effect of mesh adaptation is clear, especially after the reflections of the expansion fan and of the shock. In particular, we can observe the grid portion close to the shock reflected by the right piston wall, which is the strongest phenomenon in the flow field, and the one next to the left end of the tube, where the rarefaction fan is reflected. Because of the different intensity of the phenomena, a different level of refinement is automatically performed, i.e., a smaller grid spacing is reached near the shock, without the user’s intervention.

Although concise, these results show that the proposed method works well also for three-dimensional simulations. From the displayed contour plots and pressure profiles, we can notice that no spurious oscillations are introduced by the interpolation-free adaptation and the physical mono-dimensional behavior is achieved.

Fig. 25
figure 25

Impulsively started piston in NICFD regime (Test\(\mathcal {NI}\)), 3D: pressure contour plot, grid and pressure profile, when the piston displacement is \(\varDelta x_\mathrm {P}=0.9\), that is before any wave reflection

Fig. 26
figure 26

Impulsively started piston in NICFD regime (Test\(\mathcal {NI}\)), 3D: pressure contour plot, grid and pressure profile, when the piston displacement is \(\varDelta x_\mathrm {P}=1.5\), that is after the expansion fan has been reflected by the left wall and shock waves have been reflected by the right piston wall (second shock reflection)

7 Conclusions

This paper presents and discusses the assessment of mesh adaptation in unsteady NICFD simulations, since a detailed investigation of the possible extension of standard adaptation techniques, widely used in ideal gas simulations to deal with geometrically complex moving-body problems or to improve the solution accuracy, to such a peculiar thermodynamic regime was missing. Among the available adaptation techniques, we have selected an interpolation-free adaptive scheme capable of representing the volume changes due to mesh adaptation as fictitious continuous deformations of the finite volumes that compose the domain, and of treating them within the ALE framework. In our opinion, this approach represents an advantage for mesh adaptation in the NICFD regime since it prevents the introduction of spurious oscillations due to interpolation, which may unpredictably modify the thermodynamic state of the flow, moving it under the VLE curve.

The proposed method has been assessed through two sets of numerical tests. First, steady simulations of oblique and conical shocks were performed in the unsteady fashion to assess the validity of the numerical scheme. Then, different problems involving a piston moving into a tube filled with \(\mathrm {MD_4M}\) were simulated. Two initial conditions have been selected along an isotherm above the critical one: Test\(\mathcal {D}\) is representative of the dilute regime (approximately \(0.9<\varGamma <1\)) and Test\(\mathcal {NI}\) is more in the core of the NICFD regime. A third initial state has been chosen near the VLE curve, along an isotherm below the critical one, to perform tests across the non-classical and non-ideal region. The thermodynamic behavior of the flow has been described by the polytropic Peng–Robinson EoS. Different simulations of the harmonic motion and the impulsive starting of the piston were performed, both in an infinite-length and in a closed tube.

The expected NICFD and non-classical behavior was well reproduced by the numerical results, and mesh adaptation techniques have been successfully exploited to adapt the computational grid to the unsteady solution. In particular, in all tests, the resulting grid was refined near shocks, rarefaction and expansion waves, and their evolution in the flow field was accurately tracked, even if large deformations were imposed on the domain boundaries. At the same time, the adaptation strategy was capable of removing grid nodes where the solution was smooth, without deteriorating the solution accuracy. Also the interactions between waves and solid walls, or other waves, were correctly treated. No spurious oscillations appeared in the results, despite quite large time steps having been enforced.

In conclusion, the proposed method was assessed to perform adaptive unsteady NICFD simulations. Therefore, in future works it could be successfully exploited to perform more complex unsteady simulations. For instance, it could be useful to devise new experimental test rigs to investigate thermo-physical properties of fluid flows in the NICFD regime, or to improve the design of the components of systems operating in the NICFD regime, as organic Rankine cycles or supercritical carbon dioxide power cycles.