![]() |
MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
|
Decorator that adds caching to any gradient computation implementation. More...


Public Member Functions | |
| procedure | get (this, n) |
| procedure | set_field (this, phi) |
| final | destructor (this) |
| type(cachedgradienttype) function | constructor (gradient, dis) |
| procedure(get_if), deferred | get (this, n) |
| procedure(set_field_if), deferred | set_field (this, phi) |
Public Attributes | |
| class(igradienttype), allocatable | gradient |
| real(dp), dimension(:, :), allocatable | cached_gradients |
Private Attributes | |
| class(disbasetype), pointer | dis |
This class wraps any IGradientType implementation and provides caching functionality using the Decorator pattern. When set_field is called, it pre-computes gradients for all nodes and stores them in memory for fast O(1) retrieval. This trades memory for speed when gradients are accessed multiple times for the same scalar field.
The class takes ownership of the wrapped gradient object via move semantics and provides the same interface as any other gradient implementation. This allows it to be used transparently in place of the original gradient object.
Usage pattern:
Definition at line 33 of file CachedGradient.f90.
|
final |
| type(cachedgradienttype) function cachedgradientmodule::cachedgradienttype::constructor | ( | class(igradienttype), intent(inout), allocatable | gradient, |
| class(disbasetype), intent(in), pointer | dis ) |
Definition at line 50 of file CachedGradient.f90.
| procedure cachedgradientmodule::cachedgradienttype::get | ( | class(cachedgradienttype), target | this, |
| integer(i4b), intent(in) | n ) |
Definition at line 39 of file CachedGradient.f90.
|
pure virtualinherited |
Definition at line 17 of file IGradient.f90.
| procedure cachedgradientmodule::cachedgradienttype::set_field | ( | class(cachedgradienttype), target | this, |
| real(dp), dimension(:), intent(in), pointer | phi ) |
Definition at line 40 of file CachedGradient.f90.
|
pure virtualinherited |
Definition at line 18 of file IGradient.f90.
| real(dp), dimension(:, :), allocatable cachedgradientmodule::cachedgradienttype::cached_gradients |
Definition at line 37 of file CachedGradient.f90.
|
private |
Definition at line 35 of file CachedGradient.f90.
| class(igradienttype), allocatable cachedgradientmodule::cachedgradienttype::gradient |
Definition at line 36 of file CachedGradient.f90.