-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer dimension of arrays from input to struct. Add global dimension constants. #288
Conversation
…uct, rather than hardcode size.
Why not create the global constants? I get it might be a lot of work to consistently use them everywhere right away, but if they exist we can build them in gradually where it makes sense. Given the current design of the code, arrays have to have a hard-coded number of dimensions - and I think that would be very hard to change - so we might as well be explicit. For example, we could then also use the values in function signatures to verify that we are doing the right thing, e.g. function foo(ion_moment::AbstractArray{mk_float,ion_moment_ndim})
...
end Just on the variable names, I'd prefer to use something like |
I agree this could be nice for the instances which represent the full pdf, but I noticed that many instances (e.g., the buffer arrays) we are defining some slice of the pdf. If we slice 1, 2, 3, 4 ... dimensions then we just end up with
Here I followed the existing convention for dimension variables in |
How many is 'many'? I think it depends on the case, and there may not be a perfect answer. My gut reaction is to say define just the full dimension sizes For function arguments, the workarounds for the restrictions on type parameters are less awful, e.g.
Yes, I'd be in favour of more descriptive names - I don't think I chose the original ones well. The originals are not too bad when they're just type parameters within a single struct, where it's fairly clear from the context what they mean, but as global constants they would be pretty awful names. |
…ventions appreciated.
OK, I agree with your comments. I have made an initial set of name choices (they are a cyclic permutation of yours -- I made the choices before reading your last comment, happy to change to another cyclic permutation), but I haven't started using them outside of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Names are fine 👍
Need to remove some redundant template parameters - see comments below.
Right -- so you want to move away from inferred types entirely where possible and just use the global variables? If so, that's fine by me. |
Yes. I think it's nicest to minimise the template parameters where possible, so where the global parameters exist we should use them. |
The latest version should implement all your comments. |
Infer number of field, gyroaveraged field, moment dimensions from call to struct, rather than hardcode size. PR to address spirit of #46, may close #46. Where obvious, we infer moments and field array dimensions from the arrays themselves.
This could be extended by creating global dimension variables, as discussed in issue #46, but this would have to address how to use these variables in code like,
moment_kinetics/moment_kinetics/src/time_advance.jl
Lines 96 to 217 in e99da09
moment_kinetics/moment_kinetics/src/time_advance.jl
Lines 219 to 229 in e99da09
moment_kinetics_structs.jl
moment_kinetics/moment_kinetics/src/moment_kinetics_structs.jl
Lines 366 to 373 in e99da09
moment_kinetics/moment_kinetics/src/moment_kinetics_structs.jl
Lines 335 to 342 in e99da09