|
[Sponsors] |
porous model interperted UDF,initialization error |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 23, 2018, 09:44 |
porous model interperted UDF,initialization error
|
#1 |
New Member
wuming
Join Date: Nov 2018
Posts: 26
Rep Power: 8 |
hi all
i am learning porous model now,when i use UDF for viscous resistance and intertial resistance,the case will initialization error(received a fatelsignal(segmentation fault)).my UDF function as follows: #include "udf.h" DEFINE_PROFILE(porosity_function, t, nv) { Thread *thread_g; real void_g, cgmb, a, b, cta; cell_t c; if (C_VOF(c, thread_g)<1.0e-7) { void_g = 1.0e-7; } else { void_g = C_VOF(c, thread_g); } cta = 0.36; cgmb = 1 - void_g * cta; a = 0.64 / cgmb; b = void_g * cta; begin_c_loop(c, t) { C_PROFILE(c, t, nv) = 3.6 *void_g*cgmb*pow(a, 0.33333) / pow(b, 3) / 0.0016; } end_c_loop(c, t); } I think my void_g has some problem,but i don't know how to modify it.Thanks in advance for your support. Best regards, |
|
November 24, 2018, 07:21 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Wuming
One immediate problem is that the code uses "c" and "thread_g" without first giving them values. This will cause the error. -- A thread pointer "t" is supplied when the DEFINE_PROFILE is called. Because of the way that DEFINE_PROFILE is applied, this is presumably the thread of a boundary _face_ zone. You need to work out how to look up "thread_g" from this -- maybe you want the neighbouring cell and cell-thread? Another issue (although possibly this will not cause an error) is that you loop across cells of the thread "t" (using "begin_c_loop...end_c_loop"), but "t" is a face thread. You should use a face loop instead. Once you have the face and face-thread, you can look up the neighbouring cell and cell-thread using F_C0(f,t) and F_C0_THREAD(f,t). (Since these are boundary faces, you know that there is only one neighbouring cell. So, on this occasion, you do no need to consider F_C1.) Then you can look up cell values. -- One immediate complication is that your model may be multiphase. Is the cell value that you want stored on the master thread or on a subthread? This is a complicated question, so you should go and look up the syntax of C_VOF. This will point you to the need for subthreads and the command THREAD_SUB_THREAD or similar. Good luck! Ed |
|
November 24, 2018, 08:40 |
|
#3 |
New Member
wuming
Join Date: Nov 2018
Posts: 26
Rep Power: 8 |
thank you,i will try
|
|
December 2, 2018, 05:23 |
Variable porosity in UDF
|
#4 |
New Member
Akintayo
Join Date: Nov 2018
Posts: 2
Rep Power: 0 |
Hi all,
I need your help fam, I'm working on my project and it seems stucked as my UDF keeps giving the error message "structured reference not implemented" Problem: I want to write a UDF to calculate the viscous and inertial resistance, such that the viscous and inertial resistance are based on the varing porosity which I would parametrize. The code is something like this DEFINE_PROPERTY (viscous_resistance, cell, thread) { real phi = C_POR(cell, thread); return phi / k_p; } DEFINE_PROPERTY (inertial_resistance, cell, thread) { real c_f = 0.55; real phi = C_POR(cell, thread); return 2 * c_f * pow(k_p, -0.5) * pow(phi, 2); } It returns the error "structure reference not implemented" I have gone online but I haven't gotten enough on how to write the variable porosity. Look forward to your reply fam... Regards, Akintayo |
|
December 2, 2018, 07:19 |
|
#5 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Akintayo,
Well, you can check whether C_POR is implemented in the version of Fluent that you are using (which version is that, by the way?) -- see if there is a "#define C_POR" line in Fluent's mem.h. You might need to #include "math.h", in order to use pow (for example). Also, the code you give does not define k_p. Neither of these would fit the error message you report. Good luck! Ed |
|
December 2, 2018, 09:04 |
|
#6 |
New Member
Akintayo
Join Date: Nov 2018
Posts: 2
Rep Power: 0 |
Thanks for the response.
I defined k_p and used "math.h" to ensure my pow works. I'm using ansys 17.2, I also tried it on ansys 15 and it gave me the same error code. I'm quit new to ansys so i really don't know what you mean by "see if there is a "#define C_POR" line in Fluent's mem.h." and how to know if it was implemented... |
|
December 2, 2018, 19:48 |
|
#7 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi Arkintea,
Where Fluent is installed, you should find a directory "src", which contains some subdirectories, which contain some header files. One of these is "mem.h". These are the files that define the macros and functions that are used in User Defined Functions. So, when you have found those header files, you need to check whether C_POR is defined, and whether it is defined in the way that you think it is. I would do this by a command such as "grep C_POR */*.h" in the "src" directory, but any kind of search should help. Actually, an easier way is just to comment out the lines using C_POR(c,t), or maybe put in something more common, such as C_P(c,t). Strip out more and more of your UDFs (admittedly your UDFs are quite simple already) until something works, and then you know what is causing the trouble. In the end, you can get really paranoid and (for example) delete the spaces between "DEFINE_PROPERTY" and "(". Alternatively, approach it from the opposite direction: start from an example in the manual; check this works; and progressively adjust it until it does what you want. Good luck! Ed |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Building OpenFOAM1.7.0 from source | ata | OpenFOAM Installation | 46 | March 6, 2022 14:21 |
[OpenFOAM] Native ParaView Reader Bugs | tj22 | ParaView | 270 | January 4, 2016 12:39 |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 20:43 |
Errors in UDF | shashank312 | Fluent UDF and Scheme Programming | 6 | May 30, 2013 21:30 |
How to install CGNS under windows xp? | lzgwhy | Main CFD Forum | 1 | January 11, 2011 19:44 |