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

New to UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2015, 03:15
Exclamation
  #61
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
After several iterations as well as on demand execution once again the error occurred.

Code:
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
shivakumar is offline   Reply With Quote

Old   April 7, 2015, 04:05
Default
  #62
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
What's your latest version of the UDF, does my reply below still apply?

Quote:
Originally Posted by `e` View Post
The fatal error, "ACCESS_VIOLATION", may suggest that you're trying to access a variable that doesn't exist. I've read that the gradients are not evaluated for the first iteration and only exist from the second iteration onward. You're calling C_P_G from the start of the first iteration (before the solver is called), run the UDF after the first iteration (or set C_P_G to zero/otherwise for the first iteration).
`e` is offline   Reply With Quote

Old   April 7, 2015, 04:41
Unhappy
  #63
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Code:
#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "math.h"

#define gamma 1.4
#define temp_infi 288.15
#define rho_infi 1.225064
#define pre_infi 101325
#define u_infi 248.0514708
#define R 287
#define M_infi 0.729
#define a 340.26

DEFINE_ON_DEMAND(shock_viscous)
{
	Domain *d;
	Thread *t;
	cell_t c;
	
	real aa,bb,del_dot_F;
	
	real f_shock, f_viscous;
	real d_wave,d_viscous, d_spurious;
	
	d=Get_Domain(1);
	
	d_wave=0;
	d_viscous=0;
	d_spurious=0;
	
	thread_loop_c(t,d)
	{				
		begin_c_loop(c,t)
		{
			
			C_P_G(c,t)[0]=1;
			
			aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
	
			bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
	
			del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
			
			f_shock=((C_U(c,t)*C_P_G(c,t)[0]) + (C_V(c,t)*C_P_G(c,t)[1]) + (C_W(c,t)*C_P_G(c,t)[2]))/(a*(NV_MAG(C_P_G(c,t))));
			
			f_viscous= (C_MU_L(c,t)+C_MU_T(c,t))/C_MU_L(c,t);
			
			if(f_shock>=1)
			{
				d_wave+=del_dot_F;
				C_UDMI(c,t,1)=f_shock;
			}
			
			if(f_viscous>(1.1*f_viscous))
			{
				d_viscous+=del_dot_F;
				C_UDMI(c,t,1)=f_viscous;
			}
			
			if(f_shock<1 && f_viscous<=(1.1*f_viscous))
			{
				d_spurious+=del_dot_F;
				C_UDMI(c,t,1)=d_spurious;
			}
		}
		end_c_loop(c,t)
	}
	
	printf("The Viscous drag = %g\n",d_viscous);
	printf("The wave drag= %g\n", d_viscous);
	printf(" The spurious drag = %g\n",d_spurious);
}
Thanks for the reply.
It had run for 5000 iterations.. Finally the error..
I applied the same still getting the access_violation error.
shivakumar is offline   Reply With Quote

Old   April 7, 2015, 07:37
Default
  #64
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Why have you included this line of code?

Code:
C_P_G(c,t)[0]=1;
You're setting the cell's pressure gradient in the x-direction to unity every time...

As for the "ACCESS_VIOLATION" error, you'll need to determine which line of code is causing this error. Insert print to screen commands such as Message0("Here is the beginning of the cell loop\n"); to debug your code.
shivakumar likes this.
`e` is offline   Reply With Quote

Old   April 8, 2015, 01:52
Default
  #65
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
After inserting the Message in code.

Code:
#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "math.h"

#define gamma 1.4
#define temp_infi 288.15
#define rho_infi 1.225064
#define pre_infi 101325
#define u_infi 248.0514708
#define R 287
#define M_infi 0.729
#define a 340.26

DEFINE_ON_DEMAND(shock_viscous)
{
	Domain *d;
	Thread *t;
	cell_t c;
	
	real aa,bb,del_dot_F;
	
	real f_shock, f_viscous;
	real d_wave,d_viscous, d_spurious;
	
	d=Get_Domain(1);
	
	d_wave=0;
	d_viscous=0;
	d_spurious=0;
	Message("point a\n");
	
	thread_loop_c(t,d)
	{				
		begin_c_loop(c,t)
		{			
			f_shock=((C_U(c,t)*C_P_G(c,t)[0]) + (C_V(c,t)*C_P_G(c,t)[1]) + (C_W(c,t)*C_P_G(c,t)[2]))/(a*(NV_MAG(C_P_G(c,t))));
			Message(" point 1 \n");
			
			f_viscous= (C_MU_L(c,t)+C_MU_T(c,t))/C_MU_L(c,t);
			Message(" point 2 \n");
			
			if(f_shock>=1)
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 3\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 4\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 5\n");
				
				d_wave+=del_dot_F;
				Message("point 6\n");
				
				C_UDMI(c,t,1)=f_shock;
				Message("point 7\n");
			}
			
			if(f_viscous>(1.1*f_viscous))
			Message("point 8\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 9\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 10\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 11\n");
				
				d_viscous+=del_dot_F;
				Message("point 12\n");
				
				C_UDMI(c,t,1)=f_viscous;
				Message("point 13\n");
			}
			
			if(f_shock<1 && f_viscous<=(1.1*f_viscous))
			Message("point 14\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 15\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 16\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 17\n");
				
				d_spurious+=del_dot_F;
				Message("point 18\n");
				
				C_UDMI(c,t,1)=d_spurious;
				Message("point 19\n");
			}
		}
		end_c_loop(c,t)
	}
	
	printf("The Viscous drag = %g\n",d_viscous);
	printf("The wave drag= %g\n", d_viscous);
	printf(" The spurious drag = %g\n",d_spurious);
}
The following output with error has occurred.
Code:
point a
 point 1 
 point 2 
point 9
point 10

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
shivakumar is offline   Reply With Quote

Old   April 8, 2015, 02:22
Default
  #66
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Firstly, be careful where you add lines of code for example:

Code:
if(f_viscous>(1.1*f_viscous))
Message("point 8\n"); // this line of code is executed only if the above condition is satisfied
{
    // this section of code is always executed, regardless of the above if statement
}
From your detailed use of the Message() function, we can see the problem line is:

Code:
del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
What are you trying to calculate here (what is the equation)? Could you instead use C_STRAIN_RATE_MAG as suggested by coglione?
`e` is offline   Reply With Quote

Old   April 8, 2015, 02:55
Default
  #67
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
This is eqn of force obtained without multiplying velocity vector.

Code:
bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
del_dot_F is divergence of force.

when I multiplied bb with the velocity vector. I got
(du/dx + dv/dx+ dw/dz)*bb..

This is what I was expecting from the below line.


Code:
del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
shivakumar is offline   Reply With Quote

Old   April 8, 2015, 04:12
Default
  #68
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Check if Fluent can access the local cell velocity with the same cell number and thread pointer in the same area of code:

Code:
Message("C_U(c,t) = %e\n",C_U(c,t));
Message("C_DUDX(c,t) = %e\n",C_DUDX(c,t));
shivakumar likes this.
`e` is offline   Reply With Quote

Old   April 8, 2015, 04:59
Exclamation
  #69
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
thanks for the reply.. It is accessing those values..
Here is the code
Code:
#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "math.h"

#define gamma 1.4
#define temp_infi 288.15
#define rho_infi 1.225064
#define pre_infi 101325
#define u_infi 248.0514708
#define R 287
#define M_infi 0.729
#define a 340.26

DEFINE_ON_DEMAND(shock_viscous)
{
	Domain *d;
	Thread *t;
	cell_t c;
	
	real aa,bb,del_dot_F;
	
	real f_shock, f_viscous;
	real d_wave,d_viscous, d_spurious;
	
	d=Get_Domain(1);
	
	d_wave=0;
	d_viscous=0;
	d_spurious=0;
	Message("point a\n");
	
	thread_loop_c(t,d)
	{				
		begin_c_loop(c,t)
		{			
			f_shock=((C_U(c,t)*C_P_G(c,t)[0]) + (C_V(c,t)*C_P_G(c,t)[1]) + (C_W(c,t)*C_P_G(c,t)[2]))/(a*(NV_MAG(C_P_G(c,t))));
			Message(" point 1 \n");
			
			f_viscous= (C_MU_L(c,t)+C_MU_T(c,t))/C_MU_L(c,t);
			Message(" point 2 \n");
			
			if(f_shock>=1)
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 3\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 4\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 5\n");
				
				
				
				d_wave+=del_dot_F;
				Message("point 6\n");
				
				C_UDMI(c,t,1)=f_shock;
				Message("point 7\n");
			}
			
			if(f_viscous>(1.1*f_viscous))
			Message("point 8\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 9\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 10\n");
				
				Message("C_U(c,t) = %e\n",C_U(c,t));
				Message("C_DUDX(c,t) = %e\n",C_DUDX(c,t));
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 11\n");
				
				d_viscous+=del_dot_F;
				Message("point 12\n");
				
				C_UDMI(c,t,1)=f_viscous;
				Message("point 13\n");
			}
			
			if(f_shock<1 && f_viscous<=(1.1*f_viscous))
			Message("point 14\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 15\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 16\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t));
				Message("point 17\n");
				
				d_spurious+=del_dot_F;
				Message("point 18\n");
				
				C_UDMI(c,t,1)=d_spurious;
				Message("point 19\n");
			}
		}
		end_c_loop(c,t)
	}
	
	printf("The Viscous drag = %g\n",d_viscous);
	printf("The wave drag= %g\n", d_viscous);
	printf(" The spurious drag = %g\n",d_spurious);
}

