# A Backwards-Tracking Lagrangian-Eulerian Method for Viscoelastic Two-Fluid Flows
## 3 Numerical Method  
The momentum Equation (1) and the continuity Equation (2) are discretized on a collocated Eulerian grid with the finite volume method. The pressure-velocity coupling is accomplished by solving the momentum and continuity equations with SIMPLEC iterations [32]. An octree grid is used, in which the cells can be refined in desired locations by recursively dividing them into smaller cells to a given refinement level. The refinements may be static or adaptively updated, typically around moving objects or fluid interfaces. Figure 1 displays an example grid in two dimensions with one refinement level, showing the cell centers and the grid nodes. The grid, including the adaptive refinements, is automatically generated by the solver. Figure 1: Two-dimensional grid with one refinement level, showing cell centers (\(\times\)) and grid nodes (\(\bullet\)). Boundary conditions from objects in the domain are imposed while using the mirroring immersed boundary method [30; 31]. The velocity field is implicitly mirrored across the immersed boundary surface, such that the imposed boundary condition is satisfied for the converged solution. Surface triangulations represent the geometrical objects. The viscoelastic constitutive equation is solved in the Lagrangian frame of reference in material elements that are represented as Lagrangian nodes. From (3) and (4), it follows that the stress in a Lagrangian node is described by the ordinary differential equation (ODE)  
\[\frac{D\boldsymbol{\tau}}{Dt}=\frac{2\eta}{\lambda}\mathbf{S}-\frac{1}{\lambda }F(\boldsymbol{\tau})\boldsymbol{\tau}+(\
abla\mathbf{u})^{T}\cdot\boldsymbol {\tau}+\boldsymbol{\tau}\cdot\
abla\mathbf{u}. \tag{7}\]  
Furthermore, the trajectory of the node must be known when solving (7), as it involves the local velocity gradient \(\
abla\mathbf{u}\). The trajectory of the node is given by the ODE  
\[\frac{D\mathbf{x}}{Dt}=\mathbf{u}, \tag{8}\]  
where \(\mathbf{x}\) is the position of the node. Given an initial stress state in a set of Lagrangian nodes, a straightforward approach to obtain the stress state at a future time is to simultaneously solve (7) and (8) forwards in time. Indeed, this method has been successfully employed in previous work [27; 28]. Lagrangian nodes were then initialized with a given distribution density at the start of the simulation. The distribution was maintained in each time step by adding or deleting nodes, if necessary. After solving the constitutive equation at the Lagrangian nodes, the viscoelastic stress was interpolated to the Eulerian cell centers while using radial basis functions (RBF). In this work, the method is further developed by introducing the concept of backwards-tracking. The key idea is to choose the locations of the Lagrangian nodes a priori, at which the viscoelastic stresses are then stored, and then track them backwards in time in order to obtain their initial location in each time step. The constitutive equation may then be solved forwards in time such that the stresses are obtained at for the next time step at the chosen locations. Different choices for the locations are conceivable. In the current work, the locations of the Lagrangian nodes are chosen to be at the Eulerian grid nodes. Consider the calculation of the viscoelastic stress for the \(n\)th simulation step, which corresponds to the time interval \(I_{n}=[t_{n},t_{n+1}]\). At this point, it is assumed that momentum equation has been solved, such that the velocity field is known for \(t\in I_{n}\). The Lagrangian constitutive equation is solved along the trajectories of Lagrangian nodes. For a Lagrangian node, the trajectory \(\mathbf{x}(t)\) can be expressed in terms of the position at the end of the time step, as  
\[\mathbf{x}(t)=\mathbf{x}(t_{n+1})-\int_{t}^{t_{n+1}}\mathbf{u}(t^{\prime}, \mathbf{x}(t^{\prime}))dt^{\prime},\quad t\in I_{n}, \tag{9}\]  
where \(\mathbf{x}(t_{n+1})\) is the predefined final location of the Lagrangian node which.