Sparse-matrix utilities for multi-domain coupling and interface assembly.
Public API¶
| Symbol | Type | Summary |
|---|---|---|
construct_interface_matrices | function | Construct implicit interface-coupling matrices for two adjacent domains. |
translate_indices_to_larger_array | function | Map flat indices from a local array shape to a larger embedding shape. |
update_array_indices | function | Update sparse-matrix indices for a new embedding shape. |
update_csc_array_indices | function | Update CSC matrix row/column indexing for embedding in a larger domain. |
update_csr_array_indices | function | Update CSR matrix row/column indexing for embedding in a larger domain. |
construct_interface_matrices(shapes, x_fs, x_cs = (None, None), ic = ({'a': (1, 1), 'b': (0, 0), 'd': 0}, {'a': (0, 0), 'b': (1, -1), 'd': 0}), axis = 0, shapes_d = (None, None), format = 'csc')¶
Construct implicit interface-coupling matrices for two adjacent domains.
Parameters¶
shapes(tuple[tuple[int, ...], tuple[int, ...]]) Shapes of the two subdomains.x_fs(tuple[array_like, array_like]) Face coordinates for each subdomain alongaxis.x_cs(tuple[array_like | None, array_like | None], optional) Cell-center coordinates for each subdomain.ic(tuple[dict, dict], optional) Two interface equations. Each dictionary may definea,b, anddterms with coefficients for both subdomains.axis(int, optional) Interface-normal axis.shapes_d(tuple[tuple | None, tuple | None], optional) Optional source-vector shapes for decomposed inhomogeneous terms.format({‘csc’, ‘csr’}, optional) Sparse format for the homogeneous interface matrices.
Returns¶
tupleWithoutshapes_d:(mat0, bc0, mat1, bc1). Withshapes_d:(mat0, bc00, bc01, mat1, bc10, bc11).
translate_indices_to_larger_array(linear_indices, shape, new_shape, offset = None)¶
Map flat indices from a local array shape to a larger embedding shape.
Parameters¶
linear_indices(array_like) Flat indices defined inshape.shape(tuple[int, ...]) Local array shape.new_shape(tuple[int, ...]) Embedding array shape.offset(tuple[int, ...], optional) Offset of the local array origin in the embedding array.
Returns¶
numpy.ndarrayFlat indices innew_shape.
update_array_indices(sparse_mat, shape, new_shape, offset = None)¶
Update sparse-matrix indices for a new embedding shape.
Parameters¶
sparse_mat(scipy.sparse.sparray) Input matrix. CSR and CSC are supported.shape, new_shape(tuple or tuple[tuple, tuple]) Original and target logical shapes for rows and columns. A single tuple applies to both rows and columns.offset(tuple or tuple[tuple, tuple], optional) Optional row/column offsets of the local block in the larger domain.
Returns¶
scipy.sparse.sparrayMatrix with updated shape and indices, preserving the input format where possible.
update_csc_array_indices(sparse_mat, shape, new_shape, offset = None)¶
Update CSC matrix row/column indexing for embedding in a larger domain.
.. deprecated::
Use update_array_indices for automatic format dispatch.
update_csr_array_indices(sparse_mat, shape, new_shape, offset = None)¶
Update CSR matrix row/column indexing for embedding in a larger domain.