|
[Sponsors] |
March 19, 2021, 18:15 |
Uninitialized local variable 't' used
|
#1 |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6 |
Hey,
I'm writing a UDF to calculate the viscosity of one of the phases in a multiphase simulation. I've hooked the UDF using DEFINE_PROPERTY macro and I know the code works properly but I want to define it using the DEFINE_ADJUST macro as I want the store the value in a UDM which I can access in the other UDFs. I'm getting errors of "uninitialized local variable 't' used" and "uninitialized local variable 'c' used". I understand that it means that the thread pointer is not defined, but I'm not quite sure how to rectify it. I want to access the cell thread that will be passed to the UDF in the case of hooking it by material properties tab, but I'm not quite sure how to achieve that. Any help would be appreciated. Code:
/****************************************************************************** UDM for storing the non-Newtonian fluid viscosity calculated using APL model *******************************************************************************/ #include "udf.h" DEFINE_ADJUST(non_newtonian_viscosity_udm, domain) { Thread *t, *pt; Thread *mixture_thread = THREAD_SUPER_THREAD(t); pt = THREAD_SUB_THREAD(mixture_thread, 0); cell_t c; domain = Get_Domain(2); /*Defines the primary phase which is the non-Newtonian fluid */ /* Declare the coefficients for APL model to calculate non-Newtonian viscosity */ real mu_0 = 15.9350; real k = 19.5531; real n = 0.2891; real p = -1.00; real shear_rate; /* Calculate the viscosity and store in UDM */ shear_rate = C_STRAIN_RATE_MAG(c,pt); C_UDMI(c,pt,0) = pow((pow(mu_0,p) + pow((k*pow(shear_rate, (n-1))),p)),pow(p,-1)); } |
|
March 21, 2021, 05:36 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Thread *thread = Lookup_Thread(domain, ID);
(copied from the manual)
__________________
"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 21, 2021, 16:40 |
|
#3 | |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6 |
Quote:
I know that the domain ID for the phase is 2 from the "Phases" tab. But I'm unsure of the cell zone ID as there are two cell zones (with IDs 3 and 4) and both contain both fluids. Also is any thread pointer passed by the solver at all when using a DEFINE_ADJUST macro by default? Last edited by Venky_94; March 21, 2021 at 16:44. Reason: Mentioned wrong zone ids earlier |
||
March 22, 2021, 04:58 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You can see what is passed by looking at the function header:
Code:
DEFINE_ADJUST(non_newtonian_viscosity_udm, domain) But you do have to 'select' cell zones. If you have two cell zones, why don't you just use both?
__________________
"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 22, 2021, 09:16 |
|
#5 | |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6 |
Quote:
Also how do I select multiple cell zones? I can select a cell zone using the LOOKUP_THREAD command, but I'm not sure how to select multiple zones. Code:
/* Calculate the viscosity and store in UDM */ shear_rate = C_STRAIN_RATE_MAG(c,pt); C_UDMI(c,pt,0) = pow((pow(mu_0,p) + pow((k*pow(shear_rate, (n-1))),p)),pow(p,-1)); |
||
March 22, 2021, 14:04 |
|
#6 | ||
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
Quote:
__________________
"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 23, 2021, 03:30 |
|
#7 | |
Member
Venkat Ganesh
Join Date: May 2020
Location: Cincinnati, Ohio
Posts: 49
Rep Power: 6 |
Quote:
I'm writing another UDF to store area-averaged phase fraction of air in a UDM. I need to obtain the phase level thread pointer st for which I'm using the THREAD_SUB_THREAD command and it requires the mixture-level thread as an argument. DEFINE_ADJUST unfortunately doesn't pass the thread pointer as an argument and only allows to loop over all threads in the domain. I'm using the Lookup_Thread command to get a mixture-level thread pointer. I need the same thread pointer that will be passed by the solver within DEFINE_ADJUST if I'm looping over all threads in the domain. Would my below approach guarantee that, or do I need to specify some particular ID? Code:
#include "udf.h" #define ID 1 /* zone ID for the interior */ DEFINE_ADJUST(phase_fraction_udm, domain) /* domain is defined as the mixture-level domain by default */ { Thread *t, *st; t = Lookup_Thread(domain, ID); /* define the mixture-level thread to be used for identifying the secondary phase thread pointer */ st = THREAD_SUB_THREAD(t, 1); /* st is the thread pointer for secondary phase i.e. air */ |
||
Tags |
compiled udf, define_adjust, multiphase, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
uninitialized local variable 't' used | Blackhawks84 | Fluent UDF and Scheme Programming | 1 | October 29, 2018 13:02 |
error: uninitialized local variable 't' used | MASOUD | Fluent UDF and Scheme Programming | 5 | October 17, 2016 05:24 |
InterFoam negative alpha | karasa03 | OpenFOAM | 7 | December 12, 2013 04:41 |
AMI interDyMFoam for mixer nu problem | danny123 | OpenFOAM Programming & Development | 8 | September 6, 2013 03:34 |
same geometry,structured and unstructured mesh,different behaviour. | sharonyue | OpenFOAM Running, Solving & CFD | 13 | January 2, 2013 23:40 |