> ## 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.

# MultiphaseStaggeredStokesBoxRelaxationFACOperator

> FAC preconditioner strategy implementing box-relaxation smoothing for the two-fluid staggered Stokes system.

`MultiphaseStaggeredStokesBoxRelaxationFACOperator` is a concrete `IBTK::FACPreconditionerStrategy` that provides the level-smoothing, restriction, and prolongation operations used inside `FullFACPreconditioner`. It implements a Red-Black Gauss–Seidel (RBGS) box-relaxation smoother for the coupled two-fluid staggered Stokes system.

**Namespace:** `multiphase`\
**Header:** `multiphase/MultiphaseStaggeredStokesBoxRelaxationFACOperator.h`

> [!NOTE]
>
> This class is not used directly by most users. It is constructed internally by `MultiphaseStaggeredHierarchyIntegrator` and passed as the `fac_strategy` argument to `FullFACPreconditioner`. See [FullFACPreconditioner](https://bindi-nagda-amr-multiphase.mintlify.site/api/full-fac-preconditioner.md) for higher-level usage.

## Constructor

```cpp theme={null}
MultiphaseStaggeredStokesBoxRelaxationFACOperator(
    const std::string& object_name,
    const std::string& default_options_prefix,
    const MultiphaseParameters& params);
```

**object\_name** `string` *required*

Unique name for this strategy object, used in logging and the SAMRAI object registry.

**default\_options\_prefix** `string` *required*

Prefix used when constructing default PETSc option names for the coarse-level solver.

**params** `const MultiphaseParameters&` *required*

Physical parameters struct (`eta_n`, `eta_s`, `xi`, `nu_n`, `nu_s`) used to assemble the local box systems during smoothing. See [MultiphaseParameters](https://bindi-nagda-amr-multiphase.mintlify.site/api/multiphase-parameters.md).

## Configuration methods

### `setUnderRelaxationParameter`

```cpp theme={null}
void setUnderRelaxationParamater(double w);
```

Sets the under-relaxation (damping) factor for the box-relaxation smoother. The default value is `0.75`. This corresponds to the `W` parameter in the simulation input file.

**w** `double` *required*

Under-relaxation factor. Values in `(0, 1]` are stable; `0.75` is the recommended default from the input file.

***

### `setCandDCoefficients`

```cpp theme={null}
void setCandDCoefficients(double C, double D);
```

Sets the `C` (mass-like diagonal) and `D` (viscous/drag scaling) coefficients used when assembling the local patch systems during smoothing. These must match the coefficients set on the associated `MultiphaseStaggeredStokesOperator`.

**C** `double` *required*

Coefficient multiplying the mass-like diagonal block (`C * thn`, `C * ths`).

**D** `double` *required*

Coefficient scaling the viscous and drag terms. Corresponds to `D_u` in the operator.

***

### `setThnIdx`

```cpp theme={null}
void setThnIdx(int thn_idx);
```

Sets the patch data index for the network volume fraction `thn`. Must be called before smoothing operations are performed.

**thn\_idx** `int` *required*

SAMRAI variable–context index for the cell-centered volume fraction field.

***

### `setPhysicalBcCoefs`

```cpp theme={null}
void setPhysicalBcCoefs(
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& un_bc_coefs,
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& us_bc_coefs,
    SAMRAI::solv::RobinBcCoefStrategy<NDIM>* P_bc_coef,
    SAMRAI::solv::RobinBcCoefStrategy<NDIM>* thn_bc_coef);
```

Registers physical boundary condition objects for all solution components. Any pointer may be `nullptr`, in which case homogeneous conditions are applied.

**un\_bc\_coefs** `std::vector\<RobinBcCoefStrategy\<NDIM\>*\>` *required*

Robin BC coefficients for the network velocity, one per spatial dimension.

**us\_bc\_coefs** `std::vector\<RobinBcCoefStrategy\<NDIM\>*\>` *required*

Robin BC coefficients for the solvent velocity, one per spatial dimension.

**P\_bc\_coef** `RobinBcCoefStrategy\<NDIM\>*` *required*

Robin BC coefficient for the pressure. Pass `nullptr` for homogeneous Neumann.

**thn\_bc\_coef** `RobinBcCoefStrategy\<NDIM\>*` *required*

Robin BC coefficient for the volume fraction. Pass `nullptr` for linear extrapolation.

## FAC strategy interface

These methods implement `IBTK::FACPreconditionerStrategy` and are called by `FullFACPreconditioner` during the multigrid cycle. You do not call them directly.

### `smoothError`

```cpp theme={null}
void smoothError(
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& error,
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& residual,
    int level_num,
    int num_sweeps,
    bool performing_pre_sweeps,
    bool performing_post_sweeps) override;
```

Performs `num_sweeps` box-relaxation sweeps on the specified level. The RBGS smoother is implemented in `src/RBGS.f`.

### `restrictResidual`

```cpp theme={null}
void restrictResidual(
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& source,
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& dest,
    int dest_level_num) override;
```

Restricts the residual from the fine level to `dest_level_num` using the cached restriction schedules.

### `prolongError` / `prolongErrorAndCorrect`

```cpp theme={null}
void prolongError(
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& source,
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& dest,
    int dest_level_num) override;

void prolongErrorAndCorrect(
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& source,
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& dest,
    int dest_level_num) override;
```

Prolongs the error from the coarse level to `dest_level_num`. `prolongErrorAndCorrect` additionally adds the prolongated correction to the existing fine-level error.

### `solveCoarsestLevel`

```cpp theme={null}
bool solveCoarsestLevel(
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& error,
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& residual,
    int coarsest_ln) override;
```

Solves the coarse-level system exactly using a PETSc level solver. Returns `true` on convergence.

### `computeResidual`

```cpp theme={null}
void computeResidual(
    SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& residual,
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& solution,
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& rhs,
    int coarsest_level_num,
    int finest_level_num) override;
```

Computes the composite-grid residual `r = rhs - A*solution` on the specified range of levels.

### `initializeOperatorState` / `deallocateOperatorState`

```cpp theme={null}
void initializeOperatorState(
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& solution,
    const SAMRAI::solv::SAMRAIVectorReal<NDIM, double>& rhs) override;

void deallocateOperatorState() override;
```

Allocates and frees all hierarchy-dependent data (prolongation/restriction schedules, ghost-fill algorithms, scratch variables). Called automatically by `FullFACPreconditioner::initializeSolverState` and `deallocateSolverState`.

## Relation to `W` input parameter

The under-relaxation factor `w` is exposed in the simulation input file as the top-level parameter `W`:

```text input2d theme={null}
W = 0.75
```

This value is read by `MultiphaseStaggeredHierarchyIntegrator` and forwarded to `setUnderRelaxationParamater` before each solve.


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