
[Sponsors] 
UDF for searching the closest point to a certain point 

LinkBack  Thread Tools  Search this Thread  Display Modes 
April 23, 2015, 22:47 
UDF for searching the closest point to a certain point

#1 
New Member
Join Date: Apr 2015
Posts: 5
Rep Power: 11 
I open VOF model and use parallel solver in my model. Now, I need to find the closet point in the model to a certain point (this point may be virtual and not be involved in the real model).
The parallel solver is used, so the model is divided into several parts (six parts in my model). Using loop macros, I can find each closet point in each part and its corresponding distance. So I get six distance values and six position coordinates. They are stored in their own compute node. I only need to compare the six distance values and find the smallest one. The closest point can be found. However, I always have problems in the data exchange between host and node or between node and node. The FLUENT just crashes. Here is my code: #if !RP_HOST mp_thread_loop_c(t,domain,pt) {Thread *p_phase=pt[1]; begin_c_loop_int(c,t) {C_CENTROID(x,c,t); if(C_VOF(c,p_phase)>0.3&&C_VOF(c,p_phase)<=1&&C_UD MI(c,t,5)>=1500&&x[1]>=0&&x[1]<=0.00011) { d=sqrt(pow(x[0]v*timex0,2)+x[1]*x[1]+pow(x[2]0.0015h,2)); C_UDMI(c,t,31)=d; if(d<=dmin) {dmin=d; center[0]=x[0]; centerx=x[0]; center[1]=x[1]; center[2]=x[2]; } } } end_c_loop_int(c,t) } Message("x=%f\n",centerx); #if RP_NODE Gdmin=PRF_GRLOW1(dmin); Message("dmin=%f\n",dmin); Message("Gdmin=%f\n",Gdmin); #endif #endif #if RP_NODE if(I_AM_NODE_ZERO_P) {if(dmin==Gdmin) PRF_CSEND_REAL(node_host,center,3,myid); else compute_node_loop_not_zero(N) { PRF_CRECV_REAL(N,&dmin,1,N); if(dmin==Gdmin) { PRF_CRECV_REAL(N,center,3,N); PRF_CSEND_REAL(node_host,center,3,myid);} }} #endif else host_to_node_real(center,3); I guess something wrong with the macro such as PRF_CSEND_REAL or PRF_CRECV_REAL. Can someone help me? 

April 24, 2015, 09:31 

#2 
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 12 
I did not checked it, but I can see some mistakes:
line 3: you can not start you code and the declare a variable: First declare all your variables and then, start your code. line 6: you have omitted many parenthesis () in the if statement line 33: you have omitted the {} marks after "else" line 39: I don't know your intention here, but for sure this is wrong. The macros type PRF_CSEND and PRF_CRECV manage data in a buffer. You can not request for data that you haven't sent yet, and you can not send data you will to receive. line 44: Do you mean host_to_node_real_1(center)? Anyway, if I were you, I should not take data to the host, it is not necessary in your case. 

April 26, 2015, 04:53 

#3  
New Member
Join Date: Apr 2015
Posts: 5
Rep Power: 11 
Quote:
As I mentioned above, I need to find the closet point to a certain point. I can get six distance values and six corresponding position coordinates now, hence I can get the real closet point position through comparing the distance values. I need this position coordinate in the following SOURCE function (not shown here), so I need to pass the position coordinate to the other node. It must though the node host. I have more questions about this UDF. That do you mean about "The macros type PRF_CSEND and PRF_CRECV manage data in a buffer"? Can you give more detailed explanation? How can I pass a variable (may be an array) in a node to the other node? 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF parallel error: chipexec: function not found?????  shankara.2  Fluent UDF and Scheme Programming  1  January 16, 2012 22:14 
Various errors: Floating point, UDF compiling, etc  SEMC  FLUENT  1  September 6, 2011 09:08 
Passing point data to UDF using C_UDMI  Sam Bennett  FLUENT  6  December 1, 2005 08:46 
udf to output velocity at some point  Jun  FLUENT  4  August 19, 2003 13:43 
CFX4.3 build analysis form  Chie Min  CFX  5  July 12, 2001 23:19 