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/)
-   -   fatal error during initialization after udf compilation (https://www.cfd-online.com/Forums/fluent-udf/96571-fatal-error-during-initialization-after-udf-compilation.html)

rik January 26, 2012 04:30

fatal error during initialization after udf compilation
 
Hi all,

I have write an UDF to copy wall temperature of semi-cylinder to another.
When I want to initialize, Fluent send me fatal error, see belows :
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()


My Udf :

#include "udf.h"
#include "config.h"
DEFINE_PROFILE(temp_profil,thread,index)
{
real x[3]; /*vecteur position*/
real x1[3]; /*vecteur translaté*/
Domain *domain15=Get_Domain(15);
Domain *domain14=Get_Domain(14);
face_t f;
Thread *t0;
int Zone_ID14=14;
int Zone_ID15=15;
face_t f1;
face_t f2;

begin_f_loop(f,thread) /*boucle sur les faces des mailles*/
{
F_CENTROID(x,f,thread); /*accès aux coordonnées du centre de la face*/

if (x[1]>=244.12)
{
t0=Lookup_Thread(domain15,Zone_ID15);
begin_f_loop(f1,t0) /*boucle sur les faces des mailles*/
{
F_CENTROID(x1,f1,t0);
if (x1[0]==x[0])
{
if (x1[2]==x[2])
{
F_PROFILE(f,thread,index)=F_T(f1,t0);
}
}
}
end_f_loop(f1,t0)
}
if (x[1]<244.12)
{
t0=Lookup_Thread(domain14,Zone_ID14);
begin_f_loop(f2,t0) /*boucle sur les faces des mailles*/
{
F_CENTROID(x1,f2,t0);
if (x1[1]==x[1])
{
if (x1[2]==x[2])
{
F_PROFILE(f,thread,index)=F_T(f2,t0);
}
}
}
end_f_loop(f2,t0)
}
/*accès aux coordonnées du centre de la face translatée de -47mm /!\ Problème peut venir de l'unité*/
/*accès à la température de la face translatée*/
/*F_PROFILE(f1,tread,index) /*accès au profile de température de la face translatée*/
}
end_f_loop(f,thread) /*fin de la boucle*/
}


Does anybody know which mistake can lead to this error?

Thanks a lot in advance.





swiftaircraft January 26, 2012 14:36

Are you inititializing with Fluent running in Parallel mode or serial?

Sixkillers January 26, 2012 17:01

My compiler (gcc) noticed only nested comments at the end of the file. However I have suspicion that you are using macro Get_Domain wrong way. There is always only one domain for single phase flows. You should definitely check out UDF manual to understand its concept. Generally speaking don't be shame to try if your UDF is working in the middle of development of it. It is much easier to find a bug in the early stage than your code become more complex.

rik January 27, 2012 02:56

@ swiftaircraft:
I've compiled my udf , and there's two way,
1_If I first put the udf boundary condition, the error appears when i want to initialize
2_If I initialize before the compilation of the udf, the error comes when I put the boundary condition...
I hope this will answer to your question.

@ Sixkillers:
Sorry but I'm not fluent with C++ code. What should I have to do?

Thanks for your support.

Sixkillers January 29, 2012 05:58

As I mentioned before if you are doing single-phase simulation there is only 1 domain. So you will have to change your code:

PHP Code:

Domain *domain15=Get_Domain(15);
Domain *domain14=Get_Domain(14); 

to:

PHP Code:

Domain *domain=Get_Domain(1); 

Moreover I would commented out most of your code and load it into Fluent to ensure that it is working and then add several new lines and repeat it again. The following approach should help you to isolate piece of code which is failing. In addition don't hesitate to consult Fluent's UDF guide.

rik January 30, 2012 10:57

I understand what you are talking about, I've seen that in the Fluent's UDF guide, but Get_Domain(1) will return the fluid domain pointer, and I've to point on a specfic wall. Can I do that ?

Because my goal is to copy temperature from a wall to another, so how could I do that?

Thanks a lot for the help.

MultiphaseFlowsLab October 16, 2013 18:09

Fluent initialization peoblem
 
I have written a UDF, and I have complied it and did couple of runs. but now, when I compile it for the same case, it is not initialized and Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

appears. but if I read my old data file, with the exactly the same UDF and case file, it works without any issue.
could someone help me ?

kornetka October 17, 2013 03:01

Hi
I am not sure it will help, but please try doing this: Change the code so that first you declare all variables and only after that you assign values to them.

Pacific February 16, 2020 07:33

Quote:

Originally Posted by rik (Post 341242)
Hi all,

I have write an UDF to copy wall temperature of semi-cylinder to another.
When I want to initialize, Fluent send me fatal error, see belows :
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: ()


My Udf :

#include "udf.h"
#include "config.h"
DEFINE_PROFILE(temp_profil,thread,index)
{
real x[3]; /*vecteur position*/
real x1[3]; /*vecteur translaté*/
Domain *domain15=Get_Domain(15);
Domain *domain14=Get_Domain(14);
face_t f;
Thread *t0;
int Zone_ID14=14;
int Zone_ID15=15;
face_t f1;
face_t f2;

begin_f_loop(f,thread) /*boucle sur les faces des mailles*/
{
F_CENTROID(x,f,thread); /*accès aux coordonnées du centre de la face*/

if (x[1]>=244.12)
{
t0=Lookup_Thread(domain15,Zone_ID15);
begin_f_loop(f1,t0) /*boucle sur les faces des mailles*/
{
F_CENTROID(x1,f1,t0);
if (x1[0]==x[0])
{
if (x1[2]==x[2])
{
F_PROFILE(f,thread,index)=F_T(f1,t0);
}
}
}
end_f_loop(f1,t0)
}
if (x[1]<244.12)
{
t0=Lookup_Thread(domain14,Zone_ID14);
begin_f_loop(f2,t0) /*boucle sur les faces des mailles*/
{
F_CENTROID(x1,f2,t0);
if (x1[1]==x[1])
{
if (x1[2]==x[2])
{
F_PROFILE(f,thread,index)=F_T(f2,t0);
}
}
}
end_f_loop(f2,t0)
}
/*accès aux coordonnées du centre de la face translatée de -47mm /!\ Problème peut venir de l'unité*/
/*accès à la température de la face translatée*/
/*F_PROFILE(f1,tread,index) /*accès au profile de température de la face translatée*/
}
end_f_loop(f,thread) /*fin de la boucle*/
}


Does anybody know which mistake can lead to this error?

Thanks a lot in advance.





Dear friend,


I have the same problem.
Could find the answer?
I would appreciate it if you could let me know how you solved the problem?


Regards

vinerm February 16, 2020 16:18

Your Code
 
Rik's post is 8 years old, so, you may or may not expect a reply. However, one problem with his code was use of Get_Domain with numbers like 14 and 15. I didn't look further because code will not be able to go beyond that. If you are getting a problem, it would be better to share your code.

Pacific February 17, 2020 03:04

Hi Vinerm,


Thank you very much for your reply and also for the advice.
I am trying to apply Peltier Heating to a wall.
Peltier heating is a temperature dependent flux as:


Q = alpha_pn * I * T_w


So, I searched in the Fluent UDF manual and found Define_Heat_Flux function which was used to define convective heat transfer:


Q = h * (T_w - T_ambient).


I compared these two equations and wrote a code similarly as:



---------------------------------------------------------------

#include "udf.h"
real Alpha = 0.; // Seebeck coefficient of the couple (a_pn = Peltier/T)
real I=0.; // Electric current

//

DEFINE_ADJUST(htc_adjust, domain)
{
// Define the heat transfer coefficient. */
Alpha = 0.000400;
I=5;
}
DEFINE_HEAT_FLUX(heat_flux, f, t, c0, t0, cid, cir)
{
cid[0] = 0.;
cid[1] = 0.0;
cid[2] = Alpha*I;
cid[3] = 0.;
}
------------------------------------------------------


I would appreciate it if you could inform me why initialization of the case will lead to that error.




Regards,

vinerm February 17, 2020 03:47

Define_heat_flux
 
The macro DEFINE_HEAT_FLUX is actually a misnomer and Fluent (or Ansys) has never thought of changing its name. This macro is not meant for applying heat flux. If you wish to apply heat flux, then use DEFINE_PROFILE. Furthermore, DEFINE_ADJUST function is doing nothing, so, you do not need that.

And it appears that you have mixed two effects. Seebeck and Peltier effects are opposite of each other. Seebeck is the generation of emf due to temperature difference. So, Seebeck coefficient is multiplied by \nabla T to get emf induced. Peltier effect on the other hand uses Peltier coefficients and its product with current given to the circuit gives heat generated.

AlexanderZ February 17, 2020 04:51

there is Electric Potential model in Fluent

Pacific February 17, 2020 05:36

Thank you for reply.
I know about Peltier and Seebeck and their relation (Peltier = Seebeck * T).


Define_Adjust and Define_Heat_Flux have been used by Fluent UDF manual.

Pacific February 17, 2020 05:46

Quote:

Originally Posted by AlexanderZ (Post 758344)
there is Electric Potential model in Fluent

Thanks.


No Thread specified. If you followed a valid link, please notify the administrator

vinerm February 17, 2020 05:57

Fluent's usage
 
Could you point me to Fluent's usage of DEFINE_HEAT_FLUX that you are referring to? Then it will be easier to help.

Pacific February 17, 2020 06:46

Quote:

Originally Posted by vinerm (Post 758352)
Could you point me to Fluent's usage of DEFINE_HEAT_FLUX that you are referring to? Then it will be easier to help.

Thank you again for your followup.
please look at the last example of the following file:


https://drive.google.com/file/d/1dc7...ew?usp=sharing


Regards,

vinerm February 17, 2020 07:14

Heat Flux
 
If you read the statement in section 5, the highlighted one, it clearly mentions that the use of this UDF is to modify how Fluent relates temperature and heat flux. This is not to be used for applying the heat flux. If you wish to modify the relation, then you can go ahead and use it. In the example, the h value is provided by the user. Usually, this h value is determined by Fluent; this is heat transfer coefficient between fluid and its wall on the inside, not the outside of the wall where user specifies a boundary condition using the bc panel. If you wish to apply a heat flux, then use the example from section 1.

In any case, the UDFs in the example are very simple, kind of templates, and not meant for use as it is.

Pacific February 17, 2020 08:31

Quote:

Originally Posted by vinerm (Post 758364)
If you read the statement in section 5, the highlighted one, it clearly mentions that the use of this UDF is to modify how Fluent relates temperature and heat flux. This is not to be used for applying the heat flux. If you wish to modify the relation, then you can go ahead and use it. In the example, the h value is provided by the user. Usually, this h value is determined by Fluent; this is heat transfer coefficient between fluid and its wall on the inside, not the outside of the wall where user specifies a boundary condition using the bc panel. If you wish to apply a heat flux, then use the example from section 1.

In any case, the UDFs in the example are very simple, kind of templates, and not meant for use as it is.

Thank you again.
I will review the file again and get back to you soon.
All I know is that a temperature dependent heat flux can be applied by Define_Heat_Flux function, not Define_Profile. Define_Profile can modify the amount of constant heat flux.


My highest appreciation for the time taking to answer my questions.

vinerm February 17, 2020 08:42

Implications
 
Consider the following scenario

There is a flat plate and water is flowing on top of it. Due to this water flow, a convection coefficient is developed between the water and the flat plate. This depends upon the Re number of the flow and Pr of the water apart from the boundary conditions applied on the bottom side of the wall.

1. If you wish to apply an arbitrary heat flux or temperature or convection coefficient on the bottom of the plate (it could be function of space, time, temperature, or any other variable), then you would use DEFINE_PROFILE

2. If you wish to modify the convection coefficient calculated by Fluent between water and plate, this could be due to any reason that is not being simulated, such as rough wall, then you would use DEFINE_HEAT_FLUX

So, your understanding that DEFINE_HEAT_FLUX is to be used if the heat flux is a function of temperature is incorrect. The purpose of DEFINE_HEAT_FLUX is NOT to apply heat flux but modify its relation with the thermal field. To clarify it further, look at the hook point for both. DEFINE_HEAT_FLUX is hooked at a general location and it loops over all the boundaries that exist in your domain. On the other hand, DEFINE_PROFILE is applied on a specific boundary or cell zone.


All times are GMT -4. The time now is 00:33.