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.cppInput:
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
muParserRobinBcCoefsfor each velocity component and forthn - 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 fractionthn = 0.75 with sinusoidal velocities on the unit square domain [0,1]² with no-slip Dirichlet conditions:
Boundary condition format
Each velocity component usesmuParserRobinBcCoefs blocks. The Robin coefficients acoef = 1, bcoef = 0 specify pure Dirichlet conditions. gcoef holds the boundary value:
_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.cppInputs:
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
- Homogeneous BCs
- Inhomogeneous BCs
What it demonstrates
- Building and solving the full
MultiphaseStaggeredStokesOperatorsystem with physical boundaries - Using
FullFACPreconditionerwithMultiphaseStaggeredStokesBoxRelaxationFACOperatoras 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
channel — pressure-driven channel flow
Source: physical_bc/channel/channel.cppInput:
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
viz2d/.
What it demonstrates
- Registering Robin BC coefficient objects for both
unandusviains_integrator->registerPhysicalBoundaryConditions - Setting a Dirichlet BC for the advected
thnvariable viaadv_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: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
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.