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

# MultiphaseConvectiveManager

> Encapsulates the momentum convective operator approximation for the two-fluid multiphase equations.

## Overview

`MultiphaseConvectiveManager` manages all routines required to approximate the momentum convective operator for the multiphase equations. It performs flux-differencing of the phase-weighted momenta using a limited upwind scheme on the staggered MAC grid.

**Namespace:** `multiphase`

**Header:** `multiphase/MultiphaseConvectiveManager.h`

The class lazily allocates patch data on first use and does not maintain state across a regridding operation.

> [!WARNING]
>
> This class must be destroyed or have `deallocateData` called **before** any regridding operation. Because it does not maintain state across regridds, it cannot be used in isolation with multistep (e.g. Adams–Bashforth) algorithms.

## Available limiters

The following `IBAMR::LimiterType` values are supported:

| Limiter | Description |
| - | - |
| `UPWIND` | First-order upwind (default) |
| `CUI` | Cubic upwind interpolation |
| `FBICS` | Flux-based interpolation cubic scheme |
| `MGAMMA` | Monotone gamma scheme |

## Constructors

### Database-based constructor

```cpp theme={null}
MultiphaseConvectiveManager(
    std::string object_name,
    SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM>> hierarchy,
    SAMRAI::tbox::Pointer<SAMRAI::tbox::Database> input_db,
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& un_bc_coefs = {},
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& us_bc_coefs = {},
    SAMRAI::solv::RobinBcCoefStrategy<NDIM>* thn_bc_coef = nullptr);
```

Constructs the manager by reading the limiter type from the input database. The database must contain the key `"limiter_type"` with one of the supported limiter strings: `"UPWIND"`, `"CUI"`, `"FBICS"`, or `"MGAMMA"`.

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

Unique name for this object, used for variable registration and logging.

**hierarchy** `SAMRAI::tbox::Pointer\<SAMRAI::hier::PatchHierarchy\<NDIM\>\>` *required*

The AMR patch hierarchy on which convective terms are computed.

**input\_db** `SAMRAI::tbox::Pointer\<SAMRAI::tbox::Database\>` *required*

Input database. Must contain `"limiter_type"` specifying one of the supported limiter strings.

**un\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` (default: \{})

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

**us\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` (default: \{})

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

**thn\_bc\_coef** `SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*` (default: nullptr)

Robin BC coefficient for the volume fraction. Pass `nullptr` to use linear extrapolation at physical boundaries.

***

### LimiterType-based constructor

```cpp theme={null}
MultiphaseConvectiveManager(
    std::string object_name,
    SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM>> hierarchy,
    IBAMR::LimiterType limiter_type,
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& un_bc_coefs = {},
    const std::vector<SAMRAI::solv::RobinBcCoefStrategy<NDIM>*>& us_bc_coefs = {},
    SAMRAI::solv::RobinBcCoefStrategy<NDIM>* thn_bc_coef = nullptr);
```

Constructs the manager with an explicitly provided `LimiterType` value.

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

Unique name for this object.

**hierarchy** `SAMRAI::tbox::Pointer\<SAMRAI::hier::PatchHierarchy\<NDIM\>\>` *required*

The AMR patch hierarchy on which convective terms are computed.

**limiter\_type** `IBAMR::LimiterType` *required*

Limiter to use for momentum interpolation. One of `UPWIND`, `CUI`, `FBICS`, or `MGAMMA`.

**un\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` (default: \{})

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

**us\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` (default: \{})

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

**thn\_bc\_coef** `SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*` (default: nullptr)

Robin BC coefficient for the volume fraction.

## Methods

### `approximateConvectiveOperator` (with copy)

```cpp theme={null}
void approximateConvectiveOperator(
    int dst_un_idx,
    int dst_us_idx,
    IBAMR::TimeSteppingType ts_type,
    double current_time,
    double new_time,
    int un_cur_idx,
    int us_cur_idx,
    int thn_cur_idx,
    int un_new_idx,
    int us_new_idx,
    int thn_new_idx);
```

Computes the convective operator approximation and copies results into `dst_un_idx` and `dst_us_idx`. Either destination index may be an invalid index, in which case that copy is skipped.

For `ts_type = FORWARD_EULER`, the new-time indices (`un_new_idx`, `us_new_idx`, `thn_new_idx`) are not used and may be invalid.

**dst\_un\_idx** `int` *required*

Patch data index to receive the network-phase convective operator result. Pass an invalid index to skip.

**dst\_us\_idx** `int` *required*

Patch data index to receive the solvent-phase convective operator result. Pass an invalid index to skip.

