314
314
"""
315
315
zeros(space::AbstractSpace)
316
316
317
- Construct a field on `space` that is zero everywhere.
317
+ Create a new field on `space` that is zero everywhere.
318
318
"""
319
319
function Base. zeros (:: Type{FT} , space:: AbstractSpace ) where {FT}
320
320
field = Field (FT, space)
@@ -327,7 +327,7 @@ Base.zeros(space::AbstractSpace) = zeros(Spaces.undertype(space), space)
327
327
"""
328
328
ones(space::AbstractSpace)
329
329
330
- Construct a field on `space` that is one everywhere.
330
+ Create a new field on `space` that is one everywhere.
331
331
"""
332
332
function Base. ones (:: Type{FT} , space:: AbstractSpace ) where {FT}
333
333
field = Field (FT, space)
348
348
"""
349
349
coordinate_field(space::AbstractSpace)
350
350
351
- Construct a `Field` of the coordinates of the space .
351
+ Return a pointer to the input space's coordinates `Field` .
352
352
"""
353
353
coordinate_field (space:: AbstractSpace ) =
354
354
Field (Spaces. coordinates_data (space), space)
@@ -357,7 +357,7 @@ coordinate_field(field::Field) = coordinate_field(axes(field))
357
357
"""
358
358
local_geometry_field(space::AbstractSpace)
359
359
360
- Construct a `Field` of the `LocalGeometry` of the space .
360
+ Return a pointer to the input space's `LocalGeometry` `Field` .
361
361
"""
362
362
local_geometry_field (space:: AbstractSpace ) =
363
363
Field (Spaces. local_geometry_data (space), space)
@@ -367,7 +367,8 @@ local_geometry_field(field::Field) = local_geometry_field(axes(field))
367
367
Δz_field(field::Field)
368
368
Δz_field(space::AbstractSpace)
369
369
370
- A `Field` containing the `Δz` values on the same space as the given field.
370
+ Return a pointer to the input space's `Field` containing the `Δz` values on the
371
+ same space as the given field.
371
372
"""
372
373
Δz_field (field:: Field ) = Δz_field (axes (field))
373
374
Δz_field (space:: AbstractSpace ) = Field (Spaces. Δz_data (space), space)
@@ -521,12 +522,29 @@ Base.@propagate_inbounds Base.setindex!(field::PointField, val) =
521
522
"""
522
523
set!(f::Function, field::Field, args = ())
523
524
524
- Apply function `f` to populate
525
- values in field `field`. `f` must
526
- have a function signature with signature
527
- `f(::LocalGeometry[, args...])`.
528
- Additional arguments may be passed to
529
- `f` with `args`.
525
+ Apply function `f` to populate values in field `field`. `f` must have a function
526
+ signature with signature `f(::LocalGeometry[, args...])`. Additional arguments
527
+ may be passed to `f` with `args`.
528
+
529
+ ## Example
530
+
531
+ ```julia
532
+ using ClimaCore.Fields
533
+ using ClimaCore.CommonSpaces
534
+ ᶜspace = ExtrudedCubedSphereSpace(Float64;
535
+ z_elem = 10,
536
+ z_min = 0,
537
+ z_max = 1,
538
+ radius = 10,
539
+ h_elem = 10,
540
+ n_quad_points = 4,
541
+ staggering = CellCenter(),
542
+ )
543
+ x = Fields.Field(Float64, ᶜspace)
544
+ Fields.set!(x) do lg
545
+ sin(lg.coordinates.z)
546
+ end
547
+ ```
530
548
"""
531
549
function set! (f:: Function , field:: Field , args = ())
532
550
space = axes (field)
0 commit comments