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   March 23, 2015, 04:54
Default
  #41
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Those are the same equations as in your first post of this thread which you've already coded for...
`e` is offline   Reply With Quote

Old   March 27, 2015, 00:08
Question
  #42
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Thanks for the reply. I was out of station for 3 days..

In every parers they have mentioned the same formula to find out the f_viscous. Still I am not getting an idea to find free stream value of f_viscous.
Please help.

Thanks
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 00:22
Default
  #43
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Ok, I misunderstood your question then if you're searching for a different equation for the f_viscous function of the free stream. I'm not familiar with the details of shock waves; good luck!
`e` is offline   Reply With Quote

Old   March 27, 2015, 04:43
Question
  #44
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Ok ill find out that later..


This is my entire code for detection of shock sensor. this is compiling well but not yielding results.. Any help would appreciated.

Code:
#include "udf.h"
#include "math.h"
#include "sg.h"
#include "mem.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_ADJUST(shock_sen,d)
{


	Thread *t;
	cell_t c;
	
	real del_s;
	real del_h;
	real del_u_bar;
	
	real aa, bb, cc, dd, ee;
	
	real f_shock, shock_sensor;
	real d_wave;
	d_wave=0;

	
	
	/* Shock sensor */
	
	
	
	thread_loop_c(t,d)
	{
		begin_c_loop(c,t)
		{
			aa=((C_P(c,t))/C_R(c,t))-(pre_infi/rho_infi);
			bb=((C_U(c,t)*C_U(c,t))+(C_V(c,t)*C_V(c,t))+(C_W(c,t)*C_W(c,t)))/2;
			
			del_h=((gamma/(gamma-1))*aa)+(bb-(u_infi*u_infi/2));
			
			cc=2/((gamma-1)*M_infi*M_infi);
			
			dd=pow((C_P(c,t)/pre_infi), ((gamma-1)/gamma))-1;
			
			ee=((C_V(c,t)*C_V(c,t))+(C_W(c,t)*C_W(c,t)))/(u_infi*u_infi);
			
			del_u_bar=C_U(c,t)-u_infi*(sqrt(1+(2*del_h/u_infi*u_infi)-(cc*dd)-ee)+1);
			
			
			
			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))));
		
			if(f_shock>=1)
				{
					shock_sensor=f_shock;
					d_wave+=(-(C_R(c,t))*del_u_bar*(C_DUDX(c,t)+C_DVDY(c,t)+C_DWDZ(c,t)));
					C_UDMI(c,t,1)= shock_sensor;
				}
		}
		end_c_loop(c,t)	
	}
	
	printf("The wave drag = %g\n", d_wave);

}

shivakumar
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 04:49
Default
  #45
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
Not yielding any results (solver crashes/diverges) or not the results you're expecting? Please provide details... we don't have your results on our screens.
pakk likes this.
`e` is offline   Reply With Quote

Old   March 27, 2015, 04:56
Unhappy
  #46
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Its not yielding any results and solver is not crashing... When I tried with the execute on demand macro it doesnt and in the contour plots also its giving max and min value zero....
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 04:59
Default
  #47
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
So the text "The wave drag = " never shows up in the screen?
pakk is offline   Reply With Quote

Old   March 27, 2015, 05:03
Unhappy
  #48
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
thank u for the reply.. you're right. Its not showing
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 05:04
Default
  #49
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
What if you replace that by the more correct
Code:
Message("The wave drag = %g\n", d_wave);
?
shivakumar likes this.
pakk is offline   Reply With Quote

Old   March 27, 2015, 05:12
Default
  #50
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Quote:
Originally Posted by pakk View Post
What if you replace that by the more correct
Code:
Message("The wave drag = %g\n", d_wave);
?
Thank you. Now it is showing.. Also when my solution is converged, in contours menu, the user memory is not showing results. any problem?
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 05:18
Default
  #51
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
First of all: be more exact. You say:
Quote:
Also when my solution is converged, in contours menu, the user memory is not showing results.
I guess what you mean is that it is showing zero everywhere. Instead of saying what it not shows, it is better to say what it shows, so we don't have to guess. An alternative guess could be that no picture shows. Or that the values are NaN everywhere. This is a big difference.

But if my guess that it shows zero everywhere is correct: In your code, if you don't have a shock wave (f_shock<1), the UDM is never changed. So this shows that in your problem, f_shock is smaller than 1 everywhere. I don't know if this means that you miscalculated f_shock, or that your problem simply does not have shockwaves.
pakk is offline   Reply With Quote

Old   March 27, 2015, 05:26
Default
  #52
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Sorry I forgot to post that pic earlier....Its transonic case M=0.729.. It has a shock wave..
Attached Images
File Type: jpg Capture3.JPG (26.7 KB, 5 views)
File Type: jpg Contour.jpg (26.4 KB, 5 views)
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 05:32
Default
  #53
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by shivakumar View Post
Sorry I forgot to post that pic earlier....Its transonic case M=0.729.. It has a shock wave..
This does not show that it has a shock wave according to the equation you use. According to the equation you use, it only has a shock wave if f_shock>=1. If f_shock<1 everywhere, no shockwave is detected.

Try to replace the line
Code:
if(f_shock>=1)
by
Code:
if(2>=1)
to see the calculated values for f_shock. Probably they are all below 1.
pakk is offline   Reply With Quote

Old   March 27, 2015, 05:47
Exclamation
  #54
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
thank you for the reply. I just replaced the code which you have given and the solution is progressing but the message " The wave drag" is not showing after each iteration...!!!
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 05:49
Unhappy
  #55
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Still no change in the contour plot. Its complete red..
shivakumar is offline   Reply With Quote

Old   March 27, 2015, 05:54
Default
  #56
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
First of all: be aware that my suggestion was not a suggestion to solve your problem. It was a suggestion to find out more about your problem.

And you say your user defined memory 1 is zero everywhere? That should only be the case when the velocity is zero everywhere, or when the pressure gradient is zero everywhere. Plot them to be sure.

And if "The wave drag" is no longer shown, the problem might be that your UDF code is no longer executed. Is it still attached at the right place? Did the compilation give errors that you did not notice?
pakk is offline   Reply With Quote

Old   March 27, 2015, 05:57
Exclamation
  #57
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Finally got error like this


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.


shivakumar is offline   Reply With Quote

Old   March 27, 2015, 06:02
Exclamation
  #58
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Ok. I tried earlier adding another if-else statement when it is less than one or zero. but still getting the same.. I observed there are no compilation errors
shivakumar is offline   Reply With Quote

Old   March 28, 2015, 21:32
Default
  #59
`e`
Senior Member
 
Join Date: Mar 2015
Posts: 892
Rep Power: 18
`e` is on a distinguished road
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   March 31, 2015, 01:09
Smile
  #60
Senior Member
 
Join Date: Mar 2013
Location: B'lr
Posts: 130
Rep Power: 13
shivakumar is on a distinguished road
Thanks for the reply 'e'.. I have set value to zero, its running smoothly.
There are slight modifications which are need to be included in the code.

Thanks
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 07:26
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03


All times are GMT -4. The time now is 16:22.