No values on boundaries for post-processing

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

No values on boundaries for post-processing

Post by Mohammad » Thu Jul 30, 2020 3:41 pm

Hello,

I use Tecplot for post-processing my CFD simulations.

When I load the results generated by Code_Saturne to Tecplot, there are no values available for velocity, pressure and Reynolds stresses on the boundaries and only mpi_rank_id and yplus are available.
I think It's because of the concept of the Finite Volume where calculations occur at the cell centers not nodes. But this issue does not occur in Results generated by Fluent.

Is there any way to have the values of the velocity, pressure and Reynolds stresses on the boundaries? I need them for calculating the lift and drag (shear stress) on a 3D wing. And also some turbulence parameters on other boundaries.
I also checked the results in Paraview and the same thing happens.

I mean something like the below image which is generated by Paraview from the results of OpenFoam.
Please keep in mind that I don't have access to GUI.

Image

Thank you in advance for your great support which is one of the best that I've seen for free and open-source softwares.

Best Regards,

Mohammad

Yvan Fournier
Posts: 3025
Joined: Mon Feb 20, 2012 3:25 pm

Re: No values on boundaries for post-processing

Post by Yvan Fournier » Thu Jul 30, 2020 11:16 pm

Hello,

I do not understand why you do not have access to the GUI. If you are running on a cluster on which it is not installed, you can generate you setup on another machine such as a workstation and copy it to the cluster (keeping the btach script from the cluster)

reconstructing values at boundaries may be done for scalars, but is not yet available for Velocity, pressure, and turbulence variables. For scalars, you can call

Code: Select all

cs_parameters_add_boundary_values(f)
in cs_user_parameters (see examples).
There is also an option in field poistprocesing settings to compute non-reconstructed boundary values, but they are not exactly consistent with those from the actual computation in case of non-orthogonal meshes.

For pressure and shear stress, there is a specific boundary field, named "boundary_forces" which can be activated eithet with user subroutines (but you need to check for examples, I do not remember how), or simply with the GUI.

Regards,

Yvan

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

Re: No values on boundaries for post-processing

Post by Mohammad » Fri Jul 31, 2020 9:30 am

Hello Mr. Yvan and thank you.

You're right indeed. I can create the XML file of the case in workstation and then run it on cluster, but I was afraid that it might lead to conflict with my custom user functions and boundary conditions and forces because I have a lot of custom user functions, non-standard and unusual boundary conditions and body forces which are not available in the GUI, but if it is confirmed that it wont lead to conflict, I will use that.
By the way I installed CS 6.0.4 on my PC to check this issue.

I can see normal and tangential stresses on Surface Solution Control in GUI. But I can't find boundary_forces or any thing related to pressure forces in the GUI.
However, as you know, in turbulence, we must take time average from the results and instantaneous results are not reliable for calculating the statistics. I think these options that you mentioned (boundary_forces like pressure and shear forces) which are predefined in CS, are calculated only at the last time step and are not averaged in time. Am I right? If yes, can we average them?

I should thank you again for your consideration.

Regards,

Mohammad

Yvan Fournier
Posts: 3025
Joined: Mon Feb 20, 2012 3:25 pm

Re: No values on boundaries for post-processing

Post by Yvan Fournier » Fri Jul 31, 2020 4:09 pm

Hello,

Yes, since the forces are saved as a field, you can use the standard cs_time_moments features to average ovr time.

Best regards,

Yvan

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

Re: No values on boundaries for post-processing

Post by Mohammad » Sun Aug 02, 2020 1:14 pm

Hello,

Thanks for the reply.

As I mentioned before, there is no option related to "boundary_forces" in GUI and nothing more than an example file with the name: cs_user_extra_operations-boundary_forces.c which seems to calculate the total force on boundaries. But I checked the source codes and noticed that enabling the calculation of stresses on boundaries or enabling ALE, will create a field named "boundary_forces" (you can check this in src/base/addfld.f90). So I enabled the calculation of stresses on boundaries via GUI and tried to take the average over time in cs_user_parameters-time_moments.c file with the following codes:

Code: Select all

    int n_fields = 1;
    int moment_f_id[] = {cs_field_by_name("boundary_forces")};
    int moment_c_id[] = {-1}; // -1 means all components of field                          
    cs_time_moment_define_by_field_ids("BF_MEAN",
                                       n_fields,
                                       moment_f_id,
                                       moment_c_id,
                                       CS_TIME_MOMENT_MEAN,
                                       start_nt, /* nt_start */
                                       -1,   /* t_start */
                                       CS_TIME_MOMENT_RESTART_AUTO,
                                       NULL);
  }
After running the code these errors occur:
cs_field.c:2312: Fatal error.

Field with id 809657648 is not defined.

Call stack:
1: 0x7fa08460c1f6 <cs_field_by_id+0x56> (libsaturne-6.0\
.so)
2: 0x7fa084684113 <cs_time_moment_define_by_field_ids+0x163> (libs\
aturne-6.0.so)
3: 0x5614c0168ba2 <cs_user_time_moments+0x1f2> (cs_solver)
4: 0x7fa0846c13e4 <initi1_+0xed> (libsaturne-6.0\
.so)
5: 0x7fa085cc35e2 <cs_run+0x4e2> (libcs_solver-6\
.0.so)
6: 0x7fa085cc2fb8 <main+0x178> (libcs_solver-6\
.0.so)
7: 0x7fa0836abb97 <__libc_start_main+0xe7> (libc.so.6)
8: 0x5614c01680ba <_start+0x2a> (cs_solver)
End of stack
Can you help me with that?

Best regards,

Mohammad

Yvan Fournier
Posts: 3025
Joined: Mon Feb 20, 2012 3:25 pm

Re: No values on boundaries for post-processing

Post by Yvan Fournier » Sun Aug 02, 2020 10:23 pm

Hello,

You are almost there, but in your code, you use
int moment_f_id[] = {cs_field_by_name("boundary_forces")};
while cs_fiel_by_name returns a pointer to a field, not its id.

So you should replace that line with:
int moment_f_id[] = {cs_field_by_name("boundary_forces")->id};
Regards,

Yvan

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

Re: No values on boundaries for post-processing

Post by Mohammad » Tue Aug 04, 2020 10:10 am

Hello,

Thank you very much Mr. Fournier.

Your solution worked! But in CS 5.0.4 the function's output was the field ID and it seems that it is modified in CS 6.0.4.

Just two more question:
1- Does the forces given by the "boundary_forces" field are in X and Y directions or in the tangential and normal directions to the boundary?

2- As you may know there are homogeneous directions in the turbulent flows and we take averages along directions in order to calculate the statistics (suppose Z direction is the homogeneous direction).
Is there a function or a way in Code_Saturne to take average along the homogeneous direction or we should use post-processing tools?

Thank you again,

Mohammad

Yvan Fournier
Posts: 3025
Joined: Mon Feb 20, 2012 3:25 pm

Re: No values on boundaries for post-processing

Post by Yvan Fournier » Tue Aug 04, 2020 10:42 am

Hello,

1) the forces are given in regular Cartesian coordinates, not global coordinates. There is an option (easier with the GUI) to compute only the tangential forces (removing the normal component), but they are still in global Cartesion coordinates.

2) local directions are used internally by turbulent wall law models and in some Lagrangian wall models, but besides computing related quantities such as Y+, T+,T*, but besides these basic fields, they are not directly available, so either using some external tools, or doing more advanced computation/filtering in cs_user_extra_operations may be necessary.

Best regards,

Yvan

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

Re: No values on boundaries for post-processing

Post by Mohammad » Wed Aug 05, 2020 9:15 pm

Hello,

Thank you very much Yvan!

Regards,

Mohammad

Post Reply