CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Getting density, temperature, and other cell flow variables via macros in Fluent UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 7, 2020, 17:40
Default Getting density, temperature, and other cell flow variables via macros in Fluent UDF
  #1
New Member
 
Justin
Join Date: Aug 2020
Posts: 8
Rep Power: 6
ingabobjoe is on a distinguished road
Hello,

I'm writing a simple UDF using DEFINE_GRID_MOTION to model movement of a solid surface representing corrosion, based on adjacent fluid properties. Basically, I'm looping over all faces in the "interface" thread that separates the fluid and solid domains (threads), and attempting to move the nodes of each face based on the temperature, density, thermal conductivity, and specific heat values found in the adjacent fluid cell.

After building and loading my UDF without errors, I was getting the following error, which crashed Fluent:

Code:
999999: mpt_accept: error: accept failed: No error==============================================================================

Node 0: Process 17596: Received signal SIGSEGV.

==============================================================================
MPI Application rank 0 exited before MPI_Finalize() with status 2
I'm new at UDFs, but I was able to debug my UDF until I isolated my problem having to do with the C_R and C_T macros, to get density and temperature respectively in a given cell at a specific timestep. The macros for thermal conductivity (C_K_L) and specific heat (C_CP) work just fine, but I've determined that that after successfully building and loading the UDF, the use of either C_R(c, t) or C_T(c, t) crashes Fluent when I try to preview the dynamic mesh motion.

I've determined that the issue has to do with accessing the SV_DENSITY or SV_T variables, as they both return THREAD_STORAGE(t, SV_DENSITY [or SV_T]) == NULL. I think it's because in mem.h, the C_R and C_T macros are simply defined using the C_STORAGE_R macro, whereas both the C_K_L and C_CP macros provide an option to make use of either the C_STORAGE_R macro or the THREAD_PROP macro depending on whether THREAD_STORAGE(t, ...) == NULL or not.

For clarity's sake, I've tried the following:

Code:
if (NNULLP(T_STORAGE_R_NV(tf,SV_KTC))) //also used SV_DENSITY, SV_T
        {
            Message("Yes");
        } else
        {
            Message("No");
        }
and it always returns "No," indicating that the SV variables are not storing the values I need. This doesn't matter for thermal conductivity and specific heat, since there's another way to get them written into mem.h, but it prevents me from obtaining the density and temperature. I'm hesitant to change anything in the mem.h file, however, so I wanted to ask if anyone has encountered this problem before, and how I can obtain the density and temperature values for the cells adjacent to the face thread in between my solid and fluid threads.

Any insight would be greatly appreciated! Please let me know if you need more specific details.
ingabobjoe is offline   Reply With Quote

Old   August 10, 2020, 02:41
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you may try to initialize your case first, and load UDF later
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   August 15, 2020, 22:08
Default
  #3
New Member
 
Justin
Join Date: Aug 2020
Posts: 8
Rep Power: 6
ingabobjoe is on a distinguished road
Thanks! I think that was the issue. I was trying to preview the mesh motion before initializing, so there was no density or temperature for the UDF to grab!

After initializing I ran the simulation and it worked fine.
ingabobjoe is offline   Reply With Quote

Reply

Tags
cell flow variable macros, c_r, c_t, sv_density, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 01:32.