Fluids

Fluids

UDF Parallelization

    • satri
      Subscriber

      How do i know what UDFs can be parallelized and why? I read the documentation and it does not tell me what udfs need to be parallelized.

      I have the following udfs-

      DefineAdjust,

      DPM_Scalar_update

      Define_profile

      Define_source
       
      I look at some general parallel computing textbooks, and i cannot find any clear equivalency with ansys. What am i missing here?
      how can i achieve parallelization of UDFs?
      what do i need to read and understand please let me know.
      (What should I read to understand more about the parallelization of Ansys UDFs)
      These are the books i looked up. (Did I miss anything in these books? can anyone of you please suggest any reading that I need to do to get more insight into this? Parallelization process)
      Book1- Designing and Building Parallel Programs by Ian Foster
      Book2- Parallel Computer Architecture: A Hardware/Software Approach by David Culler et al., Morgan Kaufmann Publishers
      Book3- An Introduction to Parallel Computing: Design and Analysis of Algorithms (Ed. 2, Jan 2003) by Ananth Grama et al., Pearson Addison Wesley.
      Book4-The Sourcebook of Parallel Computing, Edited by Jack Dongarra, Ian Foster, Geoffrey Fox, William Gropp, Ken Kennedy, Linda Torczon, Andy White, October 2002, 760 pages, ISBN 1-55860-871-0, Morgan Kaufmann Publishers.
       
      (are there any examples of parallelizing adjust, a scalar update on ansys examples? )
    • Rob
      Ansys Employee

      It's not so much the main DEFINE sections that determine whether you need to parallelise the UDF but the loops and calls from within the code  https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v221/en/flu_udf/flu_udf_sec_using_udfs_parallel.html    It's generally a good idea to test UDFs on a simple system, and you can try running 1, 2 and 4 cores to see whether anything behaves differently when writing your code. 

    • satri
      Subscriber

      I have a very simple model.  I have seen that. you are referring to chapter 7 of the fluent udf manual. Are there any examples showing different features of parallelizing udf code, because everything there in the manual is the theory I don't see any example model in that manual (section 7.3.5 has one parallel udf example but i don't know where to find the model case file for that). Please let me know where i can find some examples in the manual.

      Also if i am looking at any general parallel computing textbook what should i look for? to get some examples of what is going on in Ansys parallel. Can you please suggest any reference textbooks that will help me understand this? Because i am really lost. Is there any general textbook other than the documentation?

    • Rob
      Ansys Employee

      You don't need to worry too much about how Fluent does the parallel part, just that your code will call the correct bits when in parallel: look for the RP_NODE and RP_HOST calls for examples.  

    • satri
      Subscriber

      I understand fluent does this in the background. But i want to know more about RP_NODE and RP_HOST i cannot find these commands anywhere in any general parallel programming textbooks.

      As far as examples go how can i look for a specific command RP_HOST in a specific model example?

      I see this on documentation but i cant find its corresponding case file to understand what is going on here 

      where can i find a case file for this

      Example: Global Summation of Pressure on a Face Zone and its Area Average Computation?

    • Rob
      Ansys Employee

      There isn't a case file, the UDF examples are for you to add to your own models. Similarly, RP_HOST & RP_NODE are used in Fluent UDFs, so may be specific to Fluent. 

    • satri
      Subscriber

      Ohh that is really sad to hear.

      So what model is this udf written for if i have to do it myself? say I am a simple cylinder with free stream flow on it and if i compute area average of pressure on the cylinder wall with this udf and if i print put from the reports it should be the same?

      I am trying to understand what is this udf written for.

      Please let me know what exactly is the purpose of the udf (Example: Global Summation of Pressure on a Face Zone and its Area Average Computation) what kind of model will this work on, will this work on the model as mentioned above?

    • Rob
      Ansys Employee

      Bottom of the page here,  https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v222/en/flu_udf/flu_udf_sec_using_udfs_parallel.html    The purpose of the example is to show how and where you need to call HOST and NODE values. 

      If you just want the average pressure in your model use a Surface Integral: UDFs are not always simple and are generally specific to the required task. 

    • satri
      Subscriber

      I understand that. Let me rephrase my question. Maybe asking about define adjust was too early at the moment.

      Let me start with something even more basic

      When i read the documentation this is what i see. We will have to parallelize the UDF when i encounter these situations

       

      Now i have a UDF called scalar-update that deposits some number of particles in a cell zone. This is what i get when i do volume integral sum for serial case

      This is what i get for the parallel case when i do volume integral of sum

      you can see that both the answers are not equal

      Now as far as my UDF goes I am looping over cell volume to deposit the mass in zone called part-filter.

      Q1) Do i need to parallelize anything in this udf? this is the condition i have

      if the particle thread(t) matches the cell zone thread(tm) increase udm-5.

      Q2) If not then do i have to write an execute on demand to loop over the nodes of different nodes and sum up the udm-5 because the volume integral displayed on the console is wrong?

      I am not sure where to begin. Please let me know.

    • Rob
      Ansys Employee

      If you have a filter won't you deposit scalar (or UDM) based on the particles? 

    • satri
      Subscriber

      Yes its based on the particles as the particles enter the filter thread it gets deposited on the filter depending on the conditions imposed.

      If(t==tm) {}

      This is the entry point of the particles now. my confusion is should i parallelise this. put

      #if RP_HOST

      if (t==tm){}

      #endif /* RP_HOST */

      please let me know. I am not able to find equivalent examples to make try this. and am not able to logically reason out what are scenarios that need to be parallelized and why.

    • Rob
      Ansys Employee

      You might want to start here https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v222/en/flu_udf/flu_udf_DPMDEFINE.html%23flu_udf_sec_define_dpm_erosion   The particle is the cause of the source/blockage which is then mapped onto the UDM. 

    • satri
      Subscriber

      No. The scalar update udf i have is working perfectly fine. The results from UDF match with all theoretical results, the only problem is it's extremely slow and i want to speed it up. that's why i am trying to parallelize. the erosion example does not help my cause. Is there any example like this that shows how parallelizing of UDF is done?

      If not for the manual is there any other reference book maybe a textbook or something that explains how the udf's can be parallelized?

    • Rob
      Ansys Employee

      Just the manuals, have you checked that UDM 5 is different because of the result (ie flow/particles) or parallel? 

    • satri
      Subscriber

      it's just the result of the volume integral of UDM5. The result that i have got in the serial case is the expected result when i use analytical equations to calculate the mass deposited it exactly matches the result from serial case. The only change that i did in the parallel case is increase the number of processor from 1 to 4. to see if my mass deposited matches. turns out it does not. 

      The reason is that the UDF needs to be parallelized.

      When i start looking at what UDFs need to be parallelized the first question i encounter is- do i need to parallelize the scalar update udf? that leads me to my question where should i put # if RP_HOST? in scalar update UDF

    • Rob
      Ansys Employee

      That will depend on what you're doing to the scalar in the UDF. 

    • satri
      Subscriber

      in simple terms, let's say I inject particles as soon as it enters the filter domain 50% gets deposited in the first cell and 25% gets deposited in the cell inside it and 12.5% in the next cell and 6.25% of particle mass in next cell inside and the remaining 6.25% of mass just gets penetrated and goes out. (To have a simplified view for understanding purposes, i am hypothetically describing it in extremely simple terms)

      Let us assume this happens across the volume.

      Once i finish deposition i compute the volume integral of the sum of the total mass in filter domain. So do i need to parallelize this scalar update?

    • Rob
      Ansys Employee

      Probably not, but that'll depend on how you're handling the particle termination & scalar updates. 

    • satri
      Subscriber

       

      Well, i don’t understand how. So do you mean to say that i don't need to parallelize this UDF?

      Particle termination happens when the mass deposited is less than 0.00005*massInjected.

      And as far as the scalar update goes this is how i update the mass deposited C_UDMI(c,t,Mass_Dep)+=(InjectedMass-PenetratedMass). 

      PenetratedMass = InjectedMass*Efficiency

      that still does not explain the difference in volume integral.

       

    • Rob
      Ansys Employee

      OK, so parcel hits a cell and loses some mass, more in the next cell etc.  That is added to the cell UDM, so isn't a scalar as that will diffuse. Parcel is terminated at some fraction of the initial parcel mass, or of total injected mass? 

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