Computing moments of gradient

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
C.FLAG.
Posts: 34
Joined: Fri Apr 08, 2016 2:19 pm

Computing moments of gradient

Post by C.FLAG. »

Dear users, developpers,

I am trying to compute the moments (mean and variance) of the velocity gradient. Following the examples, in cs_user_time_moments, I am using cs_time_moment_define_by_func to use a function which compute the velocity gradient.

But there is a problem : the gradient is defined on the (real+ghost) cells while the moments are only defined on the real cells. Is it possible to remove the ghost values from the field? Or to compute the gradient only on the real cells?

I am running version 4.0.4 (with fixed cs_time_moment.c). Attached is the corresponding file cs_user_parameters.c

Best regards,
Cedric
Attachments
cs_user_parameters.c
(14.91 KiB) Downloaded 244 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Computing moments of gradient

Post by Yvan Fournier »

Hello,

You code seems "almost correct": when copying results from the gradient (shape [n_cells_with_ghosts][3][3]) to the results (shape [n_cells][3][3], you outer loop (on cell_id) should simply be on n_cells and not n_cells_with_ghosts.

Note also that you can create special "variance" user variables for variances (such as the one on velocity) which are solved in a "turbulence" sense, which might be useful for you (I can explain the time moments, but for turbulent variances, the theory documentation or Sofiane can explain them better than me).

Regards,

Yvan
C.FLAG.
Posts: 34
Joined: Fri Apr 08, 2016 2:19 pm

Re: Computing moments of gradient

Post by C.FLAG. »

Dear Yvan,

Your solution seems to work like a charm. And while waiting for converged results, I will look at the theory documentation, see if i can build something more optimized.

Thank you for your help,
Best regards,
Cedric
Post Reply