Page 1 of 1

Problem in Energy Balance example file?

Posted: Tue Oct 29, 2019 7:42 pm
by Mohammad
Hello,

I was checking the cs_user_extra_operations-energy_balance.f90 file and I noticed a problem in that file.

It is using the following code to compute reconstructed value in boundary cells.

Code: Select all

! - Compute reconstructed value in boundary cells
    do ifac = 1, nfabor
      iel = ifabor(ifac)
      treco(ifac) =   cvar_scal(iel)       &
                    + diipb(1,ifac)*grad(1,iel)  &
                    + diipb(2,ifac)*grad(2,iel)  &
                    + diipb(3,ifac)*grad(3,iel)
    enddo
As you know, it calculates treco at each cell on boundary.
The problem is that why it uses treco(ifac) instead of treco(iel)?

The ifac is just a number from 1 to the number of selected faces and it does not specify the cell which the calculated variable belongs to.

But iel is the id of cell that specifies the exact cell which the calculated variable belongs to.

So in post processing, the computed parameters are on wrong cells.

Is there any reason or the written code is incorrect?

Regards,
Mohammad

Re: Problem in Energy Balance example file?

Posted: Wed Oct 30, 2019 11:36 am
by joubanba
Hello,

In this example ifac is the id of the boundary face while iel = ifabor(ifac) is the id of the (unique) neighboring cell of the same boundary face.

Regards,

Jamal

Re: Problem in Energy Balance example file?

Posted: Wed Oct 30, 2019 12:03 pm
by Mohammad
joubanba wrote: Wed Oct 30, 2019 11:36 am Hello,

In this example ifac is the id of the boundary face while iel = ifabor(ifac) is the id of the (unique) neighboring cell of the same boundary face.

Regards,

Jamal
Hello,

Thanks for your reply.

I did the same procedure and I noticed that it only does the calculation on one boundary as you can see in the attached image captured by Paraview:
SC.png
Paraview Results
(8.83 KiB) Not downloaded yet
And here is the code:

Code: Select all

const int n_b_faces = cs_glob_mesh->n_b_faces;
for (cs_lnum_t i = 0; i < n_b_faces; i++) { // Calculation Loop     
  cvar_H_11[i] = 100; 
}
Also, I tried this code ,but the same thing happens:

Code: Select all

  const int n_b_faces = cs_glob_mesh->n_b_faces;
  BFT_MALLOC(face_list, n_b_faces, cs_lnum_t);                                         
  cs_selector_get_b_face_list("1 or 3 or 5 or 6", &n_faces, face_list);
  for (cs_lnum_t i = 0; i < n_faces; i++) { // Calculation Loop     
  face_id = face_list[i];
  cvar_H_11[face_id] = 100; 
}
Regards,
Mohammad

Re: Problem in Energy Balance example file?

Posted: Wed Oct 30, 2019 4:22 pm
by joubanba
Hello,

What do you expect from this code snippet? And more precisely what is this array cvar_H_11 (enthalpy?...)

If cvar_H_11 is a pointer to the cell values of the enthalpy then you have to retrieve the cell_id corresponding to the face_id in your loop on the boundary faces (just as I mentioned in the previous post): ifabor in Fortran and b_face_cells in C language.

Regards,

Jamal

Re: Problem in Energy Balance example file?

Posted: Wed Oct 30, 2019 4:43 pm
by Mohammad
joubanba wrote: Wed Oct 30, 2019 4:22 pm Hello,

What do you expect from this code snippet? And more precisely what is this array cvar_H_11 (enthalpy?...)

If cvar_H_11 is a pointer to the cell values of the enthalpy then you have to retrieve the cell_id corresponding to the face_id in your loop on the boundary faces (just as I mentioned in the previous post): ifabor in Fortran and b_face_cells in C language.

Regards,

Jamal
I appreciate your helps dear Jamal!

I want to calculate shear stress on boundaries. So H will be replaced by Tau.
But first for checking my codes, I gave a constant number.

So, in order to calculate shear stress on boundaries, I have to set the values on neighbour cell instead of boundary face?