5.2.2. CDFEM Examples

The Conformal Decomposition Finite Element Method (CDFEM) is a powerful tool for the solution for moving interface problems. Using an evolving description of the interface location, typically provided via a level set field, CDFEM will automatically adapt the mesh to conform to the interface at each time step. This provides an explicit mesh part representation of a dynamic interface which allows for easy application of boundary conditions and a guaranteed sharp interface resolution.

5.2.2.1. Sloshing

In this example, we will use CDFEM to solve the classic “sloshing” problem, in which a dense liquid surrounded by much lighter gas is initially released from an unstable configuration and allowed to slosh back and forth in a domain under the influence of gravity.

5.2.2.1.1. Problem Files

The files required for this example can be downloaded here, or found at $TESTS/aria_rtest/example/training/cdfem (where TESTS=/projects/sierra/tests in a CEE environment, or your Sierra test distribution otherwise).

5.2.2.1.2. Problem Domain/Mesh

The geometry consists of a single square block with four sidesets, one for each edge of the square. Note at this point there are not separate blocks for the liquid and gas regions. CDFEM will create these blocks when Aria is run.

Initial mesh configuration

The objective is to decompose block_1 into liquid and gas phases using CDFEM. The liquid phase will be initially inclined so that it will move under the influence of gravity. All of the sidesets touching block_1 will also be decomposed into the portions of the sideset touching the liquid and gas phases. Finally, two new sidesets will be created at the interface between the phases to allow boundary conditions to be applied to the interface.

Initial phase configuration

Note the naming scheme used for the newly created mesh parts. The new phase blocks are named [original block name]_[phase name]. Similarly, the phase-specific sidesets are named [original sideset name]_[phase name]. Finally, the interface parts are named surface_[original block name]_[phase]_[touching phase]. Also note that sidesets surface_1_gas and surface_3_liquid are not shown. This is because those sidesets exist, but are empty in this initial configuration because each sideset has only one phase touching the entire sideset. If the phases were to move such that the other phase began touching these sidesets, those parts would be populated accordingly.

5.2.2.1.3. Aria Input File

The following sections show the commands necessary to set up a two-phase level set CDFEM problem. The input file contains the expected Aria input file components with the addition of some new commands in the finite element model block, a level set equation system, and CDFEM options and level set interface blocks.

Defining Materials

Scope: Domain

You must define a material for each phase in the problem. These materials will be assigned to phase blocks the same way they would be to ordinary mesh blocks, even though the phase blocks do not exist in the input mesh. For this problem, two materials are defined with large differences in density and viscosity to represent the liquid and gas phases. A two phase flow problem like this requires:

  • Density

  • Viscosity

  • A momentum stress model

Additionally, a material will be created to supply a surface tension coefficient at the phase interface. The syntax is shown below:

BEGIN ARIA MATERIAL liquid
    Density          = Constant rho=1000
    Viscosity        = constant mu=10.0
    Momentum Stress  = Incompressible_Newtonian
END ARIA MATERIAL liquid
BEGIN ARIA MATERIAL gas
    Density          = Constant rho=1
    Viscosity        = constant mu=0.1
    Momentum Stress  = Incompressible_Newtonian pressure=pressure_1
END ARIA MATERIAL gas
BEGIN ARIA MATERIAL gas_liquid_interface
    Surface Tension = Constant Sigma = 1.
END ARIA MATERIAL gas_liquid_interface

Note the specification of the additional pressure=pressure_1 option for the gas momentum stress. This is because two pressure fields will be used to handle the pressure discontinuity due to surface tension and this option specifies that the gas phase pressure (pressure_1) should be used in the gas phase to calculate the momentum stress instead of the default (pressure), which is the liquid phase pressure.

Linear Solver

Scope: Domain

This problem will use two linear solvers, one for the level set system and one for the coupled momentum/continuity system. The level set system will use the “Scalar_Transport” solver preset (GMRES with SGS preconditioner), following the recommendation for scalar advection diffusion equations in Solver Selection Guidelines, with a very tight linear tolerance. The level set system is always linear, but needs to be solved to a very tight tolerance. The most computationally efficient way to accomplish this is to use a linear solver with a tight tolerance and a single nonlinear iteration. The momentum/continuity system will use the “Multiphysics” preset (GMRES with DD-ILU preconditioner), following the recommendation for coupled equations in Solver Selection Guidelines.

BEGIN TPetra Equation Solver levelset
    BEGIN PRESET SOLVER
        Convergence Tolerance = 1e-12
        Solver Type = scalar_transport
    END
END

BEGIN TPetra Equation Solver momentum
    BEGIN PRESET SOLVER
        Convergence Tolerance = Automatic
        Solver Type = multiphysics
    END
