Page 1 of 1

integration over a slice

Posted: Mon Oct 31, 2022 5:04 am
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

Re: integration over a slice

Posted: Mon Oct 31, 2022 3:25 pm
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

Re: integration over a slice

Posted: Wed Nov 02, 2022 2:03 am
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

Re: integration over a slice

Posted: Mon Nov 07, 2022 1:07 am
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