7.7. Pinch-off: letting the mesh change its topology

The Rayleigh-Plateau filament of Section 7.6 was stopped just before the interesting moment: the run ends when the minimum radius falls below a threshold, because at that point the neck has become thinner than the mesh can carry. A sharp-interface method has to be told what to do at a break-up, unlike a phase field or a volume of fluid method, which handle these changes intrinsically. In this section we do tell it, and the same filament runs straight through its own break-up into three separate drops.

class RayleighPlateauPinchOffProblem(Problem):
    # Nondimensionalised by the unperturbed radius R0, the density and the surface tension, so
    # lengths are in R0, time is in the inertio-capillary time and the viscosity is the Ohnesorge
    # number - exactly as in the previous section.
    def __init__(self):
        super().__init__()
        self.Oh = 0.1                        # Ohnesorge number
        self.k = 0.697                       # the inviscid fastest-growing wavenumber, k*R0 < 1
        self.L = 2 * numpy.pi / self.k       # one FULL wavelength, so the neck is in the interior
        self.a = 0.5                         # amplitude of the perturbation
        self.min_elements_per_radius = 2.5   # elements across the local radius
        self.hmin = 0.03                     # finest allowed element
        self.hmax = 0.35                     # coarsest allowed element
        # The neck radius at which we declare the column broken
        self.rmin = 2 * self.hmin
        self.n_fragments = 1                 # set by the mesh at every build, see below
        self.post_pinch_steps = 6            # how far to continue past the event

The one genuinely new parameter is rmin: the interface radius at which we declare the column broken. It must be tied to what the mesh can resolve – here it is two elements wide, 2*hmin, and it must be well below the radius of the drops it separates. As a rule of thumb: rmin at or below a tenth of the drop radius works, considerably coarser values fail.

The imports and the mesh class differ from the previous section in exactly one line, the base class:

from pyoomph import *
from pyoomph.equations.navier_stokes import *
from pyoomph.equations.ALE import *
from pyoomph.meshes.zeta import *
# The topological changes live in their own module: an interface equation that detects the event
# and a Gmsh template that knows how to rebuild the mesh once it has happened.
from pyoomph.equations.topological_changes import *
# The plan of a pinch-off is worked out by shapely, an optional dependency of pyoomph
# (pip install pyoomph[topology]). It is not required in this file, but the run will stop with an error if it is not installed, 
# so we import it here to make that clear.
import shapely  # noqa: F401

import numpy


class PinchingJetMesh(TopologicalChangesGmshTemplate):
    def define_geometry(self):
        self.mesh_mode = "tris"
        pr = cast("RayleighPlateauPinchOffProblem", self.get_problem())
        
        self.gmsh_options["Mesh.MeshSizeMin"] = pr.hmin
        self.gmsh_options["Mesh.MeshSizeMax"] = pr.hmax
        self.gmsh_options["Mesh.MeshSizeFromCurvature"] = 10
        # Gmsh parallelises its 2d meshing and the resulting mesh differs in the last bits from run to run
        # Deactivating threading it makes it deterministic        
        self.gmsh_options["General.NumThreads"] = 1

A TopologicalChangesGmshTemplate is an ordinary GmshTemplate – it remeshes by recreation, i.e. by calling define_geometry() again – with one addition: it can be handed a surgery plan and then report the reconnected geometry instead of the current one. The plan is computed with shapely, which is an optional dependency of pyoomph (pip install pyoomph[topology]); the script imports it at the top so that a machine without it says so immediately rather than in the middle of the transient. The feature is currently restricted to axisymmetric two-dimensional problems.

The gmsh options are those of the previous section, plus General.NumThreads = 1. That is not a performance setting: gmsh parallelises its 2d meshing and the resulting node positions differ in the last bits from run to run, and on a transient that ends in a capillary singularity those bits separate within a few dozen steps. One thread makes successive runs reproducible.

