graphlow.core.MeshTopology.map_cell_to_face#

MeshTopology.map_cell_to_face(x_cell: T, mode: Literal['sum', 'mean', 'conservative', 'diff'], method: Literal['segment', 'sparse'] = 'segment') T#

Map cell field to face.

Parameters:
x_cellT

Tensor of shape (n_cells, ...).

mode“sum” | “mean” | “conservative” | “diff”

Mapping mode.

"sum"

Sum of cell values that are connected to the face. For manifold meshes, this corresponds to:

\[x_{\text{face}} = x_{\text{cell}}[\text{owner}] + x_{\text{cell}}[\text{neighbor}]\]
"mean"

The face value is computed as the arithmetic average of the values of the cells connected to the face. For manifold meshes, this corresponds to:

\[x_{\text{face}} = \frac{1}{2} \left( x_{\text{cell}}[\text{owner}] + x_{\text{cell}}[\text{neighbor}] \right)\]

In general, this method does not guarantee global conservation of the total quantity.

"conservative"

The face value is obtained by distributing each cell value equally among the faces connected to that cell:

\[x_{\text{face}} = \sum_{C \ni f} \left(\frac{1}{\operatorname{deg}(C)}\right) x_{\text{cell}}\]

where \(\operatorname{deg}(C)\) is the number of faces in cell \(C\).

Each cell contributes its value conservatively to its faces, and the total sum over faces equals the total sum over cells, making this formulation suitable for conservative transfers.

"diff"

Difference of the cell field. The face value is computed as the difference of the cell field:

\[x_{\text{face}} = x_{\text{cell}}[\text{owner}] - x_{\text{cell}}[\text{neighbor}]\]

This corresponds to a local difference over the cell stencil.

method“segment” | “sparse”

Mapping method. Default is “segment”.

"segment"

Computes the reduction without explicitly constructing the FC matrix. It is typically more memory efficient, especially on GPU. In most practical settings, this method is recommended.

"sparse"

Computes the reduction by multiplying the FC matrix with the cell values. It depends strongly on backend implementation quality but it can be beneficial when the FC matrix is used repeatedly.

Returns:
T

Tensor of shape (n_faces, ...).