CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

calculate gradient of U in groovyBC

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

Reply
 
LinkBack Thread Tools Display Modes
Old   May 21, 2014, 04:48
Default calculate gradient of U in groovyBC
  #1
New Member
 
Chao Liu
Join Date: May 2014
Posts: 5
Rep Power: 2
lcchaos is on a distinguished road
Hello

I'm trying to calculate the force on a surface to update the moving-wall boundary condition of the surface. The gradient of U is needed for calculating viscous contribution of forces.

The code is based on the example on wiki
http://openfoamwiki.net/index.php/Co...ectionalForces

Code:
    
sphere
    {
	type		groovyBC; 
  	variables 	(
			"pressure_force=sum(p*normal()*area());"
			"viscous_force=sum(-snGrad(U)*area()*0.01);"	//nu=0.01
			"force=pressure_force+viscous_force;"
			"acceleration=force*1000/33.51;"	//density=1000;mass=33.51 SI
			"torque=sum((pos()-vector(0,0.4,0))^(p*normal()*area()-snGrad(U)*area()*0.01));"
			"angular_acceleration=torque*1000/0.5362;"	//moment of inertia=0.5362
			);
	valueExpression	"(time()>1.0) ? U+(vector(acceleration.x,0,0)+angular_acceleration^(pos()-vector(0,0.4,0)))*deltaT()*0.5 : U";
	value		uniform (0 0 0);
    }
I noticed that snGrad(U) is not the inner product of normal vector of face and the deformation tensor. So I change snGrad(U) into grad(U)+grad(U)T (T means transport matrix). However, I got an error

Code:
--> FOAM FATAL ERROR: 
 Parser Error for driver PatchValueExpressionDriver at "1.1-4" :"field grad not existing or of wrong type"
"grad(U)"
  ^^^^
--|
Thanks for your help!

Regards,
lcchaos is offline   Reply With Quote

Old   May 21, 2014, 06:49
Default
  #2
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 913
Rep Power: 14
RodriguezFatz will become famous soon enough
Hi!
Quote:
Originally Posted by lcchaos View Post
I noticed that snGrad(U) is not the inner product of normal vector of face and the deformation tensor.
But what is snGrad(U) else?
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   May 21, 2014, 08:16
Default
  #3
New Member
 
Chao Liu
Join Date: May 2014
Posts: 5
Rep Power: 2
lcchaos is on a distinguished road
Quote:
Originally Posted by RodriguezFatz View Post
Hi!

But what is snGrad(U) else?
Hi, snGrad(U) is the gradient of U in the surface normal direction.
lcchaos is offline   Reply With Quote

Old   May 21, 2014, 08:18
Default
  #4
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 913
Rep Power: 14
RodriguezFatz will become famous soon enough
Well ok, this does not account for the moving wall... or what is the problem?
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   May 21, 2014, 09:30
Default
  #5
New Member
 
Chao Liu
Join Date: May 2014
Posts: 5
Rep Power: 2
lcchaos is on a distinguished road
Quote:
Originally Posted by RodriguezFatz View Post
Well ok, this does not account for the moving wall... or what is the problem?
Philipp, I want to impose a moving wall boundary condition on the surface of a sphere. The motion results from the hydrodynamic force . Therefore, the gradient of U at the surface must be obtained to calculate the force. The problem is that an error appears when I use grad(U). Using snGrad(U) is incorrect physically.
lcchaos is offline   Reply With Quote

Old   May 23, 2014, 06:32
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,829
Rep Power: 38
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by lcchaos View Post
Philipp, I want to impose a moving wall boundary condition on the surface of a sphere. The motion results from the hydrodynamic force . Therefore, the gradient of U at the surface must be obtained to calculate the force. The problem is that an error appears when I use grad(U). Using snGrad(U) is incorrect physically.
You need the gradient in tangential direction? There is no built in implementation for that in OF (and therefor not in swak). Best way to get this would be to calculate grad(U) (in a seperate step. groovyBC can't do this) on the interior and then get that value from the cells next to the patch (with internalField). But this is probably rather inaccurate.

On the other hand: as you probably know the U of the sphere it is probably better to calculate grad(U) in tangential direction analytically
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is online now   Reply With Quote

Old   May 25, 2014, 10:34
Default
  #7
New Member
 
Chao Liu
Join Date: May 2014
Posts: 5
Rep Power: 2
lcchaos is on a distinguished road
Quote:
Originally Posted by gschaider View Post
You need the gradient in tangential direction? There is no built in implementation for that in OF (and therefor not in swak). Best way to get this would be to calculate grad(U) (in a seperate step. groovyBC can't do this) on the interior and then get that value from the cells next to the patch (with internalField). But this is probably rather inaccurate.

On the other hand: as you probably know the U of the sphere it is probably better to calculate grad(U) in tangential direction analytically
Hi Bernhard,

Thanks for your advice! I' m trying to do the calculation by modify the source code. My general idea is adding a new equation for the tensor grad(U) after the momentum equation is solved. Does this way can avoid the inaccuracy?

Regards
Chao
lcchaos is offline   Reply With Quote

Reply

Tags
groovybc

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
WSS and normal velocity gradient for the slanted pipe wanna88 FLUENT 2 October 1, 2012 22:34
calculate temperature gradient from temperature field xiyuqiu Main CFD Forum 14 July 30, 2012 14:38
A function to calculate gradient in a cell Ballal CD-adapco 0 June 9, 2012 00:07
Temperature Gradient at Wall sven OpenFOAM 7 November 1, 2010 18:25
calculate the temperature gradient on a profile arther FLUENT 0 April 19, 2006 23:12


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