This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

\copyrightinfo

2022The Authors. This work is an open access article under the CC BY-SA 4.0 license \OpenFOAMversionsFOAM-extend 4.1 \Repositoryhttps://bitbucket.org/C_Habes/lcs4foam \DOIPreprint submitted to OpenFOAM Journal

lcs4Foam – An OpenFOAM Function Object to
Compute Lagrangian Coherent Structures

C. Habes1,∗    A. Kameke2,∗    M. E. Fadeli1    H. Marschall1 1Mathematical Modeling and Analysis, Technical University of Darmstadt, 64287 Darmstadt, Germany constantin.habes@tu-darmstadt.de, elwardi.fadeli@tu-darmstadt.de, marschall@mma.tu-darmstadt.de 2Department of Mechanical Engineering and Production Management, Hamburg University of Applied Sciences, 20099 Hamburg, Germany alexandra.vonkameke@haw-hamburg.de
(July 27, 2025)
Abstract

To facilitate the understanding and to quantitatively assess the material transport in fluids, a modern characterisation method has emerged in fluid dynamics in the last decades footed in dynamical systems theory. It allows to examine the most influential material lines which are called Lagrangian Coherent Structures (LCS) and order the material transport into dynamically distinct regions at large scales which resist diffusion or mixing. LCS reveal the robust skeleton of material surfaces and are essential to assess material transport in time-dependent flows quantitatively. Candidates of LCS can be estimated and visualised from finite-time stretching and folding fields by calculating the Finite-Time Lyapunov Exponents (FTLE).

In this contribution, we provide an OpenFOAM function object to compute FTLE during CFD simulation. This enables the OpenFOAM community to assess the geometry of the material transport in any flow quantitatively on-the-fly using principally any OpenFOAM flow solver.

\dedicatory

1 Introduction

Material transport and mixing in fluids is enhanced by advection. This advection is usually described mathematically in an Eulerian view by a time-dependent velocity field 𝐮(𝐮,t)\mathbf{u}(\mathbf{u},\,t). With this Eulerian description, numerous important fluid mechanical characteristics can be derived and assessed. For instance, a higher Reynolds number (higher velocities) typically will go along with better overall mixing. However, such intuition might be misleading as has been shown for example in [1] studying a rising bubble. Here, a coherent structure has been found to arise for intermediate Reynolds numbers, which causes material to move together and locally hinders mixing and increases residence times in the vicinity of the bubble rear. The example shows: a closer look at the coherent structures is necessary to evaluate the details of the material transport in the specific flow situation. Lagrangian Coherent Structures (LCS) are often observable in fluid flows due to the shape that passive tracers take on, e.g. plankton in the ocean [2] or dissolved oxygen in the wake behind a rising bubble.

That the classical Eulerian view on advection is not optimal for addressing these issues was first noted in oceanography and atmospheric science [3, 4]. The transport analysis was therefore started from its roots, the Lagrangian view, where the observer travels on the fluid parcels rather than watching them move by (Eulerian frame). The Lagrangian analysis thus considers the trajectories of individual fluid parcels and allows to draw conclusions on the transport from their evaluation. Nowadays, computational and theoretical advances allow for the calculation and analysis of the time-dependent dynamical system that governs material transport. The underlying ideas for Lagrangian analysis stem from dynamical systems theory. In time-independent incompressible velocity fields, the dynamical system is the velocity field itself and the streamlines of the velocity field coincide with the trajectories of the fluid parcels. As such, trivially, structures in the velocity fields represent governing structures for the material that is transported (as long as molecular diffusion is comparably low and negligible) [5]. In this setting, unstable and stable manifolds divide the flow into different subdomains that move coherently (together) [6]. For time-dependent flows however, the instantaneous streamlines and the trajectories of the fluid parcels do not coincide. It is thus a misleading habit to draw any conclusion about the material transport from the streamlines or any other material lines of the mean velocity field of a fluid flow. The resulting transport structures might have no relevance for the real dynamical system at all.

To obtain the lines that govern material transport in time-dependent flows the Lagrangian Coherent Structures are calculated from the trajectories of particles evaluated in the time-dependent velocity field 𝐮=𝐮(𝐱,t)\mathbf{u}=\mathbf{u}(\mathbf{x},\,t). LCS are those material lines and surfaces that separate regions of particles with very different fates or history for the time interval under consideration. Several different approaches to evaluate LCS have been developed during the last years [7].

With this contribution we introduce an OpenFOAM function object that calculates the three dimensional Finite Time Lyapunov Exponents (FTLE) on-the-fly based on the general purpose numerical library libcfd2lcs [8] with the main computational details explained in [9]. The ridges in the FTLE-field are then candidates for LCS and can be assumed to coincide with LCS if some further conditions are met [10]. However, as also pointed out in [8], these additional conditions are hard to evaluate in 3D and thus the FTLE-field will be viewed as an approximate representation of the 3D LCS. The details about the calculation of the FTLE-field and the underlying mathematical foundation are set out in Section 2.

2 Theoretical background of LCS calculations

From time-resolved CFD simulations, the time-dependent velocity field 𝐮(𝐱,t)\mathbf{u}(\mathbf{x},t) is known in space and time. From this information the fluid parcel or passive particle trajectories

𝐱(𝐱𝟎,t)=𝐱0+t0t𝐮(𝐱(τ),τ)𝑑τ\displaystyle\mathbf{x}(\mathbf{x_{0}},t)=\mathbf{x}_{{0}}+\int_{t_{0}}^{t}\mathbf{u}(\mathbf{x}(\tau),\tau)d\tau (1)

