-
-
March 21, 2021 at 6:52 pm
atulsingh92
SubscriberHello, nI have a UDF printing out results of few function calls.nThis when run with the serial configuration, still prints twice than what is requested in the funciton, with once in nan, while with the answer the second time.nAnd when is run with parallel configuration, there are number of cores+1 times the printing of Message command's output.nFor instance the function would look something like thisndouble calulateReynolds(Domain *domain , int id)n{n cell_t c;n Thread *t;n int cells = 0;n face_t f;n t = Lookup_Thread(domain, id);n n double vmag=0.0, vmag_total , rho, mu, reynolds;n begin_c_loop(c,t)n {n uc = C_U(c,t);n vc = C_V(c,t);n wc = C_W(c,t); n rho = C_R(c,t);n mu = C_MU_T(c,t);n vmag += sqrt(pow(uc,2) + pow(vc,2) + pow(wc,2));n cells += 1;n /Message(Velocity is %g, vmag);n }n end_c_loop(c,t)n n # if RP_NODEn vmag = PRF_GRSUM1(vmag);n # endifn n node_to_host_real_1(vmag);n n double avgv = vmag/cells;nn reynolds = rho * avgv * Dia / mu ;nn return reynolds;ncalled as and printed as followsnreynolds_obtained2 = calulateReynolds(domain, 7);nnMessage(reynolds obtained is: %g, reynolds_obtained2);nnSerial result will be asnreynolds obtained is: -nan(ind)nnreynolds obtained is: 29934.524nwhile parallel result would be the above and rest of print (Message) statements with -nan(ind) values, 7 times while sometimes with the actual required values.nIs there a way I could correct this?nMy guess was to use the node_to_host_real_1(variable) inorder to send only one required answer to the host, but apparently that is mixing up the resultn -
March 21, 2021 at 7:52 pm
YasserSelima
Subscriberadd this after the end_c_loopnvmag = vPRF_GRSUM1(vmag);ncells = PRF_GISUM1(cells);nnAlso remove node_to_host .. you don't need itn -
March 22, 2021 at 10:29 am
atulsingh92
SubscriberDoesn't seem to work, nstill prints 5 times (see ***********) , when used with 4 cores, and have multiple -nan(Ind)n ******************************nPressure drop pipe 1(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet -nan(ind)nVelocity average is at pipe 1: -nan(ind)nfrictionfactor is: -nan(ind)nPressure drop pipe 2(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet -nan(ind)nVelocity average is at pipe 2: -nan(ind)nfrictionfactor is: -nan(ind)n******************************nPressure drop pipe 1(Pa) 0 = p_inlet 975.903 - p_outlet 975.903nVelocity average is at pipe 1: 9.52898nfrictionfactor is: 0nPressure drop pipe 2(Pa) 0 = p_inlet 975.903 - p_outlet 975.903nVelocity average is at pipe 2: 10.8784nfrictionfactor is: 0n******************************nPressure drop pipe 1(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet 113.768nVelocity average is at pipe 1: 9.52898nfrictionfactor is: -nan(ind)nPressure drop pipe 2(Pa) 0 = p_inlet 113.768 - p_outlet 113.768nVelocity average is at pipe 2: 10.8784nfrictionfactor is: 0n******************************nPressure drop pipe 1(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet -nan(ind)nVelocity average is at pipe 1: 9.52898nfrictionfactor is: -nan(ind)nPressure drop pipe 2(Pa) 0 = p_inlet 1240.94 - p_outlet 1240.94nVelocity average is at pipe 2: 10.8784nfrictionfactor is: 0n******************************nPressure drop pipe 1(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet -nan(ind)nVelocity average is at pipe 1: 9.52898nfrictionfactor is: -nan(ind)nPressure drop pipe 2(Pa) -nan(ind) = p_inlet -nan(ind) - p_outlet 182.743nVelocity average is at pipe 2: 10.8784nfrictionfactor is: -nan(ind)nnn -
March 22, 2021 at 12:21 pm
YasserSelima
SubscriberThis is because every node is printing a message. The above lines help you to get the same Re ... where are you printing the message?n -
March 22, 2021 at 12:27 pm
atulsingh92
SubscriberSo, the above result is based on a DEFINE_ON_DEMAND(get_results) method, after achieveing convergence. (Note RE was just an example, to show the problem, other methods printed above are called as similar to the Reynolds discussed above.)nIn this DEFINE_ON_DEMAND, I call all the methods to calculate the required values, and at the end, the results are to be printed in Message() commands.nAlso, based on your answer, does that mean, I cannot have only one node printing the answer? And most importantly correctly?n -
March 22, 2021 at 2:57 pm
YasserSelima
SubscriberIf you want one node printing the message , make it Message0 ... this makes node 0 only print the message. Or ... n#if RP_HOSTnMessage(Whatever);n#endifnThe latter makes the host only to print the message. nIn all cases, if you loop through cell thread, every node will have a value from the threads assigned to it. That's why you need to use parallelisation macros ... these two macros should be used after SUM ... one for real and one for integersnvmag = PRF_GRSUM1(vmag);ncells = PRF_GISUM1(cells);nnThere are other macros should be used after MIN , MAX ... etc. check the UDF manual for detailsnn -
March 22, 2021 at 4:27 pm
DrAmine
Ansys EmployeeOr calculate it on each node and then get the max or mix or whatever for all nodes together via a reduction. n
-
Viewing 6 reply threads
- You must be logged in to reply to this topic.
Ansys Innovation Space

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
Trending discussions
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
Top Contributors
-
2524
-
2066
-
1279
-
1096
-
457
Top Rated Tags
© 2023 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.