|
[Sponsors] |
February 14, 2019, 14:59 |
How do I change the serial udf to parallel?
|
#1 | |
New Member
dhdh89
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
I use udf for membrane calculations.
I want to use face loops to store values in udm consecutively. When the code in serial mode is calculated in parallel mode, an error occurs. If you check the values stored in udm, a value of 0 is found. I converted the example of the customer portal to code it. How can you convert this code to parallel use? -------------------------------------- Quote:
|
||
February 14, 2019, 22:16 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
ansys fluent customization manual
chapter Parallel Considerations best regards |
|
February 19, 2019, 09:37 |
|
#3 | |
New Member
dhdh89
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
Quote:
CODE is calculated, but 0 value is stored in the process of being stored in UDM. even C_UDMI (c1, tc1, UDM_MASS_H2_SOURCE) = 2; 0 is also found. |
||
February 26, 2019, 07:17 |
|
#4 | |
New Member
dhdh89
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
Quote:
#endif I tried this code, but it is useless. Picture 1 shows the picture that succeeded in the serial mode, Picture 2 shows the error that failed in the parallel mode. a1.jpg a2.jpg best regards |
||
February 26, 2019, 22:31 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
in your code you use c_loop once in DEFINE_INIT macro
Code:
thread_loop_c(tc1,d) { begin_c_loop(c1,tc1) { C_UDMI(c1,tc1,UDM_NEIGHBOUR_C) = 0.0; C_UDMI(c1,tc1,UDM_NEIGHBOUR_TC) = 0.0; C_UDMI(c1,tc1,UDM_MASS_SOURCE) = 0.0; } end_c_loop(c1,tc1) } Code:
C_UDMI (c1, tc1, UDM_MASS_H2_SOURCE) = 2; put the whole code you are using (testing) go deep in ansys fluent customiztion manual, because you are interested in faces take a look into Code:
begin_f_loop_int begin_f_loop_ext best regards |
|
March 11, 2019, 04:26 |
|
#6 | |
New Member
dhdh89
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
Quote:
I completed my code by converting the reference (UDF69) found in the customer portal. test_question is my entire code (test). (After initialization) This code can be computed in serial mode, but in parallel mode, it cannot be computed with the following error. PHP Code:
I do not know why. I tried the RP_node code and the principal face_p code, but it is useless. This problem has been blocked for three months. I ask for help. |
||
March 11, 2019, 05:09 |
|
#7 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
did you define enough UDMIs in fluent GUI?
problem my comes from second loop in INIT macro Code:
thread_loop_c(tc2,d) { begin_c_loop(c2,tc2) { best regards |
|
March 13, 2019, 01:18 |
|
#8 | |
New Member
dhdh89
Join Date: Oct 2018
Posts: 7
Rep Power: 8 |
Quote:
c2 and tc2 are defined. PHP Code:
PHP Code:
"mpt_accept error accept failed no such file or directory" As soon as I pressed run calculation after initialization, I got the above error. This is some parallel / mpi error. I can not resolve this problem yet .. best regards |
||
May 12, 2020, 04:10 |
UDF for membrane distillation
|
#9 | |
New Member
Rajeev Awasthi
Join Date: Apr 2020
Posts: 5
Rep Power: 6 |
Quote:
Thanks in advance. |
||
May 12, 2020, 04:35 |
UDMs
|
#10 |
Senior Member
|
One reason could be UDM initialization. UDF69.c does it during initialization, however, if user forgot to hook DEFINE_INIT function, then it will lead to error. But usually, this would lead to segmentation violation. So, the other reason is parallelization. The code is quite old and not parallelized. Current version of Fluent runs in parallel even if you select serial (until you start with -t0), so, you need to parallelize it. Non-parallelized codes do not always cause syntactical problems, but logical ones, i.e., those run but give wrong results. However, sometimes, it may cause errors as well.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
May 12, 2020, 04:43 |
|
#11 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
first of all show the code you are using
code above has some problems with parallelization, at least: Code:
C_UDMI(c1,tc1,UDM_MASS_SOURCE) = -mass_flux / cell_volume1; C_UDMI(c2,tc2,UDM_MASS_SOURCE) = +mass_flux / cell_volume2; simplify code for debugging, later add necessary functionality
__________________
best regards ****************************** press LIKE if this message was helpful |
|
May 12, 2020, 09:05 |
|
#12 |
New Member
Rajeev Awasthi
Join Date: Apr 2020
Posts: 5
Rep Power: 6 |
I am hooking the DEFINE_INIT and DEFINE_ADJUST function in the fluent, but still the error is there. I am new to UDF writing, Can you please help me with how to parallelize a UDF or any of the UDF parallelization examples you can provide. That will be a great help for me.
code: #include "udf.h" #define WALLSIDE1 30 #define WALLSIDE2 5 #define UDM_NEIGHBOUR_C 0 #define UDM_NEIGHBOUR_TC 1 #define UDM_MASS_SOURCE 2 #define TOLERANCE 1E-10 #define SPECIES_NUMBER 0 #define PERMISSIVITY 1.0e-2 #define MY_PRINT Message /* User-Defined Functions for a membrane * permeable to one species but not to fluid * in general. The membrane is represented * by a wall (with facezone numbers WALLSIDE1 * and WALLSIDE2 for the wall and its shadow), * and the mass transfer is brought about by * source terms in the neighbouring cells. * * Written by James Tibbetts and Ed Wynn, * Fluent Europe, January 2006. */ DEFINE_INIT(init_function,d) { Thread *tc1, *tc2; Thread *tf1, *tf2; cell_t c1, c2; face_t f1, f2; real f_c1[3], f_c2[3]; /* This routine is run on initialisation. It sets the User-Defined Memory to appropriate values and initialises the species values for the entire domain. Also, for the two wall face-zones WALLSIDE1 and WALLSIDE2 (one of which is the shadow of the other), it works out pairs of cells on either side of each face. */ /* Here is the initialisation of the UDM & species: */ thread_loop_c(tc1,d) { begin_c_loop(c1,tc1) { C_UDMI(c1,tc1,UDM_NEIGHBOUR_C) = 0.0; C_UDMI(c1,tc1,UDM_NEIGHBOUR_TC) = 0.0; C_UDMI(c1,tc1,UDM_MASS_SOURCE) = 0.0; } end_c_loop(c1,tc1) } /* Here is the pairing of cells: */ /* First, find the threads of the two wall face-zones: */ tf1 = Lookup_Thread(d,WALLSIDE1); tf2 = Lookup_Thread(d,WALLSIDE2); /* Loop through all faces on one of the face-zones: */ begin_f_loop(f1,tf1) { /* Find the centroid of this face: */ F_CENTROID(f_c1,f1,tf1); /* Find the cell linked to this face: */ c1 = F_C0(f1,tf1); tc1 = THREAD_T0(tf1); /* Loop through all faces of the other face-zone: */ begin_f_loop(f2,tf2) { /* Find the face with the same centroid, to within TOLERANCE. TOLERANCE should therefore be a distance smaller than the size of a cell (but not too much smaller, to avoid missed pairings due to round-off). */ F_CENTROID(f_c2,f2,tf2); if (fabs(f_c1[0]-f_c2[0]) <= TOLERANCE && fabs(f_c1[1]-f_c2[1]) <= TOLERANCE && fabs(f_c1[2]-f_c2[2]) <= TOLERANCE ) { /* Having found the matching face, find its cell: */ c2 = F_C0(f2,tf2); tc2 = THREAD_T0(tf2); /* Note each cell's partner in the User-Defined Memory. UDMs must record real values -- add 0.1 so that an integer is not recorded as x.9999999 as the nearest real. */ C_UDMI(c1,tc1,UDM_NEIGHBOUR_C) = c2 + 0.1; C_UDMI(c2,tc2,UDM_NEIGHBOUR_C) = c1 + 0.1; C_UDMI(c1,tc1,UDM_NEIGHBOUR_TC) = THREAD_ID(tc2) + 0.1; C_UDMI(c2,tc2,UDM_NEIGHBOUR_TC) = THREAD_ID(tc1) + 0.1; } } end_f_loop(f2,tf2) } end_f_loop(f1,tf1) MY_PRINT("\n Membrane initialisation completed.\n"); } DEFINE_SOURCE(source_mass,c,t,ds,eqn) { /* This source term should be applied to the entire * fluid zone (because it is zero where not needed), * as both a mass source and a species source. */ ds[eqn] = 0.0; return C_UDMI(c,t,UDM_MASS_SOURCE); } Thanks in advance. |
|
May 12, 2020, 09:51 |
Serial
|
#13 |
Senior Member
|
Check it in Serial first. I hope you are compiling it because it will not work as Interpreted code. If it works in Serial, then parallelization could be done. However, if you get some error in Serial mode, then parallelization may still be required, but only after the other issues have been resolved. And if you get an error during Serial Compilation or execute, please copy the whole error message.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
June 4, 2020, 09:33 |
UDF Error
|
#14 | |
New Member
Rajeev Awasthi
Join Date: Apr 2020
Posts: 5
Rep Power: 6 |
Quote:
I don't know how to run this code in serial. I am using ANSYS 2020R1. I have compiled the UDF successfully and also hooked the function but the fluent is exiting abruptly after the initialization of the case. Please help me in this regard. Thanks in advance. |
||
June 4, 2020, 10:04 |
Serial
|
#15 |
Senior Member
|
Start Fluent with -t0 as option.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
serial udf to parallel udf | radioss | Fluent UDF and Scheme Programming | 10 | January 19, 2019 09:56 |
Dynamic mesh in parallel udf | rsarma | Fluent UDF and Scheme Programming | 3 | August 2, 2018 08:02 |
Fluent UDF wrong number of cells in parallel - correct in serial | dralexpe | Fluent UDF and Scheme Programming | 7 | May 17, 2018 09:26 |
Unsteady boundary condition UDF for parallel FLUENT | Hong M.H | Fluent UDF and Scheme Programming | 7 | October 18, 2017 22:01 |
Dynamic Mesh- Parallel UDF | DE HEART | Fluent UDF and Scheme Programming | 14 | August 11, 2010 02:29 |