Mercurial > repos > public > sbplib_julia
changeset 1528:d641798539c2
Update notes on changes to `eval_on` and multiblock grids
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 10 Apr 2024 09:01:54 +0200 |
parents | 2cee20ecc0bc |
children | 43aaf710463e 46a1ad30f861 9da4ab4fb85e 0eee3a4140a6 450110ed5d18 d4adee53aa30 a020afa9d076 5193e6cd6c6a |
files | Notes.md src/Grids/grid.jl |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Notes.md Tue Apr 09 07:48:20 2024 +0200 +++ b/Notes.md Wed Apr 10 09:01:54 2024 +0200 @@ -186,18 +186,41 @@ The interaction of the map methods with the probable design of multiblock functions involving nested indecies complicate the picture slightly. It's clear at the time of writing how this would work with `Base.map`. Perhaps we want to implement our own versions of both eager and lazy map. + +### 2024-04 +MappedArrays.jl provides a simple array type and function like the description +of LazyMapping above. One option is to remove `eval_on` completely and rely on +destructuring arguments if handling the function input as a vector is +undesirable. + +If we can let multi-block grids be iterators over grid points we could even +handle those by specialized implementation of `map` and `mappedarray`. + ## Multiblock implementation We want multiblock things to work very similarly to regular one block things. ### Grid functions -Should probably support a nested indexing so that we first have an index for subgrid and then an index for nodes on that grid. E.g `g[1,2][2,3]` or `g[3][43,21]`. +Should probably support a nested indexing so that we first have an index for +subgrid and then an index for nodes on that grid. E.g `g[1,2][2,3]` or +`g[3][43,21]`. -We could also possibly provide a combined indexing style `g[1,2,3,4]` where the first group of indices are for the subgrid and the remaining are for the nodes. +We could also possibly provide a combined indexing style `g[1,2,3,4]` where +the first group of indices are for the subgrid and the remaining are for the +nodes. -We should make sure the underlying buffer for gridfunctions are continuously stored and are easy to convert to, so that interaction with for example DifferentialEquations is simple and without much boilerplate. +We should make sure the underlying buffer for grid functions are continuously +stored and are easy to convert to, so that interaction with for example +DifferentialEquations is simple and without much boilerplate. #### `map` and `collect` and nested indexing -We need to make sure `collect`, `map` and a potential lazy map work correctly through the nested indexing. +We need to make sure `collect`, `map` and a potential lazy map work correctly +through the nested indexing. Also see notes on `eval_on` above. + +Possibly this can be achieved by providing special nested indexing but not +adhering to an array interface at the top level, instead being implemented as +an iterator over the grid points. A custom trait can let map and other methods +know the shape (or structure) of the nesting so that they can efficiently +allocate result arrays. ### Tensor applications Should behave as grid functions
--- a/src/Grids/grid.jl Tue Apr 09 07:48:20 2024 +0200 +++ b/src/Grids/grid.jl Wed Apr 10 09:01:54 2024 +0200 @@ -141,6 +141,8 @@ if hasmethod(f, (Any,)) return LazyTensors.LazyFunctionArray((I...)->f(g[I...]), size(g)) else + # TBD This branch can be removed if we accept the trade off that we define f with the syntax f((x,y)) instead if we don't want to handle the vector in the body of f. (Add an example in the docs) + # Also see Notes.md return LazyTensors.LazyFunctionArray((I...)->f(g[I...]...), size(g)) end end