can be calculated, where 𝐱0\mathbf{x}_{0} is the starting point of a trajectory in 3D space at a starting time t0t_{0}. Note, that each trajectory is now labelled by its start location in space and time. If a set of initially close passive particles is released at the same time the distances between them change over time due to the fluid motion. Passive particles initially forming a tiny sphere will undergo a linear deformation towards an ellipse for short times as would occur in a solid body under stress before it breaks. Certainly, in a fluid, the deformation will progress, and non-linear higher-order terms will play a role in causing stretching and folding which is crucial for mixing. However, as a first approximation and for short times these higher-order terms are neglected for the analysis of the deformation. If we consider infinitesimal spheres of initially close particles around all mesh cell centres of our simulation starting at the same initial time t0t_{0}, we obtain a set of different ellipsoids. All these ellipsoids have differently stretched and contracted principal axes which point in different directions at a slightly later time t1t_{1}. The principal axes of each ellipse denominate the final directions of maximal stretching (major axis) and maximal contraction (minor axis) of the initially spherical particle blob. The stretching factor SS is the length of the major axis of the final ellipse divided by the initial radius of the sphere. If this stretching factor at each initial grid point is plotted, a 3D stretching field results revealing the regions at which stretching and thus particle separation for the time interval of interest [t0,t1][t_{0},t_{1}] is largest due to the local flow conditions. Normally, the scaled logarithm of this stretching factor, defined by

σt0t1(𝐱0,t0)=1|t1t0|log(S),\displaystyle\sigma_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)=\frac{1}{\left|t_{1}-t_{0}\right|}\log(S)\;, (2)

is plotted. This scaled logarithmic stretching factor is called the Finite-Time Lyapunov Exponent [11]. Connected areas or lines of large FTLE values characterise the fluid transport as these denote the areas or lines along which deformation and thus particle separation is largest. All these geometrical considerations have their mathematical counterparts. The stretching factor as described is the square root of the maximal eigenvalue of the right Cauchy-Green deformation tensor 𝐂t0t1\mathbf{C}_{t_{0}}^{t_{1}}. This tensor can be calculated for every mesh cell as envisioned above for the ellipsoid. As its name reveals it includes all the information about the deformation of the fluid masses at this point for the short time interval t1t0t_{1}-t_{0}, and notably it is an objective tensor such that high stretching values and candidates for LCS derived from it will persist regardless of the motion of the observer (invariant to a time-dependent translation and rotation of the coordinate system of the observer) [12, 11].

The governing ordinary differential equation (ODE) for the evolution of a fluid parcel or a passive particle reads

𝐱˙=𝐮(𝐱(t),t).\displaystyle\dot{\mathbf{x}}=\mathbf{u}(\mathbf{x}(t),t)\;. (3)

Therefore, the infinitesimal separation γ=𝐱𝐱\mathbf{\gamma}=\mathbf{x}-\mathbf{x}^{*} of the passive particle, imagined in the centre of a infinitesimal sphere, to a particle on the surface of the sphere will be governed by the ODE

δ𝐱˙=𝐮γ.\displaystyle\mathbf{\delta\dot{\mathbf{x}}}=\nabla\mathbf{u}\mathbf{\gamma}\;. (4)

The solution of this ODE is an exponential function, which explains why the FTLE is defined as the logarithm of the stretching factor.

To analyse the stretching during short but finite time intervals, particles distributed on a mesh are advected with the flow from an initial time t0t_{0} over the time interval T=|t1t0|T=\left|t_{1}-t_{0}\right| to t1t_{1}. From the integral version of the governing ODE (Eq. 3) we obtain the definition of the flow map, Φt0t1\Phi_{t_{0}}^{t_{1}}, which maps all the particles from their initial positions onto their final positions at time t1t_{1}, viz.

Φt0t1:nn;𝐱0𝐱0+t0t1𝐮(𝐱(τ),τ)𝑑τ.\Phi_{t_{0}}^{t_{1}}:\mathbb{R}^{n}\rightarrow\mathbb{R}^{n};\quad\mathbf{x}_{0}\mapsto\mathbf{x}_{0}+\int_{t_{0}}^{t_{1}}\mathbf{u}(\mathbf{x}(\tau),\tau)d\tau\;. (5)

To obtain the separation of two initially close particles after this time interval a Taylor series

δ𝐱(t1)=Φt0t1(𝐱0)Φt0t1(𝐱𝟎+δ𝐱(𝐭𝟎))=𝐃𝚽t0t1(𝐱0,t0)δx(t0)+𝒪(|δx(t0)2|)\displaystyle\delta\mathbf{x}(t_{1})=\Phi_{t_{0}}^{t_{1}}(\mathbf{x}_{0})-\Phi_{t_{0}}^{t_{1}}(\mathbf{x_{0}+\delta x(t_{0})})=\mathbf{D}\boldsymbol{\Phi}_{t_{0}}^{t_{1}}(\mathbf{x}_{0},t_{0})\delta x(t_{0})+\mathcal{O}(|\delta x(t_{0})^{2}|) (6)

around the initial position can be employed. Where 𝐃𝚽t0t1(𝐱0,t0)\mathbf{D}\boldsymbol{\Phi}_{t_{0}}^{t_{1}}(\mathbf{x}_{0},t_{0}) is the gradient (Jacobian) of the flow map with regard to the initial separation and is also the normalised fundamental matrix solution of the equation of variations above (Eq. 4) [12]. Therefore, the particle separation at time t1t_{1} can be written as

δ𝐱(t1)=δ𝐱(t0),[𝐃𝚽t0t1(𝐱0,t0)][𝐃𝚽t0t1(𝐱0,t0)]δ𝐱(t0).\displaystyle\left\|\delta\mathbf{x}\left(t_{1}\right)\right\|=\sqrt{\left\langle\delta\mathbf{x}(t_{0}),\left[\mathbf{D}\boldsymbol{\Phi}_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)\right]^{*}\left[\mathbf{D}\boldsymbol{\Phi}_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)\right]\delta\mathbf{x}(t_{0})\right\rangle}. (7)

The right Cauchy-Green deformation tensor is then defined as

𝐂t0t1(𝐱0,t0)=[𝐃Φt0t1(𝐱0,t0)][𝐃Φt0t1(𝐱0,t0)].\displaystyle\mathbf{C}_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)=\left[\mathbf{D}\Phi_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)\right]^{*}\left[\mathbf{D}\Phi_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)\right]\;. (8)

In this way the Finite-Time Lyapunov Exponent σt0t1\sigma_{t_{0}}^{t_{1}} for the time interval t0t_{0} to t1t_{1} can now be defined on the basis of this tensor in a more thorough, mathematical way. Therefore, it is now defined by

σt0t1(𝐱0,t0)=1|t1t0|logλmax(𝐂t0t1(𝐱0,t0)).\displaystyle\sigma_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)=\frac{1}{\left|t_{1}-t_{0}\right|}\log\sqrt{\lambda_{\operatorname{max}}\left(\mathbf{C}_{t_{0}}^{t_{1}}\left(\mathbf{x}_{0},t_{0}\right)\right)}\;. (9)

Here λmax\lambda_{\operatorname{max}} is the maximum eigenvalue of the right Cauchy-Green deformation tensor and can be calculated using standard solvers. In the picture of the small ellipsoid, the square root of the eigenvalue is just the above stretching rate SS.

3 Computational details

The computation of flow maps within libcfd2lcs is described thoroughly in [9]. The following section presents a brief overview of how the computation is done in practice and which different timescales play a role in the calculations. Hereafter, we describe the structure and functionality of the newly developed function object. We will focus on how the function object acts as an interface between OpenFOAM and libcfd2lcs, how parallelisation is ensured and what has to be considered for the output of the generated data.

3.1 Numerical flow map computation in libcfd2lcs

libcfd2lcs is able to calculate both forward-time and backward-time FTLE fields. However, it uses two very different approaches for calculating the respective flow maps. The general approach used for the computation of the forward time flow-map Φt0t0+T\Phi_{t_{0}}^{t_{0}+T} and the resulting forward-time FTLE field is very straightforward. A set of tracer particles is initialised on a grid with spacing Δxlcs\Delta x_{lcs} by setting each initial tracer coordinate to the cell centre coordinate of a corresponding mesh cell. Then the flow map at each cell centre is computed by passively advecting these tracers with the flow, which mathematically corresponds to an integration of equation

d𝐱dt=𝐮(𝐱,t)\displaystyle\frac{d\mathbf{x}}{dt}=\mathbf{u}(\mathbf{x},t) (10)

over the time interval TT. Numerically this integration is done by utilising Runge-Kutta methods, with step size Δtlcs\Delta t_{lcs}. The time and space dependent velocity field 𝐮(𝐱,t)\mathbf{u}(\mathbf{x},t) results from the specific fluid simulation under consideration and is passed to libcfd2lcs after each simulation time step Δtsim\Delta t_{sim} (see Section 3.2). In order to save the flow map Φt0t0+T\Phi_{t_{0}}^{t_{0}+T}, the location of each particle after the integration is stored at its initial position.

As the evaluation of FTLE fields, indicating LCS candidates, is mainly relevant for time-dependent flows, it is often important to animate their evolution. At first glance, this would mean that a sequence of large particle sets would have to be integrated, requiring a great amount of computation. This problem is solved using a method developed by Brunton and Rowley [13]. With this method a flow map of the interval TT can be constructed from a sequence of kk flow maps over a smaller interval hh, where T=khT=kh. Following the notation of [13] this can be expressed as

Φt0t0+T=Φt0+(k1)ht0+khΦt0+ht0+2hΦt0t0+h.\Phi_{t_{0}}^{t_{0}+T}=\Phi_{t_{0}+(k-1)h}^{t_{0}+kh}\circ\cdots\circ\Phi_{t_{0}+h}^{t_{0}+2h}\circ\Phi_{t_{0}}^{t_{0}+h}\;. (11)

In practical terms, this means that the particle grid is reinitialised for every new time interval hh after which they are advected again with the flow. Then the sub-step flow map is stored and the complete flow map is constructed when all needed sub-step flow maps are available. It is important to note that since a discrete particle grid is used for the sub-step flow map computation, interpolation of the sub-step flow maps is needed in order to match the trajectories at different timelevels when reconstructing the flow map Φt0t0+T\Phi_{t_{0}}^{t_{0}+T} (see [13] for more details).

A different approach for constructing the backward-time flow maps is used. This is due to the fact that using the Lagrangian approach would require to store all computed velocity fields in the subset interval hh before the integration of the tracers from t0+ht_{0}+h to t0t_{0} could be done backward in time. Although this already includes Brunton’s and Rowley’s method for the flow map construction, the Lagrangian approach would be ”cumbersome and resource intensive” [9, p. 4]. Therefore, libcfd2lcs uses an Eulerian approach for the flow map computation proposed by Leung [14]. In contrast to the forward-time flow map, the backward-time flow map Φt0+Tt0\Phi_{t_{0}+T}^{t_{0}} describes for each grid point where a particle, that is at that point at time t0+Tt_{0}+T, originally was at time t0t_{0}. With Leung’s Eulerian approach this backward-time flow map at time t0+Tt_{0}+T is computed by initialising a vector field 𝚿(𝐱,t0)\mathbf{\Psi}(\mathbf{x},t_{0}) on a grid with the cell centre coordinates at time t0t_{0}. The advection of this so called ”takeoff coordinate field” in an Eulerian reference frame is then described by the level set equation

𝚿(𝐱,t)t+(𝐮)𝚿(𝐱,t)=𝟎.\frac{\partial\mathbf{\Psi}(\mathbf{x},t)}{\partial t}+(\mathbf{u}\cdot\nabla)\mathbf{\Psi}(\mathbf{x},t)=\mathbf{0}\;. (12)

Solving this equation over the time Interval [t0,t0+T][t_{0},t_{0}+T] in forward time gives 𝚿(𝐱,t0+T)\mathbf{\Psi}(\mathbf{x},t_{0}+T), which represents the takeoff coordinates of a Lagrangian particle at t0t_{0} reaching 𝐱\mathbf{x} at time t0+Tt_{0}+T. Thus, the backward-time flow map Φt0+Tt0\Phi_{t_{0}+T}^{t_{0}} is equivalent to 𝚿(𝐱,t0+T)\mathbf{\Psi}(\mathbf{x},t_{0}+T). libcfd2lcs solves equation (12) by using a semi-Lagrangian advection approach with the time step size

Δtlcs=ccflΔxlcs𝐮(𝐱,t)\Delta t_{lcs}=\frac{c_{cfl}\,\Delta x_{lcs}}{\mathbf{u}(\mathbf{x},t)} (13)

of this procedure being restricted by the CFL condition ccfl<1c_{cfl}<1 (see [9] and [14] for more details). Furthermore, Brunton’s and Rowley’s flow map construction method is also applied to the backward-time flow maps computed with the Eulerian method. Hence, the takeoff coordinate field is reinitialised after every sub-step time interval hh and the backward-time flow map

Φt0+Tt0=Φt0+ht0Φt0+2ht0+hΦt0+kht0+(k1)h\Phi_{t_{0}+T}^{t_{0}}=\Phi_{t_{0}+h}^{t_{0}}\circ\Phi_{t_{0}+2h}^{t_{0}+h}\circ\cdots\circ\Phi_{t_{0}+kh}^{t_{0}+(k-1)h} (14)

is constructed form kk sub-step backward-time flow maps.

Refer to caption
Figure 1: Different timescales relevant for the LCS evaluation

Since a lot of different timescales are relevant in the practical FTLE field computation described above, we try to differentiate and order them in the following, before describing the structure and functionality of the newly developed function object in the next section. The basis of the on-the-fly LCS evaluation is a parallel running simulation that provides the velocity fields. Here, three intervals are of interest (see Fig. 1): the overall simulation time that spans from the simulation start time tsim_startt_{sim\_start} to the simulation end time tsim_endt_{sim\_end}, the time step size of the simulation Δtsim\Delta t_{sim} and the write time interval of the simulation results Δtsim_write\Delta t_{sim\_write}. The computed velocity fields represent a fluid flow for which a reference timescale Δtref\Delta t_{ref} can be identified. This reference timescale characterises the dominant hydrodynamic timescale of the flow and is typically larger than the simulation time step size. In order to save computing resources the LCS evaluation of the simulated flow does not necessarily have to start and end at the same time as the simulation. Therefore, a separate start and end time for the LCS evaluation denoted as tlcs_startt_{lcs\_start} and tlcs_endt_{lcs\_end} can be defined (see Fig. 1). During the LCS evaluation, a series of FTLE fields are computed. These FTLE fields are calculated from time TT flow maps, which themselves are calculated as described earlier in this section. This means storing and constructing the time TT flow maps from multiple sub-step flow maps after each LCS sub-step integration interval hh. Calculating the sub-step flow maps in turn requires to numerically solve the equations (10) or (12) using the finite time step Δtlcs\Delta t_{lcs}. While Δtlcs\Delta t_{lcs} is set automatically according to equation (13) and a specified CFL number, TT and hh have to be defined by the user. In order to detect all LCS candidates, TT is usually chosen to be larger than Δtref\Delta t_{ref} of the investigated flow [9]. With the aim of animating the evolution of the FTLE field, hh is typically set significantly smaller than Δtref\Delta t_{ref} while being in the order of magnitude of Δtsim_write\Delta t_{sim\_write}.

3.2 Structure and functionality of the function object

In general, function objects can be used to generate additional data at runtime of the simulation. In doing so, function objects can access data generated by the flow solver at runtime, which offers a great advantage over classical post-processing since it can only utilise the stored fields or logged information. The newly developed function object incorporates the functionalities of libcfd2lcs into OpenFOAM at runtime while acting as an interface between both. This is achieved by processing the data generated by OpenFOAM and the subsequent exchange of this data via the libcfd2lcs API (see [8] for a detailed description of the libcfd2lcs API).

The calculation of the flow maps, the calculation of the resulting FTLE fields and the subsequent saving of these fields is completely handled by libcfd2lcs. The basic task of the function object is to pass the cell centre position vectors of the computational grid as well as the velocity field calculated by OpenFOAM to libcfd2lcs. Due to the very strict data structure requirements of libcfd2lcs this is not a trivial task. libcfd2lcs can only use static rectlinear grids for the calculation of forward-time and backward-time flow maps and therefore needs the velocity fields on these grids. This means that the mesh and velocity data has to be globally organised in an (i,j,k)(i,\,j,\,k) structured format [8, p. 6]. Since the LCS evaluation should also be available for simulations on moving grids with general topology and adaptive grid refinement, the function object offers several possibilities to deal with this problem.

In the simplest case, where the simulation mesh is already a static rectlinear mesh, the function object does not need to process the grid and velocity data, but can directly transfer it to libcfd2lcs as basic C++ arrays. This is the preferred method when the flow domain can be represented by a static rectlinear mesh and e.g. immersed boundary methods are used. If a moving mesh, a mesh of general topology or adaptive mesh refinement is used for the simulation a different approach is needed in order to prepare the data for its use in libcfd2lcs. Here, an additional static rectlinear mesh needs to be constructed in the preprocessing step, which can be done e.g. by using the blockMesh utility. This mesh has to contain the region for which the LCS diagnostic should be performed, meaning that it can cover the whole simulation domain as well as only a part of it. However, since libcfd2lcs also requires boundary conditions for the FTLE field calculations, the boundary patches of the additional LCS mesh must be set accordingly. The user can choose between empty, symmetryPlane, wedge, cyclic and the generic patch patch types which the function objects translates into the corresponding libcfd2lcs boundary types. Then, during runtime, the velocity fields are mapped from the simulation mesh of general topology to the static rectlinear LCS mesh, from which the data can again be transferred to libcfd2lcs as basic C++ arrays. Although this implies that interpolation errors are made during the mapping process, the LCS evaluation is hardly affected by this. Haller showed in [15] that LCS are very robust against errors in the velocity field. Also, the additional computational overhead due to the mapping can be neglected compared to the overhead caused by the flow map computations. The function object also implements a third approach in which no additional LCS mesh is needed. This approach utilises the ability to construct complex, moving mesh geometries out of simple unconnected mesh regions in OpenFOAM with the oversetMesh approach. Using this approach the function object can utilise any specified static rectlinear mesh region of the oversetMesh for the LCS evaluation, meaning that the background mesh as well as any other static rectlinear mesh region can be used. In doing so, the function object extracts the mesh and velocity data from the specified mesh region of the oversetMesh and passes it to libcfd2lcs analogously to the previous approaches. Here the overset type patches are generally passed on as inlet or outlet, as they are treated the same by libcfd2lcs.

