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. |
Are you inititializing with Fluent running in Parallel mode or serial?
|
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.
|
@ 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 initializeI 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. |
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:
PHP Code:
|
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. |
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 ? |
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. |
Quote:
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 |
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.
|
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, |
there is Electric Potential model in Fluent
|
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. |
Quote:
No Thread specified. If you followed a valid link, please notify the administrator |
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.
|
Quote:
please look at the last example of the following file: https://drive.google.com/file/d/1dc7...ew?usp=sharing Regards, |
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. |
Quote:
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. |
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. |
Quote:
I will read the UDF manual again to find the right function for the problem. I have seen codes in which Define_Profile modifies heat flux or other boundry conditions in terms of time or geometry, but I did not find any example of defining temperature dependent heat flux with this function. I read somewhere that this function cannot define such a boundry condition. Thanks a lot, |
Modify
You can modify the following as per your requirement. I am writing it assuming heat flux is dependent upon a coefficient and temperature difference from a reference temperature.
#include "udf.h" #define sCoeff 0.276 /* This and next can also be defined inside the function */ #define sRefTemp 320.0 DEFINE_PROFILE(tBasedHFlux, th, id) { face_t f; begin_f_loop(f,th) { F_PROFILE(f, th, id) = sCoeff * (F_T(f, th) - sRefTemp) } end_f_loop(f,th) } You can apply it on any wall boundary. Actually, the code does not care. You can apply it on inlet, outlet, wherever you want. Do note that the output is not heat flux but a profile of some values. If applied to heat flux boundary, it behaves like heat flux and if applied to temperature, it behaves like temperature. F_T is the temperature of the boundary where this UDF is applied. Fluent provides this value. All values are in SI. |
Quote:
I do not know how to thank you for the time taking to respond me. I hope you good fortune in the projects to come. Regards, |
Hi Vinerm,
I tried your code and faced the same error. http://s7.picofile.com/file/83886695..._VIOLATION.JPG I am trying to find the solution for my errors. I found the below pdf file which I think is very useful. https://drive.google.com/file/d/1pQn...ew?usp=sharing Regards, |
Error
Where did you hook the code? Was it at a boundary? You seem to be using Fluent 6.3.26. Do note that you need to initialize the case before hooking the UDF.
|
Dear Vinerm,
The error was solved. Yes, I'm using Fluent 6.3 on Windows XP. Unfortunately, I do not have access to License Manager of Ansys Workbench and, therefore, I should think about mass transfer mechanism for evaporation and condensation phenomenon. However, now that the Access_Violation error has solved and the case has almost completed, I can go somewhere for running on newer version of Ansys Fluent. Again, thank you very much for the time and effort. Regards, |
Good
Nice to know that the issue got resolved. But could you also mention how it got resolved so that it could be helpful to others?
|
Thanks,
I think the initialization before interpreting the UDF was the solution. I do not know why this can affect ACCESS_VIOLATION error. I wonder whether the first code I used to run (Define_heat_Flux) can also work if I interpret it after initialization. It does not matter anymore, thogh. And finally, can I ask another question? Is it possible to read the temperature of a wall and insert it into another wall's boundary consition in UDF? In other words, we want to define a boundary conditioon that connects the temperature of two walls. How can we define a coupled boundary condition in a single UDF code? By the way, I should thank you again for all your advice. Hope you good fortunes in the projects to come. Regards, |
Coupling
Yes, you can read temperature from one boundary and use it to apply some condition at another. It could be same or after some modifications.
|
That is great.
Thanks, |
Another question about UDF and Thermoelectric:
I need to define Joul heating as a heat sourse as per: Q = I^2 * R ; I : electriccurrent , R : electric resistance Based on the Fluent UDF manual, I tried to use Define_Source function and apply it to the thermoelectric zone in my case. Since it is not for a wall or boundary condition, I did not use Define_Profile. Here is the UDF: --------------------------------------------------------------------- #include "udf.h" DEFINE_SOURCE(Joule_heating, cell, thread) { real Joule_h,I,R,V; I=5; R=2; V=0.0006; // The volume of TEC per unit depth [m^3/m] Joule_h = R*I*I/V; // Joule heating [W/m^3/m] return Joule_h; } ------------------------------------------------------------------------ I would appreciate it if anyone could let me know whether or not this is true. It should be noted that the code has been successfully interpreted by Fluent. Regards, |
UDF and value
The UDF as such is correct, but not needed. Since the value is not changing, you can apply a constant value within the cell zone.
For applying source terms, only DEFINE_SOURCE is applicable, DEFINE_PROFILE cannot be used. However, DEFINE_PROFILE can be used for profiles on boundary as well as cell zones. |
Hi Vinerm,
Thank you very much. The amount of heat source might vary versus temperature in my future studies. So I used Define_Source. For example, resistivity of the thermoelectric material might change with temperature. I think I should use "C_T(cell,thread)" to apply tempreature into the code. Regards, |
Quote:
Could anybody please inform me whether or not License Manager of Ansys can make problems for another software's License Manager like Amesim? |
Temperature
Yes, you can use C_T(cell, thread) to access temperature of a cell.
Newer license managers from Ansys are not based on FlexLM, so, the changes for conflict with others are less. However, if the port required is same, then it could cause trouble. Ansys uses 1055 and 2325. You can modify these in the license file, reread the license file, and then change these at client machine. |
Thanks again,
Amesim uses 5053 as I can recall. I have tried to define environment variable as 5053@localhost. But the problem was not solved. By the way, thank you for the time and effort. |
Hostname
Sorry, I have no idea about Amesim, however, localhost may not work with any license manager. License service requires the name of the host machine serving the license.
|
All times are GMT -4. The time now is 17:12. |