Skip to main content
The physical_bc/ directory contains three focused examples that demonstrate different aspects of non-periodic (physical) boundary conditions in the multiphase solver. Each example is a standalone executable and is useful for verifying boundary condition implementations independently of the full time-stepping loop.

Overview

Building

From your build directory:

apply — operator application test

Source: physical_bc/apply/apply.cpp
Input: physical_bc/apply/input2d.const_theta.var_vel
This example initializes a prescribed velocity field, applies the MultiphaseStaggeredStokesOperator directly (without solving), and compares the output to the analytically derived right-hand side. It is used to verify that the discrete operator correctly handles Dirichlet boundary data.

Run

What it demonstrates

  • Registering muParserRobinBcCoefs for each velocity component and for thn
  • Calling stokes_op.setPhysicalBcCoefs(un_bc_coefs, us_bc_coefs, nullptr, thn_bc_coef)
  • Calling stokes_op.apply(u_vec, f_vec) and comparing to analytical forcing

Input parameters

The test uses a constant volume fraction thn = 0.75 with sinusoidal velocities on the unit square domain [0,1]² with no-slip Dirichlet conditions:

Boundary condition format

Each velocity component uses muParserRobinBcCoefs blocks. The Robin coefficients acoef = 1, bcoef = 0 specify pure Dirichlet conditions. gcoef holds the boundary value:
The suffix _0 and _1 on the block name correspond to the x- and y-components of velocity. The four gcoef_function_N entries correspond to the four sides of the 2D domain (left, right, bottom, top).

solve — steady Stokes solver test

Source: physical_bc/solve/solve.cpp
Inputs: physical_bc/solve/input2d.homogeneous, physical_bc/solve/input2d.inhomogeneous
This example solves a single steady Stokes problem with a known exact solution and computes L1, L2, and L∞ error norms. It exercises the full solve path including the FullFACPreconditioner multigrid preconditioner on a non-periodic domain.

Run

The homogeneous test uses sinusoidal velocities that vanish on all boundaries:

What it demonstrates

  • Building and solving the full MultiphaseStaggeredStokesOperator system with physical boundaries
  • Using FullFACPreconditioner with MultiphaseStaggeredStokesBoxRelaxationFACOperator as the FAC strategy
  • Setting nullspace vectors for the pressure (and optionally velocity) when the system has a constant-pressure nullspace
  • Printing per-variable error norms from solve.cpp:

Grid configuration

Both input files use a 64×64 coarse grid (N = 32*2) on [0,1]² with an L-shaped AMR refinement patch at level 1:

Preconditioner settings

Set USE_PRECOND = FALSE in the input file to run without the multigrid preconditioner. This is useful for isolating solver convergence behavior from preconditioner quality.

channel — pressure-driven channel flow

Source: physical_bc/channel/channel.cpp
Input: physical_bc/channel/input2d
This is a full unsteady simulation of Poiseuille (pressure-driven channel) flow on [0,1]² with Dirichlet velocity boundary conditions. Both phases are assigned the Poiseuille profile u = X_1 * (1 - X_1) on the inflow and outflow faces. The simulation runs to END_TIME = 1.0 and writes a visualization snapshot every VIZ_DUMP_TIME_INTERVAL = 0.05 time units.

Run

Visualization output is written to viz2d/.

What it demonstrates

  • Registering Robin BC coefficient objects for both un and us via ins_integrator->registerPhysicalBoundaryConditions
  • Setting a Dirichlet BC for the advected thn variable via adv_diff_integrator->setPhysicalBcCoef
  • A non-periodic domain (periodic_dimension = 0, 0) compared to the four-roll mill example
  • Side-by-side output of numerical and exact solutions for visual error inspection

Exact solution

Both network and solvent velocities converge to the parabolic Poiseuille profile:
The pressure gradient dp/dx = -2 drives the flow.

Boundary conditions

Dirichlet conditions are imposed on all four boundaries. The x-velocity component (_0) has Poiseuille inflow/outflow values; the y-velocity component (_1) and the transverse sides are set to zero:
thn is held at 0.5 on all boundaries:

Grid and solver settings

The grid uses a single coarse level (max_levels = 1) with static L-shaped refinement boxes defined via REFINE_BOXES. A multigrid preconditioner with MAX_MULTIGRID_LEVELS = 3 is used.
The channel example does not use gradient-based AMR tagging. Instead it uses statically defined REFINE_BOXES in StandardTagAndInitialize. This lets you test physical boundary conditions on an AMR hierarchy without tying the refinement pattern to the solution.