As libcfd2lcs also uses the domain decomposition approach and MPI for the parallelisation of the computations, the integration within the parallelisation of OpenFOAM is done in a straightforward manner. The local subdomains of the rectlinear LCS mesh and its velocity data are passed to libcfd2lcs together with an offset, which describes the position of the cell data in the globally (i,j,k)(i,\,j,\,k) structured data array (see Fig. 2). For the MPI communication, the same MPI communicator as used for OpenFOAM is shared with libcfd2lcs. Therefore, the function object can be used for simulations running in parallel or serial. However, if the approach involving an additional LCS mesh is used, special attention is required for the domain decomposition in the preprocessing step. Here the simulation mesh, as well as the LCS mesh, must be cut along the same surfaces to make sure that the mapping of the velocity fields from one mesh to the other works properly.

Refer to caption
Figure 2: Subdomain offset of a i,j,(k=0)i,\,j,\,(k=0) structured rectlinear mesh

As already mentioned, the data output of the flow-map and FTLE field data is completely handled by libcfd2lcs. This is due to the fact that the data output interval defined by hh can differ from the solver write interval Δtsim_write\Delta t_{sim\_write} (see section 3.1). Therefore, the results generated by the function object are not stored in corresponding time directories but in a separate folder in the case directory called cfd2lcs_output. Additionally, a directory named cfd2lcs_temp is created inside of which all the sub-step data is stored. All data is stored in the Tecplot ASCII data file format (*.dat) and therefore can be visualised in ParaView when opened with its internal Tecplot reader or other common visualisation programs. In addition to this data, the computational overhead generated by the use of the function object with respect to the actual simulation is also output in the solver log file after each simulation time step. This enables the user to examine the computational costs of the LCS evaluation.

4 Examples of usage

In this section a few examples are presented which are designed to show the functionality and capabilities of the function object. Therefore, example cases are presented in which only a rectlinear simulation mesh, a separate simulation and LCS mesh and a single oversetMesh are used.

4.1 Steady ABC flow

The Arnold-Beltrami-Childress (ABC) flow is an exact periodic solution of the Euler equations and is often used in the literature to verify LCS calculation methods. Therefore this case is also being reviewed here. The velocity field

𝐮=×[Ψ𝐤+×(Φ𝐤)]\displaystyle\mathbf{u}=\nabla\times[-\Psi\mathbf{k}+\nabla\times(\Phi\mathbf{k})] (15)

of the ABC flow can be described using 2 scalar potentials Ψ\Psi and Φ\Phi [16] which themselves are defined as

Ψ=[Csin(y)+Bcos(x)]Φ=A[xcos(z)+ysin(z)]Ψ.\displaystyle\begin{aligned} &\Psi=-[C\sin(y)+B\cos(x)]\\ &\Phi=A[-x\cos(z)+y\sin(z)]-\Psi\;.\end{aligned} (16)

In (15), 𝐤\mathbf{k} can be any unit vector but is commonly chosen to be the vertical unit vector. This leads to the three expressions of the velocity components

u=Asin(z)+Ccos(y)v=Bsin(x)+Acos(z)w=Csin(y)+Bcos(x).\displaystyle\begin{aligned} &u=A\sin(z)+C\cos(y)\\ &v=B\sin(x)+A\cos(z)\\ &w=C\sin(y)+B\cos(x)\;.\end{aligned} (17)
Refer to caption
(a) Forward-time FTLE field for the whole computational domain
Refer to caption
(b) Backward-time FTLE field for the whole computational domain
Refer to caption
(c) Forward-time field for a cross-section at z=2πz=2\pi
Refer to caption
(d) Backward-time field for a cross-section at z=2πz=2\pi
Refer to caption
Figure 3: FTLE fields of a stationary ABC flow

The parameters AA, BB and CC can be freely selected and influence the properties of the ABC flow. In order to create comparability with literature values, A=0.5A=0.5, B=0.8B=0.8, C=0.8C=0.8 is chosen. In order to test the newly developed function object on this flow configuration a dedicated ABC flow OpenFOAM solver was written. This solver does not solve the Euler equations in the usual sense, but sets the velocity components on a given computational mesh according to (17). Due to the periodicity of the flow solution, the dimensions of the computational mesh used in this case setup are specified as x,y,z[0,2π]x,y,z\in[0,2\pi] with a mesh size of 100×100×100100\times 100\times 100. Since the described mesh is rectlinear no additional LCS mesh is used. Again for reasons of comparability, a LCS integration time of T=10sT=10\mathrm{s} is selected for the LCS evaluation. The results of the LCS evaluation, both in forward- and backward-time, can be seen in Figure 3.

In these results the FTLE ridges, which indicate the LCS candidates in the ABC flow, can be seen very clearly. Furthermore, the results agree very well with the results from [16], both qualitatively and quantitatively, which suggests that the new function object calculates the FTLE ridges reliably.

4.2 Time dependent double gyre

Another frequently used flow for the verification of LCS computing algorithms is the time periodic Rayleigh-Bénard convection flow, or often called double gyre, proposed by Solomon and Gollub [17]. The velocity field of this flow can be describe by using a stream function ψ\psi

u=ψyv=ψx.\displaystyle\begin{aligned} &u=-\frac{\partial\psi}{\partial y}\\ &v=\frac{\partial\psi}{\partial x}\;.\end{aligned} (18)

Here ψ\psi is defined by

ψ(x,y,t)=Asin(πf(x,t))sin(πy)\displaystyle\psi(x,y,t)=A\sin(\pi f(x,t))\sin(\pi y) (19)

with

