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/)
-   -   Temperature Gradient UDF file not compiling (https://www.cfd-online.com/Forums/fluent-udf/234488-temperature-gradient-udf-file-not-compiling.html)

SugarOnichan March 8, 2021 23:52

Temperature Gradient UDF file not compiling
 
Hello,

I have a 2D spiral geometry and I am trying to calculate the temperature gradient along the wall. I have written a UDF code to calculate it but it is not getting compiled. Can anyone help me out here ? I am attaching my udf file here.

Code:

#include "udf.h"

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

        thread_loop_c(t,domain)
        {
                begin_c_loop(c,t)
                {
                        C_UDSI(c,t,0)=NV_Mag(C_T_G(c,t));
                }
                end_c_loop(c,t)
        }
}

DEFINE_ON_DEMAND(store_gradient)
{
       
        Domain *domain;
        cell_t c;
        Thread *t;
        domain=Get_Domain(1);
       
        thread_loop_c (t,domain)
        {
                begin_c_loop (c,t)       
                {
                C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
                }
        end_c_loop (c,t)
        }
}


pakk March 9, 2021 01:34

What compiler error do you get?

SugarOnichan March 9, 2021 03:41

Error: UDF library "libudf" not available at ...

pakk March 9, 2021 14:39

That is not the compile error, but the load error. What do you see after you click "build"?

SugarOnichan March 9, 2021 23:17

Here is the screenshot of it :

https://imgur.com/xwrTp90

pakk March 10, 2021 01:55

It's saying there is a problem in line 9. It is saying which word is the problem. Look at that!

pakk March 10, 2021 02:03

The error you post, does not correspond to the code you posted.

In the code, you use "domian". The error says "domain". Presumably you fixed that already.

But the real problem is that you use a word that Fluent does not know. What is domain/domian? It's the first time you use that word, Fluent does not know what you mean. I, as a human, can guess what you mean: earlier you called it "d". But the compiler can not guess that. Use the same name!

SugarOnichan March 10, 2021 03:36

Actually it was a typing mistake and I have already corrected it after that it is showing me that error.

pakk March 10, 2021 08:28

I think you missed the second part of my post.

SugarOnichan March 10, 2021 11:42

Code:

#include "udf.h"

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

        thread_loop_c(t, d)
        {
                begin_c_loop(c,t)
                {
                        C_UDSI(c,t,0)=NV_Mag(C_T_G(c,t));
                }
                end_c_loop(c,t)
        }
}

DEFINE_ON_DEMAND(store_gradient)
{
       
        Domain *d;
        cell_t c;
        Thread *t;
       
        thread_loop_c (t,d)
        {
                begin_c_loop (c,t)       
                {
                C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
                }
        end_c_loop (c,t)
        }
}

So you were trying to say to me that the mistake I was making was using domain instead of "d" in my code ?

I am still getting following error message :

Error: The UDF library you are trying to load (D:\Spiral\Grid Dependency Test-New Geometry\No Of division - 500\2Dv2\2Dv2_files\dp0\FFF\Fluent\libudf) is not compiled for 2ddp on the current platform (win64).\n\nThe system cannot find the file specified.
\n\nD:\Spiral\Grid Dependency Test-New Geometry\No Of division - 500\2Dv2\2Dv2_files\dp0\FFF\Fluent\D:\Spiral\Grid Dependency Test-New Geometry\No Of division - 500\2Dv2\2Dv2_files\dp0\FFF\Fluent\libudf\win64\2d dp\libudf.dll
Error Object: #f

pakk March 10, 2021 12:41

You are still looking at the load error. Don't do that. Look at the compile error. It should be just above this.

pakk March 10, 2021 12:43

Problem is now probably in your second function : you never initialize domain.

SugarOnichan March 10, 2021 23:08

Code:

#include "udf.h"

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

        thread_loop_c(t, d)
        {
                begin_c_loop(c,t)
                {
                        C_UDSI(c,t,0)=NV_Mag(C_T_G(c,t));
                }
                end_c_loop(c,t)
        }
}

DEFINE_ON_DEMAND(store_gradient)
{
       
        d = Get_Domain(1);
        cell_t c;
        Thread *t;
       
        thread_loop_c (t,d)
        {
                begin_c_loop (c,t)       
                {
                C_UDMI(c,t,0) = NV_MAG(C_UDSI_G(c,t,0));
                }
        end_c_loop (c,t)
        }
}

I think now it looks ok but I don't understand your second point. When I click on build option it is not showing error. When I try to load only I am getting error. So what could be the reason behind this and how to solve this ?

pakk March 11, 2021 01:23

Maybe you don't know where to look. Your earlier screenshot clearly showed a compile error... Above the load error.

SugarOnichan March 11, 2021 01:43

I am sorry but I am not understanding your point. Can you elaborate a little bit ? Here is the image after I click on the build : https://imgur.com/vdroI1S

And Here is the image after I click on the load :
https://imgur.com/lpa3IEs

And also "Problem is now probably in your second function : you never initialize domain." Did I solve this problem ?

Also can you recommend some resources to learn all of this ?

pakk March 11, 2021 03:21

The compile error is that nmake is not found.
This indicates a problem with fluent installation/configuration, and has nothing to do with your code.
Weird, because in your earlier screenshot it worked. Is this on the same computer?

I don't have a good advice to learn this... The manual, Google, and this forum...

SugarOnichan March 11, 2021 04:53

No, it is the same computer but I was looking through google and found that I need to install microsoft visual studio. I am not understanding the difference between compile error and load error. Which error I am getting ? and what is the solution of this ?

pakk March 11, 2021 04:59

You are getting both.

Your file did not compile, because your compiler was not found.
And because it was not compiled, Fluent could not load it.

How to solve that: install Fluent properly. I'm no expert on that. Search for the nmake message on this forum.

Yasser March 12, 2021 11:10

Post a screenshot of what you get when compiling, not when loading

Yasser March 12, 2021 11:12

probably the error is here

thread_loop_c(t,domain)

make it

thread_loop_c(t,d)


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