Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Remove parcels at defined cell zone

    • Holzmann
      Subscriber

      Hey everybody,

      I am working on H2O2-H2O vaporization using the latest Fluent version However, as I am almost at the relative saturation of H2O, the parcels are not evaporating anymore (everything is fine here). However, the system gets filled with parcels and I want to remove them, e.g., at a defined location in the mesh (e.g., @a cell zone). Is something like that possible?

      --> If parcel -> cell zone -> escape.

      Any ideas? An internal patch might work as well.

      Thanks,

      Tobi

    • Holzmann
      Subscriber
      Hey everybody, I found the solution:
      However, the only non-dynamic thing is that I have the cell-zone-id hard-coded. Is there a way to set it via TUI ?

      DEFINE_DPM_SCALAR_UPDATE(parcelRemoval, c, t, initialize, tp)
      {
      if (initialize)
      {
      // Fluid domain
      Domain *domain = Get_Domain(1);

      // Cell zone id
      int Cell_Zone_ID = 598;

      cell_t cCZ;
      Thread *tCZ = Lookup_Thread(domain, Cell_Zone_ID);

      // Looping over all cells of the cell zone
      begin_c_loop(cCZ, tCZ)
      {
      // Check if cCZ == c -> parcel inside
      if (cCZ == c)
      {
      MARK_TP(tp, P_FL_REMOVED);
      }
      }
      end_c_loop(cCZ, tCZ)
      }
      }

    • Rob
      Forum Moderator
      The other option is to add an interior surface when you build the model, with some careful use of the porous jump boundary condition you can remove particles as they hit the surface.
    • Amine Ben Hadj Ali
      Ansys Employee
      I guess that was posted elsewhere. You can change the cell zone ID to anything else or make it case dependent. You can get it the Thread of cells of particular cell zone using the macro Lookup_Thread or you use the conditional if (THREAD_ID(t)==yourID ) {
      do something
      }
    • Amine Ben Hadj Ali
      Ansys Employee
      However I will rather cell the thread id of the cell the particle is currently in and then terminate its trajectory.
    • Holzmann
      Subscriber
      Hey both, thank you for your hints. I did the following for making the cell-zone-id dynamic:
      Inside the UDF I have a global variable at the beginning of the source file (int cellZoneId = -1)
      I created a new DEFINE_ON_DEMAND function to set the cell zone id
      ===================================================================================
      // Function to set the cell zone id for the removal UDF
      DEFINE_ON_DEMAND(setCellZoneIdForParcelRemoval)
      {
      // Set the cell-zone-id (only called for host and not nodes)
      #if !RP_NODE
      if (RP_Variable_Exists_P("cell_zone_id_remove_parcels"))
      {
      cellZoneId = RP_Get_Integer("cell_zone_id_remove_parcels");
      }

      // TODO check if cell zone exists

      Message("cellZoneId is set to >> %i\n", cellZoneId);
      #endif

      // Communicate the id to the nodes
      host_to_node_int_1(cellZoneId);

      // Check for the nodes
      // Message("DEBUG: Cell_Zone_ID on nodes-> %d\n", cellZoneId);
      }
      ===================================================================================
      After loading the UDF, I am creating a new variable using the TUI command:
      (make-new-rpvar 'cell_zone_id_remove_parcels 'integer #f)
      The above code checks if the variable exists and take the ID of the guy. At the end, I redistribute it to the nodes.

      However, I found some strange behavior in the code. The removal works as expected but I also get some crazy removal stuff (check out the picture):
      At the cell zone (below the drawed plane) all cells get removed (as expected)


      For any reason, I also remove some (non understandable) parcels somewhere else:

      So something has to be wrong in my code. I have no idea what happens here. Any idea?
    • Holzmann
      Subscriber
      Okay, ... using your approach (which is much nicer) it works out perfectly:
      =======================================================================
      if (THREAD_ID(t) == cell_zone_id)
      {
      // Do my stuff
      }
      =======================================================================
      So anything is wrong with that code of piece:
      =======================================================================
      cell_t cCZ;
      Thread *tCZ = Lookup_Thread(domain, Cell_Zone_ID);

      // Looping over all cells of the cell zone
      begin_c_loop(cCZ, tCZ)
      { }
      end_c_loop(cCZ, tCZ)
      =======================================================================

      However, works now perfectly and nicely
    • Amine Ben Hadj Ali
      Ansys Employee
      As expected :)
    • Holzmann
      Subscriber
      And why :)
      What was wrong with the old guy?
    • Amine Ben Hadj Ali
      Ansys Employee
      I did not look into the old guy as you did not post it in complete. Now related to "As expected": because I am using similar approach to remove particles once certain condition is fulfilled or when they fly through a certain zone and some other condition is true.
    • Holzmann
      Subscriber
      Well, the previous approach is given in my second post. However, here it is again:
      Getting the fluid domain
      extracting the Thread of the cell zone
      Looping over all cell zone cells (probably here I do have the mistake)
      Nevertheless, I am fine with your way and it is way less computational expensive.

      // Fluid domain
      Domain *domain = Get_Domain(1);

      // Cell zone id
      int Cell_Zone_ID = 598;

      cell_t cCZ;
      Thread *tCZ = Lookup_Thread(domain, Cell_Zone_ID);

      // Looping over all cells of the cell zone
      begin_c_loop(cCZ, tCZ)
      {
      // Check if cCZ == c -> parcel inside
      if (cCZ == c)
      {
      MARK_TP(tp, P_FL_REMOVED);
      }
      }
      end_c_loop(cCZ, tCZ)
Viewing 10 reply threads
  • The topic ‘Remove parcels at defined cell zone’ is closed to new replies.