f(x,t)=a(t)x2+b(t)xa(t)=ϵsin(ωt)b(t)=12ϵsin(ωt)\displaystyle\begin{aligned} &f(x,t)=a(t)x^{2}+b(t)x\\ &a(t)=\epsilon\sin(\omega t)\\ &b(t)=1-2\epsilon\sin(\omega t)\end{aligned} (20)

This leads to the expressions for two-dimensional velocity components

u=πAsin(πf(x))cos(πy)v=πAcos(πf(x))sin(πy)dfdx.\displaystyle\begin{aligned} &u=-\pi A\sin(\pi f(x))\cos(\pi y)\\ &v=\pi A\cos(\pi f(x))\sin(\pi y)\frac{\mathrm{d}f}{\mathrm{~d}x}\;.\end{aligned} (21)

As the name double gyre suggests, this model defines the flow of two two-dimensional gyres enclosed in a rectangle which expand and contract periodically along the x-axis. Therefore, the periodic motion is controlled by ϵ\epsilon if ϵ0\epsilon\neq 0. Then ϵ\epsilon describes approximately how far the line separating the gyres moves to the left or right from its centre position [11]. Otherwise (ϵ=0\epsilon=0), no periodic motion is happening. Furthermore, AA specifies the magnitude of the velocity vectors and ω/2π\omega/2\pi determines the oscillation frequency of the gyres.

Refer to caption
(a) Forward-time FTLE field
Refer to caption
(b) Backward-time FTLE field
Refer to caption
Figure 4: FTLE fields of a time-dependent double gyre at t=15st=15\mathrm{s}.

Similar to the ABC flow example, a dedicated OpenFOAM solver was written for this case, which sets the velocity field on a given computational mesh according to (21). For comparability, a mesh with the same specifications as in [18],[14] and [11] was used. It has the dimensions [0,2]×[0,1]×[0,0.1]m{[0,2]\times[0,1]\times[0,0.1]}m and a resolution of 512×256×1512\times 256\times 1 cells. As this mesh is also static and rectlinear no additional LCS mesh was used. For the mathematical model of the flow the parameter values are chosen to be ϵ=0.1\epsilon=0.1, A=0.1ms1A=0.1\mathrm{m}\,\mathrm{s}^{-1} and ω=2π/10s\omega=2\pi/10\mathrm{s}. Since the oscillation frequency is known, the hydrodynamic time scale can be easily determined by tref=2π/ω=10st_{ref}=2\pi/\omega=10\mathrm{s}. As described in section 3.1, the LCS integration time interval TT should be set larger than treft_{ref}. Therefore, it is set to T=1.5tref=15sT=1.5\cdot t_{ref}=15\mathrm{s}. Figure 4 shows the forward- and backward-time FTLE fields at t=15st=15\mathrm{s} of the previously described double gyre flow. Again, the results match very well with the results from [18],[14] and [11]. This confirms that the function object is able to calculate the correct FTLE fields from velocity fields generated by OpenFOAM.

4.3 Flow around cylinder

As it has already been shown in the previous examples that the function object can calculate the correct FTLE fields from velocity fields provided by OpenFOAM, this example will focus on how to deal with non-rectlinear simulation meshes. For this purpose, a standard flow problem is selected that is very well suited for an LCS evaluation: the flow around an infinitely long cylinder. The general case setup contains a fluid domain with size [20,30]×[20,20]×[0.5,0.5]m{[-20,30]\times[-20,20]\times[-0.5,0.5]}\mathrm{m} that surrounds a cylinder with diameter D=2mD=2\mathrm{m} and its centre axis at x=y=0mx=y=0\mathrm{m}. The free-stream velocity and the fluids kinematic viscosity are set to 𝐮𝖳=(1 0 0)ms1\mathbf{u}^{\sf T}=(1\;0\;0)\mathrm{m}\,\mathrm{s}^{-1} and ν=0.01m2s1\nu=0.01\mathrm{m}^{2}\mathrm{s}^{-1}, respectively. This results in a Reynolds number of Re=200\operatorname{Re}=200 which indicates that vortex shedding behind the cylinder occurs in a barely laminar regime. If we also assume a Strouhal number of St=0.2\operatorname{St}=0.2 at Re=200\operatorname{Re}=200, the hydrodynamic time scale of this flow is tref=D/(uSt)=10st_{ref}=D/(u\cdot\operatorname{St})=10\mathrm{s}.

Because of the cylinder in the middle of the domain, a computational mesh discretising this domain is no longer rectlinear. Therefore, we consider two different procedures in the LCS evaluation, the first of which is carried out in two different ways.

Refer to caption
(a) Non rectlinear simulation mesh
Refer to caption
(b) LCS mesh enclosing the whole domain
Refer to caption
(c) Forward-time FTLE field
Refer to caption
(d) Backward-time FTLE field
Refer to caption
Figure 5: Simulation mesh, LCS mesh and FTLE fields of a flow around a cylinder with Re=200\operatorname{Re}=200 at t=118st=118\mathrm{s}.

Starting with the procedure where an additional rectlinear computational mesh is used for the LCS evaluation, the flow domain is discretised with a simulation mesh consisting of 9200 hexahedra (see upper left mesh in Fig. 5). The flow solver that is used to simulate the previously described flow from t=0st=0\mathrm{s} to t=120st=120\mathrm{s} is pimpleFoam with the initial conditions being calculated by potentialFoam. The first additional LCS mesh that is used within this procedure encloses the whole flow domain (see upper right mesh in Fig. 5). In order to minimise the loss of information during the mapping of the velocity fields between the two grids, the resolution of the LCS mesh is chosen in a way that it corresponds approximately to the finest resolution in the simulation mesh. This leads to a LCS mesh with 200×160×1200\times 160\times 1 hexahedra. The boundary patch types are set to patch for the left and right patch (inlet,outlet), to symmetryPlane for the bottom and top patch and to empty for the front and back patch. The LCS integration time TT is again based on treft_{ref} and is set to T=1.5tref=15sT=1.5\cdot t_{ref}=15\mathrm{s}. For a good animation of the dynamics of the FTLE fields hh is chosen to be h=T/10=1.5sh=T/10=1.5\mathrm{s}. The results of the forward- and backward-time FTLE fields can be seen in Fig. 5. They show how the vortices behind the cylinder form large coherent structures, where the FTLE ridges of the backward-time FTLE fields separate different fluid packages that do not mix in the vortex street.

