Conversation
… diffusivity field for sgs stats
|
Looks good to me (the results). What about the normal components, potentially with some model for the trace? |
timofeymukha
left a comment
There was a problem hiding this comment.
Had a quick look. Please check if we can use the scratch_registry in some of these.
The amount of code duplication in the _output types is painful, but for now, I guess it is the only way... Something to think about for us later, though.
So the test case all normal components are almost zero, for example for the first component it's <2nutdudx> and you could have equally distribution for negative and positive dudx for the same nut value in statistics |
Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
timofeymukha
left a comment
There was a problem hiding this comment.
Hi Shiyu,
Some comments about temproraries. There is also a number of issues Codex found, which I think, upon inspection, all have merit. Here comes:
-
High:
scalar_sgs_statscrashes/behaves incorrectly inalphatmode
scalar_sgs_stats_updatealways executesfield_cmult2(this%alphat, this%nut, 1.0_rp / this%pr_turb)even when initialized viainit_alphat, wherethis%nutis never set. That dereferences a null pointer and also overwrites providedalphatdata.
Reference:src/les/scalar_sgs_stats.f90line 188. -
Medium: memory ownership leak in
scalar_sgs_stats_free(nut-based init path)
init_nutallocatesthis%alphat, butfreeonly nullifies it; it never calls%free()anddeallocate. This leaks heap memory if the object is re-initialized/freed multiple times.
References:src/les/scalar_sgs_stats.f90lines 148-149, 223. -
Medium:
stat_fieldsallocations are not released in new SGS stats destructors
Both new stats types allocatethis%stat_fields%items(...)but do not callthis%stat_fields%free()in destructor, unlikefluid_stats_t.
References:src/les/fluid_sgs_stats.f90lines 136, 210-230;src/les/scalar_sgs_stats.f90lines 119, 161, 210-225; comparison:src/fluid/fluid_stats.f90line 659. -
Low: user-guide docs do not match implemented JSON contract for
scalar_sgs_stats
Implementation requires analphatsub-dictionary withnut_dependencyand eitheralphat_fieldor (Pr_t,nut_field), but the parameter table still documents top-levelalphat_field, and default filename text is also wrong (fluid_sgs_statsX*).
References:src/simulation_components/scalar_sgs_stats_simcomp.f90lines 121-128;doc/pages/user-guide/statistics-guide.mdlines 307, 311. -
Low: review-policy/doc quality issues in new/changed Fortran files
- Copyright year inconsistency (new file uses
2025; modifiedcoef.f90still2020-2024despite 2026 edits). - Several new procedures have incomplete/inaccurate Doxygen params (for example scalar simcomp constructor docs mention
u,v,wthough dummies ares,coef,...).
References:src/les/scalar_sgs_stats.f90line 1;src/sem/coef.f90line 1;src/simulation_components/scalar_sgs_stats_simcomp.f90lines 155-163, 211-220.
Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
Co-authored-by: Timofey Mukha <timofey.mukha@protonmail.com>
|
@Shiyu-Sandy-Du , two more comments from the AI, as per latest changes, both correct I think.
|
For its second comment, should we go through the entire neko to correct similar issues? E.g. u v w in fluid_scheme |
If we find something, then yes. But u, v, w in fluid_scheme should be fine, because those pointers just point to fields in the neko_reigstry. One never runs an |
55dcaf1 to
3688165
Compare
This PR adds the statistics for the subgrid-scale contribution for the anisotropic part of Reynolds stresses and scalar fluxes. The validation is performed by an ABL toy simulation with a TKE model for the eddy diffusivity and eddy viscosity, which is down in another un-merged branch. It does not match perfectly with the reference from nek5000, but since the simulation can not even be statistically stationary and the simulations can differ slightly in terms of time step size an other details in the implementation. But the trend still tells that we are getting the correct quantity to do the statistics. The only concern here is the scheme_t is not added into registry so one could only assign both the scalar field name and the corresponding eddy diffusivity field name for scalar sgs stats. Maybe one could add the pointer to the schemes in the registry in a separate PR.