Error reads
Code:
point a
 point 1 
 point 2 
point 9
point 10
C_U(c,t) = 2.293790e+02
C_DUDX(c,t) = 3.646992e+02

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
shivakumar is offline   Reply With Quote

Old   April 8, 2015, 05:07
Default
  #70
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
What about C_DWDZ(c,t)? If you're running 2-D then it'd make sense if that variable wasn't available because it's only available in 3-D.
`e` is offline   Reply With Quote

Old   April 8, 2015, 05:24
Default
  #71
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Sorry I forgot to inform its 2D. I need the same in 3D as well.

I just changed the code now. Its running like anything, cannot stop the fluent. I just clicked execute on demand. Its not giving access_violation error. its executing. I dunno when it will stop.

Can you check this code? Is it correct?

Code:
#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "math.h"

#define gamma 1.4
#define temp_infi 288.15
#define rho_infi 1.225064
#define pre_infi 101325
#define u_infi 248.0514708
#define R 287
#define M_infi 0.729
#define a 340.26

DEFINE_ON_DEMAND(shock_viscous)
{
	Domain *d;
	Thread *t;
	cell_t c;
	
	real aa,bb,del_dot_F;
	
	real f_shock, f_viscous;
	real d_wave,d_viscous, d_spurious;
	
	d=Get_Domain(1);
	
	d_wave=0;
	d_viscous=0;
	d_spurious=0;
	Message("point a\n");
	
	thread_loop_c(t,d)
	{				
		begin_c_loop(c,t)
		{			
			f_shock=((C_U(c,t)*C_P_G(c,t)[0]) + (C_V(c,t)*C_P_G(c,t)[1]))/(a*(NV_MAG(C_P_G(c,t))));
			Message(" point 1 \n");
			
			f_viscous= (C_MU_L(c,t)+C_MU_T(c,t))/C_MU_L(c,t);
			Message(" point 2 \n");
			
			if(f_shock>=1)
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 3\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 4\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t));
				Message("point 5\n");
				
				
				
				d_wave+=del_dot_F;
				Message("point 6\n");
				
				C_UDMI(c,t,1)=f_shock;
				Message("point 7\n");
			}
			
			if(f_viscous>(1.1*f_viscous))
			Message("point 8\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 9\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 10\n");
				
				Message("C_U(c,t) = %e\n",C_U(c,t));
				Message("C_DUDX(c,t) = %e\n",C_DUDX(c,t));
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t));
				Message("point 11\n");
				
				d_viscous+=del_dot_F;
				Message("point 12\n");
				
				C_UDMI(c,t,1)=f_viscous;
				Message("point 13\n");
			}
			
			if(f_shock<1 && f_viscous<=(1.1*f_viscous))
			Message("point 14\n");
			{
				aa=log((C_P(c,t)/pre_infi)*pow((rho_infi/C_R(c,t)),gamma));
				Message("point 15\n");
	
				bb=(C_R(c,t)*u_infi*aa)/(gamma*M_infi*M_infi*(gamma-1));
				Message("point 16\n");
	
				del_dot_F=bb*(C_DUDX(c,t)+C_DVDY(c,t));
				Message("point 17\n");
				
				d_spurious+=del_dot_F;
				Message("point 18\n");
				
				C_UDMI(c,t,1)=d_spurious;
				Message("point 19\n");
			}
		}
		end_c_loop(c,t)
	}
	
	printf("The Viscous drag = %g\n",d_viscous);
	printf("The wave drag= %g\n", d_viscous);
	printf(" The spurious drag = %g\n",d_spurious);
}
shivakumar is offline   Reply With Quote

Old   April 8, 2015, 05:37
Smile
  #72
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Thank you so much 'e'...

Its executing each and every messages now....
shivakumar is offline   Reply With Quote

Old   April 8, 2015, 05:42
Default
  #73
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Great, so the issue was you were trying to access a gradient, dw/dz, which is only applicable in 3-D cases but you're running a 2-D case. Remember that you'll need to include these z-direction forces/gradients for your 3-D case.
`e` is offline   Reply With Quote

Old   April 8, 2015, 05:53
Default
  #74
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Ok 'e'. I will keep in mind. thank you.

I just run the fluent for 60 iterations and it didnt give any access violation errors.

Output looks like this.

Code:
The Viscous drag = 0
The wave drag= 0
 The spurious drag = -1.#IND
shivakumar is offline   Reply With Quote

Reply


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
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF acasas CFD Freelancers 1 January 23, 2015 08:26
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03


All times are GMT -4. The time now is 17:05.