Refer to caption
(a) Non rectlinear simulation mesh
Refer to caption
(b) LCS mesh enclosing the region of interest
Refer to caption
(c) Forward-time FTLE field
Refer to caption
(d) Backward-time FTLE field
Refer to caption
Figure 6: Simulation mesh, LCS mesh and FTLE fields of a flow around a cylinder with Re=200\operatorname{Re}=200 at t=118st=118\mathrm{s}.

Since the FTLE ridges only appear in a fraction of the overall domain and the LCS evaluation is computation-wise a quite costly operation, a second LCS mesh is prepared. This second LCS mesh is a lot smaller than the first one and encloses only the fraction of the flow domain where the FTLE ridges are expected to show up (see Fig. 6). The boundary patches on the smaller LCS mesh and its spacial resolution are also set analogous to its bigger counterpart, leading to a LCS mesh of size [13,27]×[7.5,7.5]×[0.5,0.5][-13,27]\times[-7.5,7.5]\times[-0.5,0.5] containing 160×60×1160\times 60\times 1 hexahedra. Repeating the computations with the use of the smaller LCS mesh gives the results which are displayed in Fig. 6 and are found to match with the results from the bigger LCS mesh. This shows that the LCS evaluation, when done with a separate LCS mesh, can be used in a very targeted way. The advantages this brings in terms of computational costs are discussed after considering the second procedure for the LCS evaluation of this flow problem.

Refer to caption
(a) oversetMesh containing a rectlinear background mesh zone, a rectlinear refinement zone which is also used for the LCS evaluation, and a cylindrical mesh zone containing the cylinder.
Refer to caption
(b) Forward-time FTLE field
Refer to caption
(c) Backward-time FTLE field
Refer to caption
Figure 7: oversetMesh and FTLE fields of a flow around a cylinder with Re=200\operatorname{Re}=200 at t=118st=118\,\mathrm{s}.

The second procedure, which can be used on problems where no single static rectlinear mesh can be constructed, utilises OpenFOAM’s oversetMesh functionalities. With regard to the flow problem considered here, an oversetMesh is constructed with the same dimensions as the simulation mesh used previously. It consists of three mesh zones, namely a rectlinear background mesh zone that spans the whole fluid domain, another finer and smaller mesh zone that is used for a finer resolution of the flow and a cylindrical mesh that surrounds the cylinder (see Fig. 7). For comparability reasons the finer rectlinear mesh zone has the same dimensions and resolution as the smaller additional LCS mesh considered previously and is therefore specified as the cell zone for the LCS evaluation. Also all other LCS evaluation settings are adopted. The only difference to the previously considered simulations is the used flow solver. Here the flow solver is pimpleDyMOversetFoam due to the used oversetMesh. The resulting forward- and backward-time FTLE fields of this simulation can be found in Fig. 7. They match with the results from the previously considered procedure which shows that both approaches can be used equally well. The only thing that stands out are the high FTLE values along some boundaries in the studied solutions. These occur because of the way libcfd2lcs handles its inlet and outlet boundary conditions. It fixes out-flowing Lagrangian particles/takeoff coordinates on ”open” boundaries and cannot generate new in-flowing particles during the flow map computation. Therefore, high FTLE values occur in the forward-time FTLE fields at ”open” boundaries where inflow occurs, since there the most ”stretching” happens. Vice versa, high FTLE values occur in the backward-time FTLE fields at ”open” boundaries where outflow occurs, since there the most ”folding” happens. These high values at ”open” boundaries are just artefacts and have to be neglected. The reason they appear more in the oversetMesh approach is that all overset type patches are passed to libcfd2lcs as ”open” boundaries whereas the user can specify all patches problem dependent in the additional LCS mesh approach.

Looking at the computation times of the flow calculations including the LCS evaluation, it becomes evident that LCS evaluation is a very costly operation (see Tab. 1). When using the ”large” additional LCS mesh the simulation takes approximately 30 time longer than without the LCS evaluation. This can be improved by using the smaller additional LCS mesh. Here the simulation takes 9 times longer than without the LCS evaluation. Since the costs for the LCS evaluations are almost independent of the underlying simulation for a constant grid size, this factor becomes smaller and smaller for more complex simulations. This can also be seen from the fact that the factor is only 2.5 when the oversetMesh approach is used because the computations of the pressure and velocity fields take longer on an oversetMesh. At this point, however, it must be emphasised that the flow considered here is not a highly complex problem, which can also be seen from the simulation time of 1.5 min on a normal mesh and 8 min on an oversetMesh.

”large” add. LCS mesh ”small” add. LCS mesh oversetMesh
Total time 44 13.5 20
Simulation time 1.5 1.5 8
Total FTLE comp. time 42.5 12 12
Fwd.-FTLE comp. time 8.5 2 2
Bkwd.-FTLE comp. time 21 6 6
I/O, flow map const., … 13 4 4
Table 1: Computing times in minutes for the flow simulation including LCS evaluation on 2 cores of a Intel Core i5 processor

5 Summary & Conclusion

We provide an OpenFOAM function object based on libcfd2lcs to compute Finite-Time Lyapunov Exponent (FTLE) fields that indicate candidates of Lagrangian Coherent Structures (LCS) and allow to visualise finite-time stretching and folding fields. LCS reveal the robust skeleton of material surfaces and are key to quantitatively assess material transport in time-dependent flows. This enables the OpenFOAM community to assess the geometry of the material transport in any flow quantitatively on-the-fly using principally any OpenFOAM flow solver.

Focusing on the practical aspects, we only give a brief overview of the mathematical foundation as well as how the computation is done in practice. We describe the structure and functionality of the newly developed function object. Further focus is laid on how the function object acts as an interface between OpenFOAM and libcfd2lcs, how parallelisation is ensured and what has to be considered for the output of the generated data.

