Fluids

Fluids

Looping macro for DPM

    • hjubaer
      Subscriber

      Hi all, 


      I am aware that in the customization manual there are some examples of looping macros including one to loop over all particles in a cell. But I was just wondering if there is any way of defining a certain radius around let's say a cell, where the tracked particle is currently located, and then loop over all particles that are located within that defined radius? May be we can identify the cells that fall withing that radius and then extend our looping macro to go over multiple cells, instead of just one?


      So let's say I loop over all the threads and then loop over all the cells in those threads to find C_CENTROID(xc,c,t) and then calculate the distance of those centroids from my cell where the tp is currently residing? Would that be the way to go? I feel, that this would markedly slow down the simulation, as every time step it would have to go through those loops and check all the cells in my domain. Perhaps there is a more elegant way of achieving my objective? I'd really appreciate your input.   


      Thanks a lot for your help in advance. I also apologise if my question was too stupid.


      With best regards
      Hasan

    • DrAmine
      Ansys Employee

      Yes: you need to identify those cells by a just checking if the centroids are within a sphere. What you need is the center of the sphere and the radius.


      If center of the sphere will be different as it corresponds to the center of a cell then all become difficult and I cannot help on that within this open community. But you can imagine you will need two loops: one to loop of the cells, fix center of the sphere and another cell loop within the first one to calculate the distance between the new cells and the reference cell.

    • hjubaer
      Subscriber

      Hi Amine, 


      Thanks a lot for your quick reply. Just to confirm what you suggested, could you please have a look at the following code and let me know whether or not I understood you correctly.


      The problem that I am having now is when I am compiling the UDF it is giving me the error message: "Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the file specified.


      nnE:...libudfwin643ddp_hostlibudf.dll


      Error Object: #f"


      Due to this error I am unable to test the code to see for myself if it is doing the job. And I should mention that if I exclude this UDF the rest of my UDF's are compiling and running absolutely fine. 


      I would rather test the code with DEFINE_ON_DEMAND, however that UDF offers no pointer to the tracked particle. Can you give me an idea how I could perhaps resolve that issue?
      I really appreciate your help!


      Cheers
      Hasan


      TestUDF

    • DrAmine
      Ansys Employee

      Actually that is not our job as ANSYS Staff to debug or even to comment on UDF on this public community. We only provide guidance


      Your UDF looks okay ( In general shape not examined every single detail!!) but you need to debug it (by using Messages for examples) in case it is not behaving as it should.


      You said you are able to compile on the machine. I assume then perhaps you need to copy the UDF into a good directory (no white spaces, no special symbols), start Fluent there and try to compile without reading any case.


       


      My question is now: Why do you require that?

    • hjubaer
      Subscriber

      Dear Amine, 


      I fully understand that you cannot comment much on the UDF. All I wanted for you to just check whether or not I implemented the idea somewhat alright, just as a guidance, what you provided accordingly. Thanks a lot for that. Of course I did not expect you to debug my code. 


      I was able to find the source of the compilation error. There was a single white space somehow smuggled into the file name by mistake, which I was seeing as an underscore. Haha, it's funny how much debugging trouble, time and research something so trivial can cost!


      Anyhow, to answer your question, I am currently working on a project, where I am looking at the neighbouring particles of any tracked particle to find out the likelihood of them colliding into each other, as an alternative to the current collision model. So, you understand now my predicament, why I am concerned as to the speed of execution of the segment? For each single time step if I have to loop through the entire domain, it is going to cost me significant computation time, I suppose. I wish, there was a more elegant way of doing it. Please guide me with some hints, if you have any idea.


      Thanks again for your assistance. 


      With best regards
      Hasan


       

    • Rob
      Ansys Employee

      If you have a look into the theory in Fluent we look for particles in the same cell: not a perfect solution, but this does avoid the looping problem you're seeing. I'd read the Theory Guide to our collision model, and then look at the references: tracking those backwards (and forwards to where they're referenced) should give you some pointers.


      When/if you do come up with a good solution let us know: our Developers may be interested! 

    • DrAmine
      Ansys Employee

      Yes I understand what you want to do. If this is part of master thesis: that would be hard. As PhD our research work you can then try doing that. 


      To get started (other idea) have a look into the customization manual especially to DEFINE_DPM_SPRAY_COLLIDE

    • hjubaer
      Subscriber

      Thank you both for your replies. 


      This is a part of my PhD project and I am actually planning on going with DEFINE_DPM_SPRAY_COLLIDE. In fact I already started working on it. But as @rwoolhou correctly noted that the easiest solution implemented in Fluent of looping only over one cell, where the tp is currently residing, is not necessarily the best solution, my idea was to find an alternative to this first. However, as you both may be able to appreciate how challenging even only this small part is.


      Cheers
      Hasan

    • DrAmine
      Ansys Employee

      Actually I need to correct: for DEM we look within a Cartesian grid and not only in the cell particle is residing.


      What are you missing in the current Fluent DEM framework?

    • hjubaer
      Subscriber

      Hi Amine, 
      I am not using the DEM. The scope of my work is limited to DPM only. It would be a nice discussion to have perhaps in person, but I don't think here in the forum we can discuss in that much detail. 


      Thank you for your help though. And please let me know if you can suggest any way to limit the search of cells. May be this is something the development team could look into. If only they could add another macro to implement a conditional cell loop like begin_c_loop_while(xc,d), xc being the coordinate of the current cell and d being the distance. If this could be done in a more efficient way, this could prove extremely useful...Just an idea


      Cheers
      Hasan


       

    • DrAmine
      Ansys Employee

      You (can contact you ASC who) can contact local account team to think about consultancy or mentoring services.


       

    • hjubaer
      Subscriber

      Hi Amine and @rwoolhou, 


      I have one last question with regard to this thread. Is there any way to loop through all the particles without going into the thread and cell loop? To clarify, I just want to check each particle present in my domain (transient simulation), extract the position and then calculate the distance between my reference point and the particle position. 


      If I implement


      "Particle *p;


      Injection *Ilist, *I;


      Ilist = Get_dpm_injections();


      loop(I, Ilist)


      {


      loop(p,I->p_init) /* Standard ANSYS Fluent Looping Macro to get particle streams in an Injection */


      {/*do the check here*/}


      }


      Would that do that trick? Or does it only loop through the initial streams of an injection?


      Thanks a lot for your reply in advance. 


      Cheers
      Hasan 

    • DrAmine
      Ansys Employee

      The manual mentions how to loop over the particles. you need to get the injections from injection's list and loop over all injections and then loop over all particles from that injection.


      I guess you have that trick from the WorldWideWeb and I guess part of that are from ANSYS. I would not comments on that but I can tell you are on the correct path!

    • hjubaer
      Subscriber

      Hi Amine,


      Thanks again for your reply. I didn't get it from the www, I wrote the code based on the instructions provided in Fluent Customization Manual. Since there is no comparable implementation in any example UDF, I wasn't very sure of its effectiveness.


      The only thing I am very uncertain about is whether this loop covers all the particles in the domain or only those in the initial injection step?


      Cheers
      Hasan

    • DrAmine
      Ansys Employee

      It would loop over particles not only at initial injection step.

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