MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
leastsquaresgradientmodule::leastsquaresgradienttype Interface Reference

Weighted least-squares gradient method for structured and unstructured grids. More...

Inheritance diagram for leastsquaresgradientmodule::leastsquaresgradienttype:
Inheritance graph
Collaboration diagram for leastsquaresgradientmodule::leastsquaresgradienttype:
Collaboration graph

Private Member Functions

procedure get
 
procedure, private compute_cell_gradient
 
procedure, private create_gradient_reconstruction_matrix
 
type(leastsquaresgradienttype) function constructor (dis)
 

Private Attributes

class(disbasetype), pointer dis
 
type(array2d), dimension(:), allocatable r
 

Detailed Description

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.

Member Function/Subroutine Documentation

◆ compute_cell_gradient()

procedure, private leastsquaresgradientmodule::leastsquaresgradienttype::compute_cell_gradient
private

Definition at line 43 of file LeastSquaresGradient.f90.

◆ constructor()

type(leastsquaresgradienttype) function leastsquaresgradientmodule::leastsquaresgradienttype::constructor ( class(disbasetype), intent(in), pointer  dis)
private

Definition at line 52 of file LeastSquaresGradient.f90.

53  ! --dummy
54  class(DisBaseType), pointer, intent(in) :: dis
55  !-- return
56  type(LeastSquaresGradientType) :: gradient
57  ! -- local
58  integer(I4B) :: n, nodes
59 
60  gradient%dis => dis
61  nodes = dis%nodes
62 
63  ! -- Compute the gradient rec
64  nodes = dis%nodes
65  allocate (gradient%R(dis%nodes))
66  do n = 1, nodes
67  gradient%R(n)%data = gradient%create_gradient_reconstruction_matrix(n)
68  end do

◆ create_gradient_reconstruction_matrix()

procedure, private leastsquaresgradientmodule::leastsquaresgradienttype::create_gradient_reconstruction_matrix
private

Definition at line 44 of file LeastSquaresGradient.f90.

Here is the call graph for this function:

◆ get()

procedure leastsquaresgradientmodule::leastsquaresgradienttype::get
private

Definition at line 41 of file LeastSquaresGradient.f90.

Member Data Documentation

◆ dis

class(disbasetype), pointer leastsquaresgradientmodule::leastsquaresgradienttype::dis
private

Definition at line 38 of file LeastSquaresGradient.f90.

38  class(DisBaseType), pointer :: dis

◆ r

type(array2d), dimension(:), allocatable leastsquaresgradientmodule::leastsquaresgradienttype::r
private

Definition at line 39 of file LeastSquaresGradient.f90.

39  type(Array2D), allocatable, dimension(:) :: R ! Gradient reconstruction matrix

The documentation for this interface was generated from the following file: