CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   OF/groovyBC: 2nd derivative or power BC (https://www.cfd-online.com/Forums/openfoam-pre-processing/119654-groovybc-2nd-derivative-power-bc.html)

startingWithCFD June 21, 2013 03:24

OF/groovyBC: 2nd derivative or power BC
 
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?

gschaider June 23, 2013 05:25

Quote:

Originally Posted by startingWithCFD (Post 435200)
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

startingWithCFD June 23, 2013 06:21

Thanks! I should have imagined the second one, seems obvious now.

maalan October 3, 2013 06:55

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??

Thanks in advance!!
Best,

gschaider October 3, 2013 08:44

Quote:

Originally Posted by maalan (Post 454847)
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

maalan September 18, 2014 18:44

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);
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!

gschaider September 23, 2014 13:45

Quote:

Originally Posted by maalan (Post 510866)
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)

brunotessa February 24, 2015 12:26

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 :confused:

Thank you


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