TAGGED: udf
-
-
March 30, 2021 at 6:58 pm
vedama
SubscriberHello,nI'm relatively new to UDFs. Trying to write a function that returns the length between 2 cells. I'm calculating the centroid of each cell but I also want the length between each set of 2 cells so that I can use it for other operations. Here is a sample of my code:n/*************************************nCentroid UDFn*************************************/#include udf.hnnDEFINE_ON_DEMAND(edgeL)n{ntThread *t;ntcell_t c;ntDomain *d;ntreal edgelength;ntreal xc[ND_ND];ntntd = Get_Domain(1);ntntthread_loop_c(t,d)nt{nttt=Lookup_Thread(d,2);nttbegin_c_loop(c,t)ntt{ntttedgelength=C_CENTROID(xc,c,t) - C_CENTROID(xc,c+1,t);n?ntt}nttend_c_loop(c,t)nt}nnObviously this doesn't work because C_CENTROID(xc,c+1,t) would give me an error, but I hope it gives someone an idea of what I'm trying to do. I would also like to use other similar functions like C_P_G(xc,c+1,t) etc etc. I couldn't find the solution online anywhere and I'm looking for any sort of guidance, please. Thank you in advance.n -
March 30, 2021 at 10:18 pm
YasserSelima
SubscriberHello, first replace the following line to before the loop to avoid having error when running the functionnt=Lookup_Thread(d,2);nnSecond, this loop is performed by many compute nodes ... and every cell has many adjacent cells. So, which adjacent you need? x, y or z in 3D geometry?nThird .. the way to do it is to loop on the faces of the cell. Then compare the face-node coordinates to the centroid coordinates to know this is the right face. Then request the cell on the other side. nI know this is a long procedure and tough. So, I recommend that you approximate this by using the area component of the cell. But if you decided to proceed in finding the centroid of adjacent cell, the macros you need are listed under Cell macros , Face macros and Connectivity macros ... Good luck! and let me know if you need help.n
-
Viewing 1 reply thread
- The topic ‘Fluent UDF successive cells’ is closed to new replies.
Ansys Innovation Space
Trending discussions
Top Contributors
-
3647
-
1313
-
1142
-
1075
-
1013
Top Rated Tags
© 2025 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.