**ts\_type** `IBAMR::TimeSteppingType` *required*

Time-stepping scheme: `FORWARD_EULER`, `MIDPOINT_RULE`, or `TRAPEZOIDAL_RULE`.

**current\_time** `double` *required*

Current simulation time t^n.

**new\_time** `double` *required*

New simulation time t^{n+1}.

**un\_cur\_idx** `int` *required*

Patch index for the network velocity at time t^n.

**us\_cur\_idx** `int` *required*

Patch index for the solvent velocity at time t^n.

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

Patch index for the volume fraction at time t^n.

**un\_new\_idx** `int` *required*

Patch index for the network velocity at time t^{n+1}. May be invalid for `FORWARD_EULER`.

**us\_new\_idx** `int` *required*

Patch index for the solvent velocity at time t^{n+1}. May be invalid for `FORWARD_EULER`.

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

Patch index for the volume fraction at time t^{n+1}. May be invalid for `FORWARD_EULER`.

***

### `approximateConvectiveOperator` (without copy)

```cpp theme={null}
void approximateConvectiveOperator(
    IBAMR::TimeSteppingType ts_type,
    double current_time,
    double new_time,
    int un_cur_idx,
    int us_cur_idx,
    int thn_cur_idx,
    int un_new_idx,
    int us_new_idx,
    int thn_new_idx);
```

Identical to the copy variant but does not transfer results to any external indices. Retrieve the result afterwards using `fillWithConvectiveOperator` or `getConvectiveIndices`.

**ts\_type** `IBAMR::TimeSteppingType` *required*

Time-stepping scheme: `FORWARD_EULER`, `MIDPOINT_RULE`, or `TRAPEZOIDAL_RULE`.

**current\_time** `double` *required*

Current simulation time t^n.

**new\_time** `double` *required*

New simulation time t^{n+1}.

**un\_cur\_idx** `int` *required*

Patch index for the network velocity at t^n.

**us\_cur\_idx** `int` *required*

Patch index for the solvent velocity at t^n.

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

Patch index for the volume fraction at t^n.

**un\_new\_idx** `int` *required*

Patch index for the network velocity at t^{n+1}. May be invalid for `FORWARD_EULER`.

**us\_new\_idx** `int` *required*

Patch index for the solvent velocity at t^{n+1}. May be invalid for `FORWARD_EULER`.

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

Patch index for the volume fraction at t^{n+1}. May be invalid for `FORWARD_EULER`.

***

### `fillWithConvectiveOperator`

```cpp theme={null}
void fillWithConvectiveOperator(int dst_un_idx, int dst_us_idx);
```

Copies the most recent convective operator approximation into the provided patch indices. If either index is invalid, that copy is skipped.

**dst\_un\_idx** `int` *required*

Destination patch index for the network-phase result.

**dst\_us\_idx** `int` *required*

Destination patch index for the solvent-phase result.

***

### `getConvectiveIndices`

```cpp theme={null}
std::pair<int, int> getConvectiveIndices() const;
```

Returns the internal patch data index pair holding the most recent convective operator approximation. The first element of the pair is the network-phase index; the second is the solvent-phase index.

***

### `deallocateData`

```cpp theme={null}
void deallocateData();
```

Deallocates all patch data associated with this object. You must call this (or destroy the object) before any regridding operation.

***

### `resetData`

```cpp theme={null}
void resetData();
```

Resets the manager to a blank state without deallocating patch memory. Useful for clearing operator state between time steps when the hierarchy has not changed.

***

### `setBoundaryConditions`

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

Updates the boundary condition objects at any point after construction. This class does not take ownership of any of these objects.

**un\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` *required*

Robin BC coefficients for the network velocity.

**us\_bc\_coefs** `const std::vector\<SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*\>&` *required*

Robin BC coefficients for the solvent velocity.

**thn\_bc\_coef** `SAMRAI::solv::RobinBcCoefStrategy\<NDIM\>*` *required*

Robin BC coefficient for the volume fraction. May be `nullptr`.

## Regridding note

`MultiphaseConvectiveManager` does not rebuild its internal state after a regridding event. Before calling any regrid routine, either destroy the object or call `deallocateData`. After regridding, reconstruct or reinitialise the manager with the updated hierarchy.

```cpp theme={null}
// Before regrid
convective_manager->deallocateData();

// ... perform regrid ...

// After regrid: re-create or reset the manager
convective_manager = std::make_unique<MultiphaseConvectiveManager>(
    "ConvectiveManager", new_hierarchy, IBAMR::LimiterType::CUI,
    un_bc_coefs, us_bc_coefs, thn_bc_coef);
```


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