The initial geometry is the perturbed cosine profile, built directly as a spline so that the mesh size fields already see the neck:

        if self.is_first_time():
            # The initial mesh: one full wavelength of the perturbed column, r=1+a*cos(k*z).
            zs = numpy.linspace(0.0, pr.L, 61)
            pts = [self.point(1 + pr.a * numpy.cos(pr.k * z), z) for z in zs]
            interfaces = [self.spline(pts, name="interface")]
            axes = [self.create_lines(pts[0], "bottom", self.point(0, 0),
                                      "axisymm", self.point(0, pr.L), "top", pts[-1])[1]]

The remeshing branch is where the topological change is delivered, and the important point about it is that there is only one code path:

        else:
            # This branch is entered for an ordinary quality remesh and for pinch-off events
            # Since the topology might change, we have to take a detour here:
            rb = self.get_reconnected_boundaries("liquid/interface", "liquid/axisymm")
            # One interface chain per connected fluid fragment, sorted by ascending y, and one axis
            # segment per fragment. Before the pinch there is one of each, afterwards three.
            interfaces = [self.spline_from_chain(chain, "interface") for chain in rb.interface_chains]
            # How many fragments there are is a statement about the WHOLE interface, and this is the
            # one place every rank has it: the plan is made on rank 0 and broadcast, so every rank
            # builds the same chains. Counting the local interface mesh instead (which is what
            # get_cached_mesh_data gives) answers a different question on every rank.
            pr.n_fragments = len(rb.interface_chains)
            axes = self.lines_from_axis_segments(rb.axis_segments, "axisymm")
            # The symmetry planes at z=0 and z=L. Every chain end is either "fixed" (it ends on a
            # boundary that was there before, i.e. on one of the two symmetry planes) or "axis" (it
            # ends on the axis of symmetry, where the interface closes itself off with a cap).            
            for chain in rb.interface_chains:
                for index, kind in ((0, chain.end_types[0]), (-1, chain.end_types[1])):
                    if kind == "fixed":
                        x, y = float(chain.points[index][0]), float(chain.points[index][1])
                        self.line(self.point(0.0, y), self.point(x, y),
                                  name="bottom" if y < 0.5 * pr.L else "top")

get_reconnected_boundaries() replaces the call to get_boundary_coordinates() of the previous section, and it is not told whether a pinch-off is pending. If one is, the returned ReconnectedBoundaries describes the geometry after the surgery; if none is, it wraps the current geometry into exactly the same structure. So the branch that carries the event is the branch that runs on every single quality remesh, and is therefore exercised constantly instead of once per simulation.

What that branch has to cope with is a variable number of fragments, which is why it is written as loops:

  • interface_chains holds one ReconnectedChain per connected fluid fragment, sorted by ascending \(z\). spline_from_chain() turns one of them into a named spline, using the local element sizes the chain suggests. (Its points and suggested_sizes are public, so dropping down to point() and spline() for full control over the resolution is always possible.)

  • axis_segments holds the pieces of the symmetry axis that belong to this phase – one per fragment, with gaps where the fragments have separated. lines_from_axis_segments() makes them into named lines.

  • end_types tells the two ends of a chain apart: "fixed" means it ends on a boundary that was already there, i.e. on one of our two symmetry planes, and "axis" means it closes itself off with a cap on the axis. Initially the single chain has two fixed ends. After the pinch, the lower and the upper fragment have one fixed end each and one fresh cap, and the satellite in between has none at all – which is why the symmetry planes at \(z=0\) and \(z=L\) are created in a loop over the chain ends rather than written out twice.

Everything after that – the plane_surface and the gmsh mesh size fields – is the previous section verbatim, except that the fields now act on a list of interface curves and a list of axis curves. Gmsh assembles the named curves into as many closed loops as they form, so nothing has to be said about how many fragments there are.

