Export the data calculated by extra operations

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Export the data calculated by extra operations

Post by Mohammad »

Hi,
I wrote some codes in cs_user_extra_operations.f90 file which calculates strain rate tensor and also shear stress tensor at each point and each time step.

Now, I want to export this data in the template and format of the exported data files in RESU/... folder (for example: results.velocity.0001 file)

How can I do this?
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: Export the data calculated by extra operations

Post by Yvan Fournier »

Hello,

In this case, you need to move your code from cs_user_extra_operations to cs_user_postprocess_values (in cs_user_postprocess.c) so as tou output this to a reguar "writer" (EnSight in your example).

Regards,

Yvan
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Export the data calculated by extra operations

Post by Mohammad »

So, I should convert my fortran code to C language?
Luciano Garelli
Posts: 280
Joined: Fri Dec 04, 2015 1:42 pm

Re: Export the data calculated by extra operations

Post by Luciano Garelli »

Hello,

You can call the fortran subrutine in a C function doing some BIND(C) to be compatible with C.

May be this link could help you.
https://gcc.gnu.org/onlinedocs/gfortran ... tions.html

Maybe you can check in the post.f90 file the subrutine cs_f_post_write_var, which is then used in cs_post.c

Regards,
Luciano
Mohammad
Posts: 114
Joined: Thu Oct 25, 2018 12:18 pm

Re: Export the data calculated by extra operations

Post by Mohammad »

Thank you.
If I want to use cs_user_postprocess.c and write the code in C language, can I use and call the variables which I defined in Fortran files like cs_user_modules.f90 and cs_user_initilization.f90 or I have to use the C file type of them?
Luciano Garelli
Posts: 280
Joined: Fri Dec 04, 2015 1:42 pm

Re: Export the data calculated by extra operations

Post by Luciano Garelli »

Hello,

I think that the answer is yes (I'm not totally sure because I never have done), but if you have created a new variable (scalar, vector, etc) and you store some data, then you can access from both, fortran or C.

Maybe someone from the development team could answer more precisely to your question.

Take a look at this link, maybe could help
https://www.code-saturne.org/cms/sites/ ... field.html

Regards,
Luciano
Post Reply