END TPETRA EQUATION SOLVER

Define the Finite Element Model

Scope: Domain

The finite element model section is where you indicate which mesh file to use and associate materials with the blocks and surfaces. In this problem, this is also where the phases are specified. The level set interface “LS” is used to divide the liquid and gas phases. The level set is a signed distance field indicating the shortest distance from any point in the domain to the interface. Thus, the interface location is wherever the level set field is zero and the different phases are indicated by the sign of the field.

BEGIN FINITE ELEMENT MODEL TwoPhaseFlow
    database name = cdfem_slosh_adapt.g
    coordinate system is cartesian
    Decomposition Method = RCB

    Begin Parameters For Phase gas
        where LS is positive
    End
    Begin Parameters For Phase liquid
        where LS is negative
    End
    Begin Parameters For Block block_1_gas
        Material gas
    End
    Begin Parameters For Block block_1_liquid
        Material liquid
    End
    Begin Parameters For Block block_1
        Material gas
    End
    Begin Parameters For Surface surface_block_1_liquid_gas
        Material gas_liquid_interface
    End
END FINITE ELEMENT MODEL TwoPhaseFlow

Solution Control

Scope: Procedure

The solution control block defines how the problem is stepped forward in time. Here, the simulation begin and end times are specified as well as the time stepping scheme. There are two features in this block specific to CDFEM. The first is the LS_CONSERVED_REDISTANCE event. The level set field must be periodically redistanced to enforce mass conservation. The recommendation is that this operation is performed whenever the interface moves across a mesh cell. Thus, the redistance operation is conditioned to occur at regular time intervals based on the estimated maximum velocity and mesh size. The second feature is the Interface Courant Limit used to control the time step size. Because of the semi-explicit nature of the interface evolution, for best results Courant numbers on the interface should be limited to around 1. Here 0.5 is chosen for finer time resolution. The predictor-corrector tolerance is also set very high, effectively disabling predictor-corrector time step control and relying instead on the interface Courant limit.

Begin Solution Control Description
    Use System Main
    Begin System Main
        Simulation Start Time            = 0.0
        Simulation Termination Time      = 2.0
        Begin Transient Stepper
            Advance MyRegion
            Event LS_CONSERVED_REDISTANCE when "(CURRENT_TIME - LAST_LS_CONSERVED_REDISTANCE_TIME) >= 0.01"
        End
    End
    Begin Parameters For Transient Stepper
        Start Time      = 0.0
        Begin Parameters For Aria Region MyRegion
            Initial Time Step Size = 0.005
            Maximum Time Step Size = 0.1
            Minimum Time Step Size = 0.005
            Time Step Variation = Adaptive
            Interface Courant Limit = 0.5
            Predictor-Corrector Tolerance = 1.0
        End
    End
End

Aria Region

Scope: Procedure

Two blocks are required in the Aria Region in order to set up a CDFEM problem: the Level Set Interface block and the CDFEM Options block. The Level Set Interface block sets up the level set interface for use in the finite element model block to determine the phase decomposition. A required component is specifying the mesh field to use as the level set distance variable. In this problem, the solution field from the level set equation system is used. Optionally, initial conditions for the level set field can be specified here. In this case, the interface is initialized with a plane centered at the origin and whose normal is provided. Since we are using a level set field that is also a solution variable, initial conditions for it can also be specified in the level set equation system block using the methods documented in Initial Conditions.

The CDFEM options block allows settings specific to CDFEM to be specified. If only default CDFEM settings are to be used, this block can be omitted. For this problem, one level of non-conformal adaptivity is used. This means that, prior to modifying the mesh to align it with the interface, cells that are intersected by the interface are refined one time.

Additional options set in the Aria Region scope are the creation of some mesh groups to clarify mesh part names and disabling the use of the two pressure fields in the predictor-corrector time step control scheme. Since the continuity equation does not have an unsteady term, it is possible for pressure to change rapidly with time, potentially driving time step sizes unnecessarily low.

BEGIN ARIA REGION MyRegion

    BEGIN LEVEL SET INTERFACE LS
        Distance Variable = solution->LEVEL_SET
        Begin analytic initial condition myIC
            plane normal = 0.7 1. 0 offset = 0
        End
    END

    Predictor Fields = Not Pressure
    Predictor Fields = Not Pressure_1

    Begin CDFEM OPTIONS
        cdfem nonconformal adaptivity levels = 1
    End

    USE FINITE ELEMENT MODEL TwoPhaseFlow
    MESH GROUP gas_blocks = block_1_gas
    MESH GROUP liquid_blocks = block_1_liquid
    MESH GROUP liquid_gas_interface = surface_block_1_liquid_gas
    MESH GROUP nonconformal_blocks = block_1

    # other region commands
