> ## Documentation Index
> Fetch the complete documentation index at: https://bindi-nagda-amr-multiphase.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Run the four-roll-mill example end-to-end: compile, configure, execute, and visualize your first multiphase simulation.

The four-roll-mill (`frm`) example is the primary validation case for AMR Multiphase. It simulates a two-phase Newtonian fluid driven by a body force that produces four counter-rotating vortices on the periodic domain $[-0.5, 0.5]^2$. The network-phase volume fraction is initialized as a smooth radial blob at the center of the domain.

> [!NOTE]
>
> Complete the [build and install](https://bindi-nagda-amr-multiphase.mintlify.site/building.md) steps before continuing. You need a compiled `frm` executable in your `build/frm/` directory.

## Running the four-roll-mill simulation

**1. Navigate to the frm directory**

The input file and executable are both located in the `frm/` subdirectory of your build tree.

```bash theme={null}
cd build/frm
```

**2. Run the executable**

Launch `frm` with `input2d` as the input file and pass solver options on the command line:

```bash theme={null}
./frm input2d \
    -solver_ksp_initial_guess_nonzero FALSE \
    -solver_ksp_monitor_true_residual \
    -solver_ksp_type fgmres \
    -solver_ksp_max_it 20 \
    -solver_ksp_rtol 1e-14
```

These flags configure the PETSc Krylov solver used for the coupled saddle-point system at each time step:

| Flag | Value | Effect |
| - | - | - |
| `-solver_ksp_initial_guess_nonzero` | `FALSE` | Start each linear solve from zero initial guess |
| `-solver_ksp_monitor_true_residual` | — | Print the true (unpreconditioned) residual at each iteration |
| `-solver_ksp_type` | `fgmres` | Use flexible GMRES, required when the preconditioner is non-stationary |
| `-solver_ksp_max_it` | `20` | Maximum Krylov iterations per linear solve |
| `-solver_ksp_rtol` | `1e-14` | Relative convergence tolerance for the linear solver |

**3. Monitor progress via log files**

While the simulation runs, progress is written to the log file named `output` in the working directory. You can tail it in a separate terminal:

```bash theme={null}
tail -f output
```

Each time step prints the current simulation time, time step size, and linear solver convergence information. Logging is controlled by `ENABLE_LOGGING = TRUE` in `input2d`.

**4. Visualize results with VisIt**

Visualization dumps are written to the `viz2d_four_roll_mill/` directory at the interval set by `VIZ_DUMP_TIME_INTERVAL`. Open VisIt and load the `dumps.visit` file from that directory:

1. Launch VisIt.
2. Select **File → Open** and navigate to `build/frm/viz2d_four_roll_mill/dumps.visit`.
3. Add a **Pseudocolor** plot on the variable `Thn_n` to see the network-phase volume fraction.
4. Use the time slider to step through the simulation.

Hierarchy data for restart and post-processing is written to `hier_data_four_roll_mill/`.

## Key input file parameters

The simulation is fully controlled by `frm/input2d`. The parameters below are the most important ones to understand and tune.

### Grid and time stepping

| Parameter | Default | Description |
| - | - | - |
| `N` | `64` | Number of grid cells along each axis on the coarsest level. The domain is $[-0.5, 0.5]^2$, so `DX = 1.0 / N`. |
| `CFL_MAX` | `0.1` | Maximum CFL number. The time step is set to `DT_MAX = CFL_MAX * DX / U_MAX`. |
| `U_MAX` | `20.0` | Estimate of the maximum velocity in the domain, used to set the time step. |
| `END_TIME` | `1.0` | Simulation end time in non-dimensional units. |
| `REGRID_INTERVAL` | `10` | Number of time steps between AMR regridding operations. |
| `MAX_MULTIGRID_LEVELS` | `6` | Maximum number of levels allowed in the multigrid preconditioner hierarchy. |

### Fluid parameters

| Parameter | Default | Description |
| - | - | - |
| `ETA_S` | `0.04` | Solvent-phase dynamic viscosity $\eta_s$. |
| `ETA_N` | `4.0` | Network-phase dynamic viscosity $\eta_n$. |
| `NU_N` | `1.0` | Network-phase volume-fraction mobility coefficient $\nu_n$. |
| `NU_S` | `1.0` | Solvent-phase volume-fraction mobility coefficient $\nu_s$. |
| `XI` | `250.0*ETA_S` | Drag coupling coefficient between the two phases. Higher values increase inter-phase coupling. |
| `RHO` | `1.0` | Fluid density (same for both phases). |
| `W` | `0.75` | Solver relaxation parameter used by the box-relaxation smoother. |

### Initial condition for the volume fraction

```
DELTA = 0.175
thn {
   function = "0.25 + 0.25*((sqrt(X_0*X_0+X_1*X_1)<delta) ? \
     (1989.0/(896*PI)*(1.0-((X_0*X_0+X_1*X_1)/(delta*delta))^4.0)^4.0* \
     (4.0*((X_0*X_0+X_1*X_1)/(delta*delta))^4.0+1.0)) : 0.0)"
}
```

`DELTA = 0.175` sets the radius of the initial volume-fraction blob. The function evaluates to a smooth radially symmetric bump of amplitude 0.25 centered at the origin, on top of a background value of 0.25.

### Convective discretization

| Parameter | Default | Description |
| - | - | - |
| `ADV_DIFF_CONVECTIVE_OP_TYPE` | `"CUI"` | Convective operator limiter. Options include `UPWIND`, `CUI`, `FBICS`, and `MGAMMA`. |
| `ADV_DIFF_CONVECTIVE_TS_TYPE` | `"ADAMS_BASHFORTH"` | Time-stepping scheme for the advection-diffusion integrator. |
| `ADV_DIFF_CONVECTIVE_FORM` | `"CONSERVATIVE"` | Form of the convective term: `CONSERVATIVE` or `ADVECTIVE`. |
| `VISCOUS_TS_TYPE` | `"TRAPEZOIDAL_RULE"` | Time-stepping scheme for the viscous terms. |

### Viscoelastic model

```
USE_CF = FALSE
```

The `USE_CF` flag enables the Oldroyd-B conformation tensor model for viscoelastic simulations. It is disabled in the default four-roll-mill configuration, which uses a purely Newtonian model. Set `USE_CF = TRUE` to activate it and configure the `CFMultiphaseOldroydB` parameters.

### Visualization and output

| Parameter | Default | Description |
| - | - | - |
| `VIZ_DUMP_TIME_INTERVAL` | `0.005` | Simulation time between visualization dumps. |
| `viz_dump_dirname` | `"viz2d_four_roll_mill"` | Directory for VisIt visualization output. |
| `data_dump_dirname` | `"hier_data_four_roll_mill"` | Directory for hierarchy restart data. |
| `log_file_name` | `"output"` | Name of the text log file written during the run. |

## Next steps

> [card] [Convergence testing](https://bindi-nagda-amr-multiphase.mintlify.site/examples/convergence-testing.md)
>
> Run `frm_convergence` to verify second-order accuracy across grid refinements

> [card] [Physical boundary conditions](https://bindi-nagda-amr-multiphase.mintlify.site/examples/physical-bc.md)
>
> Explore the channel flow example with non-periodic boundary conditions

> [card] [Input parameters reference](https://bindi-nagda-amr-multiphase.mintlify.site/configuration/input-parameters.md)
>
> Full reference for every parameter in the input file

> [card] [Multiphase model](https://bindi-nagda-amr-multiphase.mintlify.site/concepts/multiphase-model.md)
>
> Understand the two-fluid mixture equations and physical parameters


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.