On the equation side, a single line switches the topological changes on:

    def define_problem(self):
        self.set_coordinate_system("axisymmetric")
        self.add_mesh(PinchingJetMesh())

        eqs = NavierStokesEquations(mass_density=1, dynamic_viscosity=self.Oh)
        eqs += HyperelasticSmoothedMesh()
        eqs += MeshFileOutput()
        eqs += RemeshWhen(RemeshingOptions())
        
        eqs += AxisymmetryBC() @ "axisymm"
        eqs += DirichletBC(mesh_y=True, velocity_y=0) @ ["top", "bottom"]
        eqs += NavierStokesFreeSurface(surface_tension=1) @ "interface"

        # This single line is what allows the interface to change its topology: a neck whose minimal
        # radius drops below rmin pinches off.
        eqs += AxisymmetricReconnection(rmin=self.rmin) @ "interface"

        # The volume is our accuracy check: the surgery is volume-conserving by construction, so
        # whatever the volume does at the event must be no worse than at an ordinary remesh.
        eqs += IntegralObservables(volume=1)
        eqs += ExtremumObservables(min_r=var("mesh_x")) @ "interface"

        # Accurate interpolation of the interface fields upon remeshing, as in the previous section.        
        eqs += AssignZetaCoordinatesByArclength(sort_along_axis="y+") @ "interface"
        eqs += AssignZetaCoordinatesByEulerianCoordinate("y") @ "axisymm"
        eqs += AssignZetaCoordinatesByEulerianCoordinate("x") @ "top"
        eqs += AssignZetaCoordinatesByEulerianCoordinate("x") @ "bottom"

        self.add_equations(eqs @ "liquid")

The AxisymmetricReconnection monitors the interface and, when the minimal interface radius drops below rmin, hands the mesh template a plan and asks for a remesh. It does not modify anything itself: the event is applied by the ordinary remeshing-by-recreation path, i.e. by the else: branch above. Note also that the RemeshWhen is still there and is still doing its usual job – remeshing after a pinch is not optional, since the two fresh caps retract fast enough to degenerate the mesh within a handful of steps.

The \(\zeta\) coordinates of the previous section are unchanged and keep working across the event: the reconnection writes the plan’s own chart onto the old and the new interface, so the points of a fragment that the surgery did not touch keep exactly the parametrization they had before, and the fields are carried across the break-up rather than re-interpolated from scratch.

The IntegralObservables are our accuracy check, discussed below.

The run loop is the generator of the previous section with two additions:

    def run_until_broken(self, dt_factor=0.15, maxstep=0.25, post_dt=0.01, max_steps=200):
        # As in the previous section, we tie the time step to the minimum radius: the inertial
        # collapse follows r ~ (t0-t)^(2/3), so a step that is a fixed fraction of r can never jump
        # over the event. After the break-up, however, the minimum radius is the tip of one of the
        # fresh caps, i.e. exactly zero, and is no longer the scale that has to be resolved - so we
        # switch to a fixed, modest step there.
        t, pinched_at = self.get_current_time(dimensional=False, as_float=True), None
        fragments = self.get_number_of_fragments()
        for step in range(max_steps):
            t += post_dt if pinched_at is not None else min(maxstep, dt_factor * self.get_minimum_radius())
            self.run(t, outstep=False, maxstep=maxstep, temporal_error=1, do_not_set_IC=True)
            yield self.get_current_time(dimensional=False, as_float=True)

            # Every event, not only the first one: this column produces a satellite, and a satellite
            # can pinch again. The restart below is owed to each of them.
            if self.get_number_of_fragments() != fragments:
                fragments = self.get_number_of_fragments()
                if pinched_at is None:
                    pinched_at = step
                # Let the first step after pinch-off become a  BDF1 instead of BDF2, because the history of the new fragment is only accurate to first order.
                self.timestepper.set_num_unsteady_steps_done(0)
            if pinched_at is not None and step - pinched_at >= self.post_pinch_steps:
                return

