graphlow.core.MeshTopology.map_face_to_cell#
- MeshTopology.map_face_to_cell(x_face: T, mode: Literal['sum', 'mean', 'conservative', 'div'], method: Literal['segment', 'sparse'] = 'segment') T#
Map face field to cell.
- Parameters:
- x_faceT
Tensor of shape
(n_faces, ...).- mode“sum” | “mean” | “conservative” | “div”
Mapping mode.
"sum"Sum of face values in cell.
"mean"Row-normalized CF operator.
The cell value is computed as the arithmetic average of the values of the faces connected to the cell:
\[x_{\text{cell}} = \frac{1}{\operatorname{deg}(C)} \sum_{f \ni C} x_{\text{face}}\]where \(\operatorname{deg}(C)\) is the number of faces connected to cell \(C\).
This corresponds to a local arithmetic averaging over the cell stencil. In general, this method does not guarantee global conservation of the total quantity.
"conservative"Column-normalized CF operator.
The cell value is obtained by distributing each face value equally among the cells connected to that face:
\[x_{\text{cell}} = \sum_{f \ni C} \left(\frac{1}{\operatorname{deg}(f)}\right) x_{\text{face}}\]where \(\operatorname{deg}(f)\) is the number of cells connected to face \(f\).
Each face contributes its value conservatively to its neighboring cells, and the total sum over cells equals the total sum over faces, making this formulation suitable for conservative transfers.
"div"Divergence of the face field. The cell value is computed as the divergence of the face field:
\[x_{\text{cell}} = \sum_{f \ni C} x_{\text{face}} \cdot n_f\]where \(n_f\) is the normal vector of face \(f\).
This corresponds to a local divergence over the cell stencil.
- method“segment” | “sparse”
Mapping method. Default is “segment”.
"segment"Computes the reduction without explicitly constructing the CF 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 CF matrix with the face values. It depends strongly on backend implementation quality but it can be beneficial when the CF matrix is used repeatedly.
- Returns:
- T
Tensor of shape
(n_cells, ...).