Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pymrm.ibm_coupling.apply_ibm_interface

Back to module page · Back to alphabetical overview

Signature

apply_ibm_interface(mat, ibm, recon, ic, *, det_tol = 1e-12, return_values = False)

Summary

Apply general linear interface conditions to an operator matrix.

Documentation

Combines pymrm.apply_ibm (ghost-column folding, source matrices) with the interface-value elimination of construct_ibm_interface_values:

``A_final = A_ibm + G_out @ H_out + G_in @ H_in``
``g_final = G_out @ h_out + G_in @ h_in``

Parameters

Returns

Source

View on GitHub

def apply_ibm_interface(mat, ibm, recon, ic, *, det_tol=1e-12,
                        return_values=False):
    """Apply general linear interface conditions to an operator matrix.

    Combines :func:`pymrm.apply_ibm` (ghost-column folding, source matrices)
    with the interface-value elimination of
    :func:`construct_ibm_interface_values`:

        ``A_final = A_ibm + G_out @ H_out + G_in @ H_in``
        ``g_final = G_out @ h_out + G_in @ h_in``

    Parameters
    ----------
    mat : sparse matrix or array
        Operator matrix of shape ``(n_cells, n_cells)``.
    ibm : IBM
    recon : IBMNormalDerivative
    ic : tuple of dict
        Two interface equations (module docstring).
    det_tol : float, optional
        Passed to :func:`construct_ibm_interface_values`.
    return_values : bool, optional
        Also return ``(H_out, h_out, H_in, h_in)`` for post-processing wall
        values and fluxes.

    Returns
    -------
    A_final : csr_array
        Modified operator matrix.
    g_final : ndarray, shape (n_cells,)
        Interface source (sign convention: *added*, ``value = A @ c + g``).
    values : tuple, optional
        Only when *return_values* is true.
    """
    A_ibm, G_out, G_in = apply_ibm(mat, ibm, return_bc="matrix")
    H_out, h_out, H_in, h_in = construct_ibm_interface_values(
        ibm, recon, ic, det_tol=det_tol)
    A_final = (A_ibm + G_out @ H_out + G_in @ H_in).tocsr()
    g_final = (np.asarray(G_out @ h_out).ravel()
               + np.asarray(G_in @ h_in).ravel())
    if return_values:
        return A_final, g_final, (H_out, h_out, H_in, h_in)
    return A_final, g_final