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/)
-   -   Difficulty in loading UDF: udf library not compiled for parallel use (https://www.cfd-online.com/Forums/fluent-udf/230474-difficulty-loading-udf-udf-library-not-compiled-parallel-use.html)

Danmei September 24, 2020 18:49

Difficulty in loading UDF: udf library not compiled for parallel use
 
1 Attachment(s)
Hi all,
I’m having difficulty debug/load the UDF in my work. The problem description is demonstrated as the following:
Background: I’m using mixture model to simulate two liquid phases in a tank. The primary phase is water and the second phase is slightly heavier than water. What I want to do is to “count how much of the second phase fluid can accumulate at the bottom of the tank”. So I understand it as it is similar to degassing boundary condition for air, but in my case, for liquid. I assume if the second phase hit the floor below a certain velocity, I “take it out”.
Condition: I have windows 10 64bit OS VS2017 installed. ANSYS 2020R2.
Problem: As I was trying to build and load the library with a c file saved in the same directory where the case file is saved, I received this error message:
Copied D:\Software\ansys\ANSYS 2020R2\UDF practice/D:\Software\ansys\ANSYS 2020R2\UDF practice estudf.c to libudf\src
Creating user_nt.udf file for 3ddp_host ...
(system "copy "d:\software\ansys\ansys 2020r2\ansys inc\ansys student\v202\fluent"\fluent20.2.0\src\udf\makefile _nt.udf "libudf\win64\3ddp_host\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_host")# Generating ud_io1.h
testudf.c
# Generating udf_names.c because of makefile testudf.obj
udf_names.c
# Linking libudf.dll because of user_nt.udf udf_names.obj testudf.obj
Microsoft (R) Incremental Linker Version 14.16.27043.0
Copyright (C) Microsoft Corporation. All rights reserved.

LINK : fatal error LNK1104: cannot open file 'libudf.dll'
Creating user_nt.udf file for 3ddp_node ...
(system "copy "d:\software\ansys\ansys 2020r2\ansys inc\ansys student\v202\fluent"\fluent20.2.0\src\udf\makefile _nt.udf "libudf\win64\3ddp_node\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\3ddp_node")# Generating ud_io1.h
testudf.c
..\..\src\testudf.c(13): warning C4003: not enough arguments for function-like macro invocation 'THREAD_SUB_THREAD'
..\..\src\testudf.c(13): error C2059: syntax error: ']'

I also received this message if I tried to click load.



Question: I noticed that there are bugs. i.e. not enough arguments for function-like macro invocation ‘THREAD_SUB_THREAD’. However, I’m not sure where did I make the mistake. Also in regards of the syntax error: ‘]’, I do not have ‘]’ in that line.

Also, can someone help me understand what does it mean in the error message and how to resolve it?

What I have tried:
1. Open Fluent from VS Command Prompt
2. Making sure all the files (cas,dat,c) are in the same location
3. Run this in parallel with multiple cores.
4. Making sure that visual C++ is installed.

Attached is my udf file. Any help is highly appreciated!

Danmei September 25, 2020 14:18

Managed to build and load facing UDMI problem
 
Hi all,

So I managed to modify and code and make it work for serial processing for now. I am able to build and load the library in ANSYS 2020R2.

However, as I tried to initiate the computation, I received an error message like:

Node 0: Process 20628: Received signal SIGSEGV.

I set the UDM locations to 6 before I load the library, as I put 5 in the C_UDMI(c,t,i). (I'm not sure how to determine what your index i should be...)

Can anyone help me?

AlexanderZ October 5, 2020 04:00

try this code,
its enough to allocate only one udmi memory location for this UDF

Code:

#include "udf.h"

DEFINE_ADJUST(my_adjust1, d)
{
        Thread *t, **pt;
        cell_t c;
        t = Lookup_Thread(d, 9);
        begin_c_loop(c, t)
        {
                C_UDMI(c,t,0)=0.0;
                pt=THREAD_SUB_THREAD(t);
                if (C_V(c, pt[1]) < -0.15)
                        C_UDMI(c, t, 0) = 227.27*C_R(c, pt[1])*C_VOF(c, pt[1])*C_V(c, pt[1]);
        }
        end_c_loop(c, t)
}

DEFINE_SOURCE(bot_source1, c, t, dS, eqn)
{
real source;
Thread *super_t = THREAD_SUPER_THREAD(t);
        source = (-1.0*C_UDMI(c,super_t,0));
        return  source;
}
       
DEFINE_INIT(my_init_func,d)
{
        Thread *t, **pt;
        cell_t c;
        thread_loop_c(t,d)
        {
                /* loop over all cells */
                begin_c_loop_all(c,t)
                        {
                                C_UDMI(c,t,0) = 0.0;
                        }
                end_c_loop_all(c,t)
        }
}


Danmei October 7, 2020 10:03

Hi, thank you very much for the code! However, I'm still getting the error message: Node 0: Process XXXXX: Received signal SIGSEGV

I tried making the C_UDMI a constant and it does not report error. I assume there is something wrong with the formula for C_UDMI.

I wanted to calculate the mass flow rate at the wall boundary which will be (\rho*vof_2nd phase*v_vertical*Area. The area should be the area of the rectangular cell surface perpendicular to the y_axis. I'm not sure how can I get that...

Any help would be highly appreciated!

AlexanderZ October 7, 2020 22:53

well, now I can see, the problem comes from pt[1]
why are you trying to use it?
change pt[1] to t everywhere.


the other important thing is
Quote:

I wanted to calculate the mass flow rate at the wall boundary
1. on wall boundary velocity is 0 (usually, if not special simulations), so no mass flow rate at all
2. if you want to calculate mass flow rate on the surface, you need loops over faces (and adjusted cells) , not cells.
3. once you've made t =9 , you defined that loop will be in thread with ID = 9, and for your code it should be some zone, not boundary

Danmei October 8, 2020 18:53

Hi,

I think I should explain the problem better in this way:

I use mixture model to simulate flow with two different fluids. What I'm trying to do is that I want to remove the second fluid that "hits" the bottom floor with a certain vertical velocity(assume 0.0 m/s). So the C_UDMI calculates the flux of the second phase that needs to be removed. I shouldn't have said it as "to calculate the mass flow rate at the wall boundary"

To answer some of your questions:
1. I used pt[1] because I need to read some variables of the second phase like density, volume fraction, vertical velocity. I'm not sure if I'm only using t, one pointer, how can I read the second phase properties only?

2. I loop over the cell because my understanding is that the values are stored in the cells? The source term was eventually hooked up in cell zone. So I'm not actually getting the velocity from the wall, but read it from the cell at the ID=9.

Here is the code that I successfully compiled but still having issues with the error message I mentioned above:

Code:

#include "udf.h"

DEFINE_ADJUST(my_adjust1, d)
{
        Thread *t, **pt;
        face_t f;
        cell_t c;

        t = Lookup_Thread(d, 9);
                begin_c_loop(c, t)
        {
                C_UDMI(c,t,0)=0.0;
                pt=THREAD_SUB_THREADS(t);
                if (C_V(c, pt[1]) < 0.0)
                        C_UDMI(c,t,0) = -1.368*C_R(c, pt[1])*C_VOF(c, pt[1])*C_V(c, pt[1]);
        }
        end_c_loop(c, t)

}

DEFINE_SOURCE(bot_source1, c, t, dS, eqn)
{
        Thread *super_t = THREAD_SUPER_THREAD(t);
        return (-1.0*C_UDMI(c,super_t,0));
}

3. Also, if you don't mind can you explain a bit why pt[1] can be the problem? I suspect that is the case, but I cannot comprehend it yet.


My apologies, I'm new to UDF. Thank you for being so patient with me.

AlexanderZ October 12, 2020 07:12

thread pt is not defined in your code, which supposes to lead to error
try to add
Code:

**pt = THREAD_SUB_THREADS(t);
before cell loop


All times are GMT -4. The time now is 19:57.