From validation of the presented function object using simple benchmark problems, a notable computational overhead has been recognised. However, if LCS evaluations are used for much more complex problems as the ones used here, the computational overhead significantly drops and the LCS evaluation no longer accounts for the largest proportion of the computation time. Nevertheless, the user should be aware that the calculation of FTLE fields is expensive and should therefore think carefully about the size and position of the LCS mesh. In addition, consideration should also be given to whether both forward and backward-time FTLE calculations are required or if one of them is sufficient.

References

  • [1] A. Kameke, S. Kastens, S. Rüttinger, S. Herres-Pawlis, and M. Schlüter, “How coherent structures dominate the residence time in a bubble wake: An experimental example,” Chemical Engineering Science, vol. 207, pp. 317–326, Nov. 2019. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0009250919305366
  • [2] F. Huhn, A. von Kameke, V. Pérez-Muñuzuri, M. J. Olascoaga, and F. J. Beron-Vera, “The impact of advective transport by the South Indian Ocean Countercurrent on the Madagascar plankton bloom: Jet in Madagascar Plankton Bloom,” Geophysical Research Letters, vol. 39, no. 6, pp. n/a–n/a, Mar. 2012. [Online]. Available: http://doi.wiley.com/10.1029/2012GL051246
  • [3] F. d’Ovidio, V. Fernández, E. Hernández-García, and C. López, “Mixing structures in the Mediterranean Sea from finite-size Lyapunov exponents: Mixing Structures in the Mediterranean Sea,” Geophysical Research Letters, vol. 31, no. 17, pp. n/a–n/a, Sep. 2004. [Online]. Available: http://doi.wiley.com/10.1029/2004GL020328
  • [4] J. B. Weiss and A. Provenzale, Eds., Transport and Mixing in Geophysical Flows: Creators of Modern Physics. Berlin, Heidelberg: Springer Berlin Heidelberg, 2008. [Online]. Available: http://link.springer.com/10.1007/978-3-540-75215-8
  • [5] Z. Neufeld and E. Hernández-García, Chemical and Biological Processes in Fluid Flows: A Dynamical Systems Approach. Imperial College Press, Sep. 2009. [Online]. Available: https://www.worldscientific.com/worldscibooks/10.1142/p471
  • [6] S. Balasuriya, N. T. Ouellette, and I. I. Rypina, “Generalized Lagrangian coherent structures,” Physica D: Nonlinear Phenomena, vol. 372, pp. 31–51, Jun. 2018. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0167278917302750
  • [7] A. Hadjighasem, M. Farazmand, D. Blazevski, G. Froyland, and G. Haller, “A critical comparison of Lagrangian methods for coherent structure detection,” Chaos: An Interdisciplinary Journal of Nonlinear Science, vol. 27, no. 5, p. 053104, May 2017. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.4982720
  • [8] Justin Finn, Romain Watteaux, and Andrew Lawrie, “libcfd2lcs: A general purpose library for computation of Lagrangian coherent structures during CFD simulation,” Feb. 2017. [Online]. Available: https://www.archer.ac.uk/training/virtual/2016-06-22-libcfd2lcs/ArcherVT.pdf
  • [9] J. Finn and S. V. Apte, “Integrated computation of finite-time Lyapunov exponent fields during direct numerical simulation of unsteady flows,” Chaos: An Interdisciplinary Journal of Nonlinear Science, vol. 23, no. 1, p. 013145, Mar. 2013. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.4795749
  • [10] M. Farazmand and G. Haller, “Computing Lagrangian coherent structures from their variational theory,” Chaos: An Interdisciplinary Journal of Nonlinear Science, vol. 22, no. 1, p. 013128, Mar. 2012. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.3690153
  • [11] S. C. Shadden, F. Lekien, and J. E. Marsden, “Definition and properties of Lagrangian coherent structures from finite-time Lyapunov exponents in two-dimensional aperiodic flows,” Physica D: Nonlinear Phenomena, vol. 212, no. 3-4, pp. 271–304, Dec. 2005. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0167278905004446
  • [12] G. Haller, “Lagrangian Coherent Structures,” Annual Review of Fluid Mechanics, vol. 47, no. 1, pp. 137–162, Jan. 2015. [Online]. Available: https://www.annualreviews.org/doi/10.1146/annurev-fluid-010313-141322
  • [13] S. L. Brunton and C. W. Rowley, “Fast computation of finite-time Lyapunov exponent fields for unsteady flows,” Chaos: An Interdisciplinary Journal of Nonlinear Science, vol. 20, no. 1, p. 017503, Mar. 2010. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.3270044
  • [14] S. Leung, “An Eulerian approach for computing the finite time Lyapunov exponent,” Journal of Computational Physics, vol. 230, no. 9, pp. 3500–3524, May 2011. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0021999111000799
  • [15] G. Haller, “Lagrangian coherent structures from approximate velocity data,” Physics of Fluids, vol. 14, no. 6, pp. 1851–1861, Jun. 2002. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.1477449
  • [16] M. H. Sulman, H. S. Huntley, B. Lipphardt, and A. Kirwan, “Leaving flatland: Diagnostics for Lagrangian coherent structures in three-dimensional flows,” Physica D: Nonlinear Phenomena, vol. 258, pp. 77–92, Sep. 2013. [Online]. Available: https://linkinghub.elsevier.com/retrieve/pii/S0167278913001450
  • [17] T. Solomon and J. Gollub, “Chaotic Transport in Time-Dependent Rayleigh-Bénard Convection,” Physical review. A, vol. 38, pp. 6280–6286, Jan. 1989.
  • [18] D. Lipinski and K. Mohseni, “A ridge tracking algorithm and error estimate for efficient computation of Lagrangian coherent structures,” Chaos: An Interdisciplinary Journal of Nonlinear Science, vol. 20, no. 1, p. 017504, Mar. 2010. [Online]. Available: http://aip.scitation.org/doi/10.1063/1.3270049