Utilities

ClimaCore.Utilities.PlusHalfType
PlusHalf(i)

Represents i + 1/2, but stored as internally as an integer value. Used for indexing into staggered finite difference meshes: the convention "half" values are indexed at cell faces, whereas centers are indexed at cell centers.

Supports +, - and inequalities.

See also half.

source
ClimaCore.Utilities.replace_type_parameterFunction
replace_type_parameter(T, P, P′)

Recursively modifies the parameters of T, replacing every subtype of P with P′. This is like constructing a value of type T and converting subfields of type P to type P′, though no constructors are actually called or compiled.

source
ClimaCore.Utilities.fieldtype_valsFunction
fieldtype_vals(T)

Statically inferrable analogue of Val.(fieldtypes(T)). Functions of Types are specialized upon successful constant propagation, but functions of Vals are always specialized, so fieldtype_vals can be used in place of fieldtypes to ensure that recursive functions over nested types have inferrable outputs.

source
ClimaCore.Utilities.newFunction
new(T, [fields])

Exposes the new pseudo-function that allocates a value of type T with the specified fields. Can also be called without a second argument to leave the allocated value with uninitialized fields.

In contrast to the pseudo-function, this only asserts that all fields match the fieldtypes of T, rather than automatically converting them to those types.

source

Utilities.Cache

ClimaCore.Utilities.CacheModule

Utilities.Cache

ClimaCore maintains an internal cache of topology and grid objects: this ensures that if the constructor with the same arguments is invoked again (e.g. by reading from a file), the cached object will be returned (also known as memoization). This has two main advantages:

  1. topology and metric information can be reused, reducing memory usage.

  2. it is easy to check if two fields live on the same grid: we can just check if the underlying grid objects are the same (===), rather than checking all the fields are equal (via ==).

However this means that objects in the cache will not be removed from the garbage collector, so we provide an interface to remove these.

source
ClimaCore.Utilities.Cache.clean_cache!Function
Utilities.Cache.clean_cache!(object)

Remove object from the cache of created objects.

In most cases, this function should not need to be called, unless you are constructing many grid objects, for example when doing a sweep over grid paramaters.

source
Utilities.Cache.clean_cache!()

Remove all objects from the cache of created objects.

In most cases, this function should not need to be called, unless you are constructing many grid objects, for example when doing a sweep over grid paramaters.

source