CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for searching the closest point to a certain point

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 23, 2015, 23:47
Default UDF for searching the closest point to a certain point
  #1
New Member
 
Join Date: Apr 2015
Posts: 5
Rep Power: 11
princekar is on a distinguished road
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*time-x0,2)+x[1]*x[1]+pow(x[2]-0.0015-h,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?
princekar is offline   Reply With Quote

Old   April 24, 2015, 10:31
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
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.
upeksa is offline   Reply With Quote

Old   April 26, 2015, 05:53
Default
  #3
New Member
 
Join Date: Apr 2015
Posts: 5
Rep Power: 11
princekar is on a distinguished road
Quote:
Originally Posted by upeksa View Post
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.
Thank you very much for your help. These codes are only part of my ADJUST UDF, so some of the variables are not declared here.

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?
princekar is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 00:25.