Skip to content

Support for NestedFields in v4 #2289

@erikvansebille

Description

@erikvansebille

There is currently no support in v4-dev for the NestedFields that we had in v3. This is a good opportunity to reconsider how exactly we implement NestedFields

In v3, a NestedField is an (ordered) list of Fields, where an OutOfBoundsError triggers interpolation on the next Field in the list. This means that, for every particle, a Field evaluation is first done in the first Field (the smallest one) and if the particle doesn't 'live' there, the evaluation goes to the next Field.
But this is a very inefficient implementation, because for N nests, each NestedField evolution scales as O(N).

In v4, I propose we try a completely different approach, where we ask the user to provide a mask Field, that gives for each location which Field to interpolate on. The Field evaluation scheme can then pick up the correct Field based on that mask. This is an O(1) operation, and also has the advantage that it can support more complex (i.e. not rectangular) nesting domains

Note that this is already possible in principle in v3, but requires a lot of logic in a Kernel:

def AdvectionEE_Nested_inv3(particle, fieldset, time):
    field_id = fieldset.mask[particle]
    if field_id == 0:
       u, v = fieldset.UV_0[particle]
    if field_id == 1:
       u, v = fieldset.UV_1[particle]
    ...

We could try to put this under the hood in a NestedField class. However, a few things to consider

  • how to construct the mask Field (at which resolution?), and in particular how to deal with particles very close to edges

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Backlog

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions