Dear Code_Saturne community,
I am a new user of Code_Saturne and I am trying to adapt the cs_user_extra_operation_extract_1d_profile.f90 subroutine on Code_Saturne 5.0.8 in order to make it extract 2D profiles.
The idea is to do a slice, and then compute the average pressure for this slice.
In the attached subroutine, I am extracting a 2D profile at x=0.23 for instance, with 50*50 points for a 0.3*0.3 square-channel.
However, I don't know how to have access to the surface intersection of a given 3D cells and my 2D plan, I order to weight the pressure for each cell with its surface. I have tried, by curiosity, to weight it with the volume of the cells, but of course the average pressure computed was then different as the one computed with ParaView using the "slice+integrate variable" filters. I was also wondering if there were a way to extract this 2D profile without indicating the number of points wanted, as it is done with the slice filter of ParaView for instance ?
What's more, is there a way to adapt this subroutine to use it for the inlet and outlet ? since they are boundary conditions, I think that I have to interpolate first the pressure, is that right ?
Thank you in advance for your help and don't hesitate if you need any clarifications,
Regards,
Robin D.
Postprocessing - 2D profile
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
Postprocessing - 2D profile
- Attachments
-
- cs_user_extra_operations-extract_1d_profile.f90
- (6.45 KiB) Downloaded 214 times
-
- Posts: 4251
- Joined: Mon Feb 20, 2012 3:25 pm
Re: Postprocessing - 2D profile
Hello,
The examples using "findpt" only locate the cell center closest to the points you define, and leave you to do an interpolation (such as cell_center value + gradient.(probe_point-cell_center)).
The C examples (in cs_user_postprocess.c or cs_user_postprocess-profiles.c) also contain a variant with a line-sgement intersection, which does a "true" intersection with cells and so allows automatically obtaining the correct number of points (in 1D; would be more tricky in 2D) but does not add interpolation either, so you would need to add the gradient correction.
Note that ParaView does not ensure the interpolation is consistent with that of Code_Saturne, though its simple, unweighted interpolation is OK for most uses.
Which quantities do you want to plot ? For boundaries, you can activate boundary fields (consistent with boundary conditions) for scalars, but not (yet) for velocity or turbulence quantities.
It all depends whether you want mostly graphical output (in which case ParaView is a good option and the Catalyst variant would allow you to generate ParaView output directly from the computation), or more "quantititive" outputs, in which case the "balance" type functions may also be of interest.
For 2D probe/profile type plots, the functions used in cs_user_postprocess-profiles.c could be adapted, but this would require minor changes in src/base/cs_probe.c and src/fvm/fvm_to_plot.c. Do not hesitate to request those on the bugtracker (at least for the "2D part"; interpolation can be more tricky) at https://github.com/code-saturne/code_saturne/issues so that the request is not lost in forum posts history.
Best regards,
Yvan
The examples using "findpt" only locate the cell center closest to the points you define, and leave you to do an interpolation (such as cell_center value + gradient.(probe_point-cell_center)).
The C examples (in cs_user_postprocess.c or cs_user_postprocess-profiles.c) also contain a variant with a line-sgement intersection, which does a "true" intersection with cells and so allows automatically obtaining the correct number of points (in 1D; would be more tricky in 2D) but does not add interpolation either, so you would need to add the gradient correction.
Note that ParaView does not ensure the interpolation is consistent with that of Code_Saturne, though its simple, unweighted interpolation is OK for most uses.
Which quantities do you want to plot ? For boundaries, you can activate boundary fields (consistent with boundary conditions) for scalars, but not (yet) for velocity or turbulence quantities.
It all depends whether you want mostly graphical output (in which case ParaView is a good option and the Catalyst variant would allow you to generate ParaView output directly from the computation), or more "quantititive" outputs, in which case the "balance" type functions may also be of interest.
For 2D probe/profile type plots, the functions used in cs_user_postprocess-profiles.c could be adapted, but this would require minor changes in src/base/cs_probe.c and src/fvm/fvm_to_plot.c. Do not hesitate to request those on the bugtracker (at least for the "2D part"; interpolation can be more tricky) at https://github.com/code-saturne/code_saturne/issues so that the request is not lost in forum posts history.
Best regards,
Yvan