Skip to content

BackgroundField is a confusing name #3586

Open
@glwagner

Description

@glwagner

It's not a Field. The docstring for the struct admits as much:

"""
BackgroundField{F, P}
Temporary container for storing information about `BackgroundFields`.
"""
struct BackgroundField{F, P}
func:: F
parameters :: P
end

and this temporary struct is always thrown away to build a "real" field:

regularize_background_field(LX, LY, LZ, f::BackgroundField{<:Function}, grid, clock) =
FunctionField{LX, LY, LZ}(f.func, grid; clock=clock, parameters=f.parameters)

The problem is that the name leads to confusing patterns like

B_field = BackgroundField(constant_stratification, parameters=(; ĝ, N² = 1e-5))

where B_field is not a field. Indeed, later on when we need a "real" field we have to write

B∞ = model.background_fields.tracers.b

Can we think of a better name? For example BackgroundFieldInfo is one. That's sorta clumsy though. Maybe we can come up with something more concise and elegant.

cc @tomchor @hdrake @liuchihl because you are using this feature

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions