CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for particle deposition in porous zone (https://www.cfd-online.com/Forums/fluent-udf/237736-udf-particle-deposition-porous-zone.html)

Peter_Beshay August 1, 2021 23:23

UDF for particle deposition in porous zone
 
Hi,
I am very new in UDF and do not have much knowledge on C.
I need urgent help in a UDF to:
1- specify the porous zone ID
2- read the particle concentration in each cell
3- reduce it as a percentage from the initial concentration
4- store the new reduced concentration

I tried for many days but i am stuck, i really appreciate if anyone will help me.
The code i tried is below (probably it is very bad):

#include "udf.h"
#include "sg_mem.h"
# include "dpm.h"
# define domain_ID 4
DEFINE_ADJUST(adjust_UDS,domain)
{
Thread *t;
cell_t c;
domain = Get_Domain(domain_ID);
/*Fill UDS with the variable*/
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_DPMS_CONCENTRATION(c,t);
}
end_c_loop (c,t)
}
}
DEFINE_SOURCE(conc_source,c,t,dS,equ)
{
real x[ND_ND],c_source;
source= (C_UDSI(c,t,0) + C_UDSI(c,t,0));
return source;
}

AlexanderZ August 3, 2021 03:58

compile following code,
in fluent GUI:
hook functions,
allocate 1 user define memory

Code:

#include "udf.h"
#include "sg_mem.h"
#include "dpm.h"

int porous_ID = 4;

DEFINE_INIT(my_init_func,d)
{
        cell_t c;
        Thread *t;
        /* loop over all cell threads in the domain */
        thread_loop_c(t,d)
        {
                /* loop over all cells */
                begin_c_loop(c,t)
                {
                C_UDMI(c,t,0) = 0.0;
                }
                end_c_loop_all(c,t)
        }
}

DEFINE_ADJUST(my_adjust,domain)
{
        Thread *t;
        cell_t c;
        t = Lookup_Thread(domain, porous_ID);
        /*Fill UDM with the variable*/

        begin_c_loop(c,t)
        {
                C_UDMI(c,t,0) = C_DPMS_CONCENTRATION(c,t);
        }
        end_c_loop (c,t)
}

DEFINE_SOURCE(conc_source,c,t,dS,equ)
{
        real x[ND_ND],c_source;
        source= (C_UDMI(c,t,0) + C_UDMI(c,t,0));
        return source;
}


Peter_Beshay August 3, 2021 04:24

Hi Alexander,
Thank you so much for your help.
I will try this UDF.
Could you clarify what do you mean by hook function? (interpret or compile?)
And how do i allocate 1 user memory?
I am so sorry, i'm just beginner in this

Peter_Beshay August 3, 2021 04:41

I have one more question, if i want to also capture the axial velocity at each cell in the porous domain, and include it in the source equation at the end, what should i add more? i am so sorry, i really appreciate your help. you are saving me :)

Peter_Beshay August 3, 2021 07:14

I tried compiling the UDF, i got this error:
///////
Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).\n\nThe system cannot find the file specified.
\n\nD:\NUS\pollutant_study_Prof_Bala\chinese_garde ns_1m_thick_DM_geometry\udf_inlet_trying_depositio n_injecting_from_road_and_inlet\libudf\win64\3ddp_ host\libudf.dll
Error Object: #f
////////
When i interpret the udf, it doesnt generate errors but the solution of the case is the same, it didnt change any numbers.
Could you please help me in this issue?
Thank you

pakk August 3, 2021 11:30

Check my signature below.

Peter_Beshay August 3, 2021 23:13

Hi Pakk,
Thanks for your response.
So how can i solve this issue?
Even when i try "Serial" not parrallel, it generates a similar error, but instead of "(libudf) is not compiled for parallel use on the current platform (win64)." it says not compiled for 3ddp

pakk August 4, 2021 01:45

My suggestion is to look at the errors during compiling, and if you need help share them with us.

I can't see what went wrong during compiling from the word during loading. Show the errors that come after you click 'build'.

(and can you suggest an improvement for my signature? Apparently it is not clear enough, but I can't see the problem...)


All times are GMT -4. The time now is 18:53.