Weighted least-squares gradient method for structured and unstructured grids.
More...
This class implements a least-squares gradient reconstruction for use on both structured and unstructured grids. For each cell, it precomputes and caches a gradient reconstruction matrix using the Moore-Penrose pseudoinverse, based on the geometry and connectivity of the mesh. The operator is created once during initialization and can then be efficiently applied to any scalar field to compute the gradient in each cell. The gradient can then be computed by multiplying the reconstruction matrix with the difference vector. ∇ɸ = R * ∑(ɸ_i - ɸ_up), where i are the neighboring cells.
- The gradient operator is constructed using normalized direction vectors between cell centers, scaled by the inverse of the distance.
- The least-squares approach ensures robust gradients even for irregular or rank-deficient stencils.
- The operator is cached for each cell, so gradient computation is efficient for repeated queries.
- The class provides a
get
method to compute the gradient for any cell and scalar field.
- Note
- Boundary cells are not handled in a special manner. This may impact the quality of the gradient near boundaries, especially if a cell does not have enough neighbors (fewer than three in 3D).
Definition at line 37 of file LeastSquaresGradient.f90.