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: 30
Joined: Thu Oct 25, 2018 12:18 pm

Export the data calculated by extra operations

Post by Mohammad » Tue Oct 15, 2019 1:04 pm

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: 2774
Joined: Mon Feb 20, 2012 3:25 pm

Re: Export the data calculated by extra operations

Post by Yvan Fournier » Tue Oct 15, 2019 1:09 pm

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: 30
Joined: Thu Oct 25, 2018 12:18 pm

Re: Export the data calculated by extra operations

Post by Mohammad » Tue Oct 15, 2019 2:16 pm

So, I should convert my fortran code to C language?

Luciano Garelli
Posts: 222
Joined: Fri Dec 04, 2015 1:42 pm

Re: Export the data calculated by extra operations

Post by Luciano Garelli » Tue Oct 15, 2019 6:42 pm

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: 30
Joined: Thu Oct 25, 2018 12:18 pm

Re: Export the data calculated by extra operations

Post by Mohammad » Wed Oct 16, 2019 5:20 am

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: 222
Joined: Fri Dec 04, 2015 1:42 pm

Re: Export the data calculated by extra operations

Post by Luciano Garelli » Wed Oct 16, 2019 9:18 am

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