integration over a slice

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
xiaoxue123
Posts: 29
Joined: Fri Mar 02, 2018 11:50 am

integration over a slice

Post by xiaoxue123 »

Dear expert team,

I want to calculate an integration over a slice. I plan to add a variable using "cs_parameters_add_property", then do the integration in cs_user_extra_operations. The version I'm using is 6.0.8.

The definition of the new variable (swirl number) is attached, and the simulation domain is a pipe.
2022-10-31 035039.png
(45.13 KiB) Not downloaded yet
Ux is the streamwise velocity, U_theta is the tangential velocity, which can be calculated based on Uy and Uz. r is the radial distance from the axis. R is the radius of the pipe.

The geometry is using x-y-z coordinates. I need to calculate the swirl number at 3 streamwise locations and need the time monitoring of the 3 swirl numbers.

Do you have any guidance on how to do the integration?

Best regards,
Xiaoxue
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: integration over a slice

Post by Yvan Fournier »

Hello,

Some of the examples in the development branch might help you (https://github.com/code-saturne/code_sa ... rofile.cxx), though they are not quite simple...

Integrating a variable in a given direction or over a slice is always a bit tricky, since we need to project from an unstructured mesh to a structured one at some point. If your mesh is a Cartesian-type mesh, you might be able to integrate fields over single directions by summing values at cells with neighboring cells aligned along the chosen axis, bit you need to do this iteratively, without counting cells twice (for example by setting a cell's value to 0 once you have added it to another cell), and handling parallel partitioning boundaries...

Best regards,

Yvan
xiaoxue123
Posts: 29
Joined: Fri Mar 02, 2018 11:50 am

Re: integration over a slice

Post by xiaoxue123 »

Hi Yvan,

Thanks for the information. The example is indeed not simple.
My geometry is Cartesian-type, the cells are aligned along the axis. The geometry is a pipe and the mesh is extruded along the axis.
To do the integration over a slice perpendicular to the axis, I'll need the surface area of the cell, the coordinate of the cell, and the velocity at the cell.
Do you have simpler examples or suggestions?

Thanks very much,
Xiaoxue
Yvan Fournier
Posts: 4070
Joined: Mon Feb 20, 2012 3:25 pm

Re: integration over a slice

Post by Yvan Fournier »

Hello,

No, I do not have simpler examples. All the information you need can be accessed through mesh, mesh quantities, and field structures, which are documented here: https://www.code-saturne.org/documentat ... _dico.html

But I have no example of combining those in a way that is useful to you. You'll need to loop over cell faces (or loop over faces and add contributions to cells), comparing using face normals with x, y, z directions to determine whether a given face joins 2 cells aligned perpendicular to the axis or not...

Best regards,

Yvan
Post Reply