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

fatal error during initialization after udf compilation

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree12Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 26, 2012, 04:30
Default fatal error during initialization after udf compilation
  #1
rik
New Member
 
Join Date: Jan 2012
Posts: 5
Rep Power: 14
rik is on a distinguished road
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.




rik is offline   Reply With Quote

Old   January 26, 2012, 14:36
Default
  #2
Member
 
David Stanbridge
Join Date: Apr 2010
Location: Norwich, UK
Posts: 59
Rep Power: 16
swiftaircraft is on a distinguished road
Are you inititializing with Fluent running in Parallel mode or serial?
swiftaircraft is offline   Reply With Quote

Old   January 26, 2012, 17:01
Default
  #3
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 14
Sixkillers is on a distinguished road
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.
Sixkillers is offline   Reply With Quote

Old   January 27, 2012, 02:56
Default
  #4
rik
New Member
 
Join Date: Jan 2012
Posts: 5
Rep Power: 14
rik is on a distinguished road
@ 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.
rik is offline   Reply With Quote

Old   January 29, 2012, 05:58
Default
  #5
Member
 
Join Date: Nov 2011
Location: Czech Republic
Posts: 97
Rep Power: 14
Sixkillers is on a distinguished road
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.
Sixkillers is offline   Reply With Quote

Old   January 30, 2012, 10:57
Default
  #6
rik
New Member
 
Join Date: Jan 2012
Posts: 5
Rep Power: 14
rik is on a distinguished road
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.
rik is offline   Reply With Quote

Old   October 16, 2013, 18:09
Default Fluent initialization peoblem
  #7
New Member
 
Join Date: Apr 2012
Posts: 19
Rep Power: 14
MultiphaseFlowsLab is on a distinguished road
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 ?
MultiphaseFlowsLab is offline   Reply With Quote

Old   October 17, 2013, 03:01
Default
  #8
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 12
kornetka is on a distinguished road
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.
kornetka is offline   Reply With Quote

Old   February 16, 2020, 07:33
Default
  #9
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
Quote:
Originally Posted by rik View Post
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
Pacific is offline   Reply With Quote

Old   February 16, 2020, 16:18
Default Your Code
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 17, 2020, 03:04
Default
  #11
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
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,

Last edited by Pacific; February 17, 2020 at 05:49.
Pacific is offline   Reply With Quote

Old   February 17, 2020, 03:47
Default Define_heat_flux
  #12
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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.
Pacific likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 17, 2020, 04:51
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
there is Electric Potential model in Fluent
Pacific likes this.
__________________
best regards


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

Old   February 17, 2020, 05:36
Default
  #14
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
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 is offline   Reply With Quote

Old   February 17, 2020, 05:46
Default
  #15
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
there is Electric Potential model in Fluent
Thanks.


No Thread specified. If you followed a valid link, please notify the administrator
Pacific is offline   Reply With Quote

Old   February 17, 2020, 05:57
Default Fluent's usage
  #16
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Could you point me to Fluent's usage of DEFINE_HEAT_FLUX that you are referring to? Then it will be easier to help.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 17, 2020, 06:46
Default
  #17
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
Quote:
Originally Posted by vinerm View Post
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,
Pacific is offline   Reply With Quote

Old   February 17, 2020, 07:14
Default Heat Flux
  #18
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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 likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 17, 2020, 08:31
Default
  #19
New Member
 
Join Date: Jul 2014
Posts: 26
Rep Power: 11
Pacific is on a distinguished road
Quote:
Originally Posted by vinerm View Post
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.
Pacific is offline   Reply With Quote

Old   February 17, 2020, 08:42
Default Implications
  #20
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
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.
Pacific and ebrahem like this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF compilation error Szabolcs Varga Fluent UDF and Scheme Programming 4 September 14, 2015 05:27
UDF compilation problem -- "undeclared variable" Henrik Ström FLUENT 1 September 21, 2005 05:25
error while compiling the USER Sub routine CFD user CFX 3 November 25, 2002 15:16
UDF initialization Sam FLUENT 1 May 21, 2002 08:23
Compiled UDF / Compilation problem mikhail FLUENT 1 October 13, 2000 06:12


All times are GMT -4. The time now is 10:13.