The first is the step control after the break-up. Before it, the step is a fixed fraction of the minimum radius, exactly as before: the inertial collapse follows \(r\sim(t_0-t)^{2/3}\), so a step proportional to \(r\) can never jump over the event. Afterwards the minimum radius is the tip of one of the fresh caps, i.e. exactly zero, and no longer the scale that has to be resolved, so we switch to a fixed modest step.

The second is the one obligation this feature places on the user: A node that the surgery has created has no time history of its own; the interpolation from the old mesh gives it whatever the old mesh held at that position, which for a fresh cap is the middle of a neck that was collapsing at the largest velocity anywhere in the domain. That is what the second-order scheme extrapolates through on the first step past the event, and at a step size that was perfectly comfortable before it the Newton solve simply diverges.

We therefore call problem.timestepper.set_num_unsteady_steps_done(0), to that the time stepper assumes we are at the first step of a new transient, and the BDF2 becomes a BDF1 for that step.

if __name__ == "__main__":
    with RayleighPlateauPinchOffProblem() as problem:
        problem.DTSF_max_increase_factor = 1.25
        problem.DTSF_min_decrease_factor = 0.75
        problem.initialise()
        
        # Make it reproducible. A threaded direct solver is not bit-reproducible, and a pinch-off
        # turns a last-bit difference into a different remesh sequence. After initialise(), so that
        # it also wins over a --omp N on the command line. (Gmsh is pinned separately, with
        # General.NumThreads in define_geometry above.)
        problem.set_num_threads(1)

        history = problem.create_text_file_output("pinchoff.txt",
                                                  header=["t", "r_min", "fragments", "volume"])
        problem.output()
        history.add_row(0.0, problem.get_minimum_radius(), 1, problem.get_volume())

        for t in problem.run_until_broken():
            problem.output()
            history.add_row(t, problem.get_minimum_radius(), problem.get_number_of_fragments(),
                            problem.get_volume())

The break-up happens at \(t\approx2.57\), and the result is shown in figure Fig. 7.7.

Rayleigh-Plateau pinch-off with a satellite drop

Fig. 7.7 (left) The interface over one wavelength, mirrored about the axis, before and after the break-up. The column does not pinch at one point but at both ends of the thin filament between the two growing drops, so a single event carries two simultaneous pinches and leaves three fragments: two drops and a satellite. (right) The relative change of the liquid volume in each accepted time step, on a logarithmic scale. The pinch-off step is no larger an error than the ordinary steps and quality remeshes around it.

The volume is the quantitative payoff. The surgery is volume-conserving by construction: the plan splits the parent volume at the waist plane and moves only the freshly created points, along their normals, until each child fragment carries its share exactly. What is left is the \(\mathcal{O}(h^2)\) deviation between the plan’s polyline and the Catmull-Rom spline that define_geometry draws through it – which is precisely the error an ordinary quality remesh makes as well. Measured on this run (relative change of the liquid volume in one accepted time step):

worst ordinary step or quality remesh

\(9.3\times10^{-6}\)

the pinch-off step

\(-2.8\times10^{-6}\)

the whole run (71 steps)

\(-1.3\times10^{-4}\)

i.e. the break-up costs about what remeshing the same mesh costs anyway, and both are far below the drift the free-surface kinematic condition accumulates over the run. fragment_volumes exposes the target volume of each fragment for exactly that purpose.

Note

The reverse event, coalescence, is available from the same equation: pass distmin instead of (or in addition to) rmin and two fragments whose axial tip-to-tip gap falls below it will merge, with the same one-branch define_geometry handling the merged geometry. For a two-phase setting, get_reconnected_boundaries() additionally takes an opposite_axis_name, and fills opposite_axis_segments with the complementary axis pieces the surrounding phase has to cover.

Full code available in the

pyoomph example bundle

Moving_Mesh/rayleigh_plateau_pinchoff.py