END

Level Set Equation System

Scope: Aria Region

The level set equation system will govern the advection of the level set field by the fluids and thus define the evolution of the phase interface. In this block, the use of the level set-specific linear solver is specified as well as a very large correction tolerance. Since the level set equation is always linear in the level set variable, this causes the solution to be accepted after only one nonlinear iteration. The Level_Set equation is specified on both the conformal and non-conformal blocks, although the non-conformal blocks only contain the mass term. This is the only equation that should be specified on the non-conformal block.

begin equation system LS
    Use Linear Solver levelset

    Nonlinear Solution Strategy    = Newton
    Maximum Nonlinear Iterations   = 3
    Nonlinear Residual Tolerance   = 1e-6
    Nonlinear Correction Tolerance = 1e+12 # LINEAR

    EQ Level_Set for Level_Set on nonconformal_blocks Using Q1 with Mass
    EQ Level_Set for Level_Set on gas_blocks          Using Q1 with Mass Adv SUPG
    EQ Level_Set for Level_Set on liquid_blocks       Using Q1 with Mass Adv SUPG
end equation system

Momentum Equation System

Scope: Aria Region

The momentum equation system will govern the evolution of the fluid velocities. The use of the momentum equation specific solver is specified and momentum and continuity equations set up on the conformal blocks. The surface tension of the interface will create a pressure discontinuity, so different pressure variables are used in each of the phases. Surface tension is activated using the capillary flux boundary condition on the liquid interface. Numerical stabilization of the capillary force is also generally required. No-slip conditions are applied to the bottom and side walls of the domain. The top of the domain is implicitly kept as a zero-flux boundary. Finally, gravitational loads are applied to both phases, which will drive motion of the liquid.

begin equation system momentum
    Nonlinear Solution Strategy    =  Newton
    Maximum Nonlinear Iterations   =  10
    Nonlinear Residual Tolerance   =  1e-6
    Nonlinear Correction Tolerance =  0

    USE LINEAR SOLVER momentum

    EQ Momentum for Velocity ON gas_blocks   USING Q1 WITH MASS ADV DIFF SRC SUPG
    EQ Momentum for Velocity ON liquid_blocks USING Q1 WITH MASS ADV DIFF SRC SUPG
    EQ Continuity_1 for Pressure_1 ON gas_blocks   USING Q1 WITH DIV
    EQ Continuity   for Pressure   ON liquid_blocks USING Q1 WITH DIV
    PRESSURE STABILIZATION is pspg_shakib with scaling = 1.0

    BC FluxBP for Momentum on liquid_gas_interface = Capillary
    BC FluxBP for Momentum on liquid_gas_interface = Capillary_stabilization

    BC dirichlet for velocity_y on surface_1_gas = constant value = 0.0
    BC dirichlet for velocity_y on surface_1_liquid = constant value = 0.0
    BC dirichlet for velocity_x on surface_2_gas = constant value = 0.0
    BC dirichlet for velocity_x on surface_2_liquid = constant value = 0.0
    BC dirichlet for velocity_x on surface_4_gas = constant value = 0.0
    BC dirichlet for velocity_x on surface_4_liquid = constant value = 0.0

    Source For Momentum On gas_blocks   = Hydrostatic gx=0 gy=-10
    Source For Momentum On liquid_blocks = Hydrostatic gx=0 gy=-10
end equation system

Solution Output

Scope: Aria Region

A Results Output block is defined to control the output of simulation results. In this case, all solution fields are written to an exodus database at each time step.

BEGIN RESULTS OUTPUT LABEL SolutionOutput
    DATABASE NAME = cdfem_slosh_adapt.e
    AT STEP 0, INCREMENT = 1
    TITLE Aria Two Phase Sloshing
    NODAL VARIABLES = solution->Level_Set AS F
    NODAL VARIABLES = solution->Pressure   AS Pliquid
    NODAL VARIABLES = solution->Pressure_1 AS Pgas
    NODAL VARIABLES = solution->Velocity AS V
END RESULTS OUTPUT LABEL SolutionOutput

5.2.2.1.4. Viewing the Results

Results can be visualized in Paraview or EnSight. You will notice that for this case multiple files are created per processor rank instead of the typical one per processor rank. This is because CDFEM is generally modifying the mesh every time step, and a new exodus file will be generated each time the mesh is modified. These files will have a -s#### suffix appended to the file name specified in the output block (ie cdfem_slosh_adapt.e-s0002 in this example). Each file may contain just one or multiple time steps, depending on whether the interface moved significantly enough to trigger a CDFEM mesh modification between output times. Both Paraview and EnSight will seamlessly read these file stacks, so no special steps need to be taken by the user to view output from CDFEM runs.