-
Notifications
You must be signed in to change notification settings - Fork 195
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
NonhydrostaticModel
creates an extra empty element in diffusivities
list when a tuple is passed to as closure
#1878
Comments
For tupled closures we use a tuple of diffusivities. So the in your example, Tuple closures are certainly a bit rough... what do you expect to have here? What would you expect to happen with, for example, three closures, two of which have diffusivities but one of which does not? |
Part of the problem we are trying to solve is how to evaluate the closure term for multiple closure models. For this we basically unroll a loop (using recursion) over all the closures, and add each term separately. Since the closure term (the flux divergence) expects a diffusivity, we need For example, see how the closure term is evaluated for a tuple of two closures: Oceananigans.jl/src/TurbulenceClosures/closure_tuples.jl Lines 14 to 16 in 201b50e
|
I don't really understand the question though. What do you mean by a closure without diffusivity? The way I see it every closure has a diffusivity associated with it (and here I'm counting viscosity as a momentum diffusivity), whether it's a constant diffusivity or a dynamically-calculated (eddy) one. (The exception being That said, what I expected was |
Scratch that! I was thinking of a specific example I had in mind and forgot that not every closure can be simplified to the sum of diffusivities times the nabla operator. |
Ah I see the confusion. The field model.diffusivities stores viscosities and diffusivities that have to be precomputed. For diffusivities prescribed as constants or functions we don't need to store the diffusivities; instead the information needed to compute the diffusivity or viscosity is bound to model.closure. Perhaps we could call this model property "diffusivity_fields"? This would distinguish the information there from constant or function diffusivities. |
Yeah I think this change would help! It would definitely make things
clearer.
Here's a couple alternative thoughts though:
Would it be possible to get rid of diffusivities altogether and store the
precomputed fields in the closures directly? E.g. AMD would have an extra
field data, so would smagorinsky and so on. I think it'd simplify things,
although I'm not sure how feasible that would be. I guess in order to
calculate those, the closure would need to already be associated with a
model, so that's a downside right away...
Another thought: why not just also store the constant viscosities in the
diffusivities property? I know it's not necessary, but it wouldn't take up
any significant space and it would make things more intuitive/organized I
think.
…On Tue, Jul 20, 2021, 12:40 Gregory L. Wagner ***@***.***> wrote:
Ah I see the confusion. The field model.diffusivities stores viscosities
and diffusivities that have to be precomputed. For diffusivities prescribed
as constants or functions we don't need to store the diffusivities; instead
the information needed to compute the diffusivity or viscosity is bound to
model.closure.
Perhaps we could call this model property "diffusivity_fields"? This would
distinguish the information there from constant or function diffusivities.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1878 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADEX5KSF44HXRQARFRTAQ6DTYXGJNANCNFSM5AV5LNJQ>
.
|
An additional thought: it might be nice to great an auxiliary_fields object for users and closures alike and put diffusivities there. The issue is closure tuples. For example, god forbid a user wants two LES closures. This might require two diffusivity fields with the same name (eg nu_e). Then this method fails. We could have all closures use unique names, like AnisotropicMinimimDissipation_nu_e. But then I'm wondering if this is much of an improvement to the code, since it adds complexity of its own (and we have plenty of work to do). |
Those are all possible developments. To put fields in When a complicated algorithm endows the code with more features, I feel it could be justified if the feature is good enough. But if its only purpose is to rearrange where array references are bound, it feels less worth the trade off of code maintenance and the work to implement it. Another solution is documentation. Storing constant values in I think of all the changes to Note: I don't this will work for memory parallel models until #1825 is resolved. |
We don't have that many closures that would need this though, right? I think only
I like this option, but keeping the user from creating a closure without a grid seems a bit counter-productive... It's still not clear to me which one I'd vote for. For the time being, should we do something for the problem title refers to? |
I think all the closures we have contain diffusivity data (constants or functions or fields) that are not in The list is here: Only a subset of the code is documented, so better to look to the source when considering refactoring I think. |
What can we do that will preserve the functionality of our closure tuples? For example, we need this code to work: Oceananigans.jl/src/TurbulenceClosures/closure_tuples.jl Lines 14 to 16 in 201b50e
|
I guess the only non-invasive option would be to leave |
Just for the record, @glwagner and I decided to go with this suggestion which is the simplest for the time being. The naming is more intuitive and (with the new name) is makes sense that an empty element is created when a closure doesn't require an auxiliary field. |
I'm assuming the behavior below isn't expected., where
NonhydrostaticModel
creates an element indiffusivities
for each element in a tuple of closures but one of them is empty. What would be the preferred way?Note that the output of the last line is empty. So the second element is there, but it's
nothing
. If I check the model's property closure, I can see both closures though:So this is a bit confusing (at least to me) and I guess it relates to #1381.
Thoughts?
The text was updated successfully, but these errors were encountered: