|
[Sponsors] |
urgent! Help! Define mass source on boundary cells used UDF |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 14, 2021, 03:22 |
urgent! Help! Define mass source on boundary cells used UDF
|
#1 |
New Member
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6 |
Hi, friends
I am using UDF to define a mass source on the boundary cells,here's my code. My case is this: particles and water flow in a pipe, and I want to define a mass source for the particle phase in the pipe wall cells. When I compile this UDF, it works normally, but the volume fraction of particles at the wall has not changed. According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced. I don't know where the error is, but the UDF can work well after compilation. Can anyone help me? Any suggestions will be appreciated! code: Code:
//* You are storing source in User defined memory under DEFINE_ON_DEMAND. Then you are using UDMI(c0,t0,0) in DEFINE_SOURCE *// #include "udf.h" //get the boundary cells DEFINE_ON_DEMAND(selecting_the_cells) { #if !RP_HOST Domain *d; Thread *t, *tc, *t0; face_t f; cell_t c, c0; d = Get_Domain(1); tc = Lookup_Thread(d, 9); //Get boundary thread, wall zone ID is 9 //Loop through all the cell threads in the domain thread_loop_c(t, d) { //Loop through the cells in each cell thread begin_c_loop(c, t) { C_UDMI(c, t, 0) = 0; } end_c_loop(c, t) } begin_f_loop(f, tc) { c0 = F_C0(f, tc); t0 = THREAD_T0(tc); C_UDMI(c0, t0, 0) = 1; } end_f_loop(f, tc) #endif } DEFINE_SOURCE(mass_source, c, t, dS, eqn) { real source; if (C_UDMI(c, t, 0) > 0.) { source = -1000.; dS[eqn] = 0.; } else { source = 0.; dS[eqn] = 0.; } return source; } |
|
March 14, 2021, 05:29 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
"According to my UDF, the volume fraction of the particle phase in the pipe wall cells should be reduced."
I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work? Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 14, 2021, 21:06 |
|
#3 |
New Member
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6 |
Thanks for your suggestion, and sorry for my late reply.
"I don't see that. According to your UDF, UDM 0 should be zero everywhere, except at the wall where it is one. Does that part work?" To be honest, I want to use UDM0 to distinguish wall cells. As you just said, UDM0 is 1 in the wall cells and 0 in other cells; In this way, I can specify the source in the wall cell in the following if statement (if (C_UDMI(c, t, 0)> 0.)). Is there anything wrong with this? please give me some advice. "Why that should mean that the volume fraction changes: that depends on how you use UDM 0... Not part of this UDF, but elsewhere in your model." I'm sorry I didn't understand you. I am a UDF rookie... Do you mean there is a problem with my UDF0 usage method? Any suggestions will be appreciated. best wishes |
|
March 15, 2021, 02:30 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I hadn't noticed the second UDF.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build". |
|
March 17, 2021, 22:46 |
|
#5 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you code seems to be correct,
do you see what you want, when making contour of C_UDMI_0 ? are you sure, that -1000 is value which you want? check units
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 18, 2021, 06:27 |
|
#6 |
New Member
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6 |
Thanks Reply! Now it works great because I forgot to load it...
|
|
Tags |
fluent, udf and programming |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
[swak4Foam] Installation Problem with OF 6 version | Aurel | OpenFOAM Community Contributions | 14 | November 18, 2020 17:18 |
Problem compiling a custom Lagrangian library | brbbhatti | OpenFOAM Programming & Development | 2 | July 7, 2014 12:32 |
OpenFOAM without MPI | kokizzu | OpenFOAM Installation | 4 | May 26, 2014 10:17 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |