parallelization issues in the cs_user_extra_operations.c

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
CandiceLIU
Posts: 11
Joined: Thu Mar 02, 2023 5:36 pm

parallelization issues in the cs_user_extra_operations.c

Post by CandiceLIU »

Dear Code_Saturne users,

I am struggling with the parallelization in the cs_user_extra_operations.c. I am using Version 7 and set up the case by SRC.

Firstly, I calculate the shortest distance by using cs_geom_closest_point of each grid cell (domain->mesh_quantities->cell_cen) to the wall surface (domain->mesh_quantities->b_face_cog). Secondly, I try to calculate the difference between the reaction progress variable (boundary_RPV) and dimensionless temperature (boundary_theta) at the boundary surface and then calculate the corresponding value at each grid cell in the whole mesh domain based on the shortest distance away from the wall surface (from step 1) .

Currently, the code run perfectly well in sequence. However, when I run it in parallel and the error jumps as shown in figure.


I am not very skilful in MPI and any suggestions are appreciated. The cs_user_extra_operations.c has been attached.

Best regards
Liyuan
Attachments
cs_user_extra_operations.c
(5.24 KiB) Downloaded 352 times
Screenshot from 2023-12-04 11-24-13.png
Yvan Fournier
Posts: 4080
Joined: Mon Feb 20, 2012 3:25 pm

Re: parallelization issues in the cs_user_extra_operations.c

Post by Yvan Fournier »

Hello,

You code cannot work in parallel: use of cs_geom_closest point is not recommended in general, though it may be useful for some specific cases involving a small number of points.

This function loops on all cells, and involves a parallel reduction for each point. So it must be called exactly the same number of times on each MPI rank. But you selected faces are in general not spread evenly over ranks. Which is why you get a crash.

Since you seem to be looking for cell centers closes to selected face centers, why do you not simply use the cell center of the cell adjacent to these faces (as indicated by domain->mesh-b_face_cells[face_id]) ?

Best regards,

Yvan
Post Reply