# OF/groovyBC: 2nd derivative or power BC

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

 June 21, 2013, 03:24 OF/groovyBC: 2nd derivative or power BC #1 Member   Join Date: Nov 2012 Posts: 58 Rep Power: 4 It recently occurred to me that I have no idea how to impose a BC of the following two sorts: i) d^2 (X) / dn^2 = 0 ii) d(X) / dn = X^2 Even though they appear rarely, they are used in the literature. Is there a way to impose them natively in OF or in groovyBC?

June 23, 2013, 05:25
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by startingWithCFD It recently occurred to me that I have no idea how to impose a BC of the following two sorts: i) d^2 (X) / dn^2 = 0 ii) d(X) / dn = X^2 Even though they appear rarely, they are used in the literature. Is there a way to impose them natively in OF or in groovyBC?
Second derivative: groovyBC is based on the kind of boundary conditions OpenFOAM can impose and I'm not aware of a boundary condition that allows that directly

Power: that is easy: the "pow(X,2)". Although that is "only" explicit as it uses the current value of X to set a gradient for the "next" X
__________________
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

 June 23, 2013, 06:21 #3 Member   Join Date: Nov 2012 Posts: 58 Rep Power: 4 Thanks! I should have imagined the second one, seems obvious now.

October 3, 2013, 06:55
#4
Member

Join Date: Jun 2011
Posts: 68
Rep Power: 6
Quote:
 Second derivative: groovyBC is based on the kind of boundary conditions OpenFOAM can impose and I'm not aware of a boundary condition that allows that directly
Hi there, Bernhard!!

I was wondering if implementing a convective bc like this:
dU/dt + Un*dU/dn = 0,
is possible by using groovy bc.

Could you help me??

Best,

October 3, 2013, 08:44
#5
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by maalan Hi there, Bernhard!! I was wondering if implementing a convective bc like this: dU/dt + Un*dU/dn = 0, is possible by using groovy bc. Could you help me?? Thanks in advance!! Best,
basically you want dU/dn (which is the definition of OF for "gradient on the boundary") as a function of the current U and dU/dt. The problem is the dU/dt. you CAN get the U from the last timestep with oldTime(U) and thus calculate it as "(U-oldTime(U))/deltaT()" but I think that during the first iteration U will be oldTime(U) (so if you have only one iteration during the time-loop the expression will degenerate to a zeroGradient. And even with more than one iteration you might get oscillations).
Also does the behaviour of oldTime depend on the solver storing the last time-step value.

You'll have to experiment
__________________
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

September 18, 2014, 18:44
#6
Member

Join Date: Jun 2011
Posts: 68
Rep Power: 6
Quote:
 basically you want dU/dn (which is the definition of OF for "gradient on the boundary") as a function of the current U and dU/dt. The problem is the dU/dt. you CAN get the U from the last timestep with oldTime(U) and thus calculate it as "(U-oldTime(U))/deltaT()" but I think that during the first iteration U will be oldTime(U) (so if you have only one iteration during the time-loop the expression will degenerate to a zeroGradient. And even with more than one iteration you might get oscillations). Also does the behaviour of oldTime depend on the solver storing the last time-step value. You'll have to experiment
Hi Bernhard!

This is what I have tried but my code blows up at the 3rd time step:

type groovyBC;
refValue uniform (1 0 0);
valueFraction uniform 0;
value uniform (1 0 0);
fractionExpression "0";

Would you know what is wrong?? It is supposed that gradientExpression calculates the field derivative normal to the domain...

Thank you!
Best!

September 23, 2014, 13:45
#7
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by maalan Hi Bernhard! This is what I have tried but my code blows up at the 3rd time step: type groovyBC; refValue uniform (1 0 0); refGradient uniform (1 0 0); valueFraction uniform 0; value uniform (1 0 0); gradientExpression "-(U-oldTime(U))/deltaT()"; fractionExpression "0"; Would you know what is wrong?? It is supposed that gradientExpression calculates the field derivative normal to the domain... Thank you! Best!
"normal to the domain": you mean "normal to the domain BOUNDARY", right? That is exactly what gradientExpression does

The problem is not groovyBC per se (it gets to the 3rd timestep) but the physics or the implementation of it. My time is limited and I limit myself to problems with swak itself.

Just some hints: check the sign, try under-relaxation, but first write out all timesteps (its only three after all) and try to figure out what goes wrong (my guess is: the BC leads to oszillations because of overcorrection)
__________________
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

 February 24, 2015, 13:26 #8 New Member   Bruno Join Date: Oct 2014 Posts: 2 Rep Power: 0 Hello maalan! Have you managed to make the BC work? I've tryied the one that you wrote and my code also blows up on the third time step! I'm new to OF so I have no ideia how to fix it Thank you

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Andrew Garrard FLUENT 9 September 21, 2015 09:15 maka OpenFOAM Pre-Processing 1 November 8, 2007 16:04 Vishal FLUENT 0 May 25, 2006 06:54 Andrea CFX 2 October 11, 2004 05:12 Thomas Wolfanger Main CFD Forum 1 June 29, 1999 11:00

All times are GMT -4. The time now is 06:40.