Fluids

Fluids

Looping pattern over cells in FLUENT UDFs

Tagged: 

    • Dubey92
      Subscriber

      I just have a simple 2D domain consisting of uniform hexahedral cells as shown in the attached image. I want to know the looping pattern in which looping over the cells happens. I have a total of 11232 cells. As I have understood, the cell index c is a number assigned to the cells and therefore there should be a total of 11232 values for c. Is there a way to know how begin_c_loop and end_c_loop works over the domain and in what order the looping over the cells works? I want to loop over the cells in a particular direction(say y, along each column). Can someone please help? Thanks in advance.

    • Rob
      Ansys Employee

      I'm not sure you can loop over in order, the cell loops are defined in the UDF Manual, so I'd start there. 

    • eric1234598765
      Subscriber

      Hi, 

      It seems that you are trying to loop something "directionally"

      I've never done that before, but include the concept of coordinate (such as node coordiante or cell centroid) may work.

      You can refrer to chapter 3.2 in UDF manual for more info of access node or cell coordinate data.

    • Dubey92
      Subscriber

      Thanks Eric! Yes, I want to loop directionally(along y direction). I will see what you have suggested.

    • eric1234598765
      Subscriber

      Hi, 

      The dumbness way to do that is writing a for loop , such as

      for( i=0; i++; i< num)

      where "i" is the varible that increase in x direction in your picture , and num is your total numbers of cells on the edge in x direction. This could be a hard work since you need to get all of the cell's coordinates first, which may use more than one c_loop to do that.

      Best,

    • Dubey92
      Subscriber

      Thanks Eric for your reply. I can easily get the coordinates of the centres of the cells as my mesh is uniform and try your method. The only issue I am facing and I am doubtful about is the use of begin_c_loop and end_c_loop. As I have understood, begin_c_loop loops over each cell one by one and I could not find the order in which it loops over the cells. The image beloq shows what I am trying to achieve. It can be done using a for loop but I am unable to implement it.

    • shitizsehgal
      Subscriber

      You can use the if condition in the begin_c_loop such that the if condition targets the particular cells using a physical quantity such as density etc. I use this for VOF simulations. Hope this helps.

    • DrAmine
      Ansys Employee

      Contditional statemetns inside Fluent legacy cell loops.

Viewing 7 reply threads
  • You must be logged in to reply to this topic.