Page 1 of 1

Export the data calculated by extra operations

Posted: Tue Oct 15, 2019 1:04 pm
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?

Re: Export the data calculated by extra operations

Posted: Tue Oct 15, 2019 1:09 pm
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

Re: Export the data calculated by extra operations

Posted: Tue Oct 15, 2019 2:16 pm
by Mohammad
So, I should convert my fortran code to C language?

Re: Export the data calculated by extra operations

Posted: Tue Oct 15, 2019 6:42 pm
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

Re: Export the data calculated by extra operations

Posted: Wed Oct 16, 2019 5:20 am
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?

Re: Export the data calculated by extra operations

Posted: Wed Oct 16, 2019 9:18 am
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