Replies: 1 comment 2 replies
-
Thanks! <3 The purpose of this design is to support a user interface wherein masks can be plainly specified as functions of To support parameterized functions within this framework in the source code, those parameterized functions must be attached to callable objects that store the parameters. For example, the @inline (g::GaussianMask{:x})(x, y, z) = exp(-(x - g.center)^2 / (2 * g.width^2)) makes You can use this in your own code too, if you don't want to use masking functions that are closures (ie they capture parameters from the global scope). It's a bit neater to capture parameters via callable objects (your code is more portable). Does that help / is that the answer you are looking for? |
Beta Was this translation helpful? Give feedback.
-
Hello and thank you for maintaining this amazingly intuitive model,
I have started using Oceananigans this year and am currently developing some custom functions for building boundaries and forcings. Sorry if this is a bit of basic question, but I noticed most functions are wrapped in custom structures. Why is the code written this way and is there an advantage for building these structures instead of passing the function directly to where they are used?
Exemplifying, the relaxation scheme creates a mask structure, which is then passed as one of the fields for the relaxation struct, then the functions are inlined as in the shortened code below. Why not pass the masking function directly to the relaxation structure?
Beta Was this translation helpful? Give feedback.
All reactions