# Boundary Conditions with GroovyBC, Normal Gradient

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

 May 24, 2012, 09:42 Boundary Conditions with GroovyBC, Normal Gradient #1 Member   Join Date: Mar 2012 Location: Munich, Germany Posts: 67 Rep Power: 5 Hello, I´d like to implement some boundary conditions with groovyBC, but it seems, that that doesn`t work like I think it should . Here is my problem: Without groovyBc it´s possible to implement a fixed normal gradient with boundary { type fixedGradient; gradient 100; } Now i need this expression with a dependency of a variable, computet in a step befor. So i tried boundary { type groovyBC; gradientExpression "Var-fixed"; variable "Var{boundary2}=Var2; fixed=100"; value uniform 0; } For a calculating a single value, for example for a Dirichlet boundary condition, it works. Did I make a mistake in my definition of the boundary condition? Are there any good documentations for groovyBC, where i can find such things? Best regards treima

May 24, 2012, 11:11
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by treima Hello, I´d like to implement some boundary conditions with groovyBC, but it seems, that that doesn`t work like I think it should . Here is my problem: Without groovyBc it´s possible to implement a fixed normal gradient with boundary { type fixedGradient; gradient 100; } Now i need this expression with a dependency of a variable, computet in a step befor. So i tried boundary { type groovyBC; gradientExpression "Var-fixed"; variable "Var{boundary2}=Var2; fixed=100"; value uniform 0; } For a calculating a single value, for example for a Dirichlet boundary condition, it works.
What you're missing is
Code:
`fractionExpression "0";`
to make it a Neumann condition. See http://openfoamwiki.net/index.php/Contrib_groovyBC

Quote:
 Originally Posted by treima Did I make a mistake in my definition of the boundary condition? Are there any good documentations for groovyBC, where i can find such things?
Good documentation? I'm offended . The above link plus the presentations that are linked from the swak4Foam-page provide an unfoamy amount of information (I'm sure people are laughing behind my back)

No seriously. I've started writing a document that summarizes the most important concepts of swak4Foam. But don't hold your breath. If we're lucky I will have a first version before the end of the Mayan calendar (otherwise the world will end ...)

 May 30, 2012, 08:41 #3 Member   Join Date: Mar 2012 Location: Munich, Germany Posts: 67 Rep Power: 5 Thanks for your answer, it works perfect. I have another question on boundary conditions with groovyBC. Is it possible to make this location-dependent? Is here pos().x right? For example, if I´m having a look at a twodimensional geometry: boundary { type groovyBC; gradientExpression "Var-function"; variable "Var{boundary2}=Var2; function=pos().x^2+2*pos().x+3"; value uniform 0; fractionExpression "0"; } And if this is possible, how can I define a interval for x, e.g. x from 0 to 1?

 May 30, 2012, 09:44 #4 Member   Join Date: Mar 2012 Location: Munich, Germany Posts: 67 Rep Power: 5 I think I found a solution to my problem from above. boundary { type groovyBC; gradientExpression "Var-function"; variable "Var{boundary2}=Var2; function=pos().x*pos().x+2*pos().x+3"; value uniform 0; fractionExpression "0"; } But I´d like to expand my example Is it possible to define something like this in the boundary conditions? Var{boundary2} (x) = Var2 (x) Var2 at boundary2 is a function, which is dependent from the location. OpenFoam takes the average of the Values, but it would be nicer to have the exact values at every location. Best regards treima

May 30, 2012, 13:03
#5
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by treima I think I found a solution to my problem from above. boundary { type groovyBC; gradientExpression "Var-function"; variable "Var{boundary2}=Var2; function=pos().x*pos().x+2*pos().x+3"; value uniform 0; fractionExpression "0"; } But I´d like to expand my example Is it possible to define something like this in the boundary conditions? Var{boundary2} (x) = Var2 (x) Var2 at boundary2 is a function, which is dependent from the location. OpenFoam takes the average of the Values, but it would be nicer to have the exact values at every location. Best regards treima
What you want is patch to patch mapping, right? Sorry. For the foreseeable future groovyBC will not support this (I've discussed the technical problems elsewhere).

BUT: if you reorganize Var and Var2 as a cyclic patch you might be able to get what you want using a jump-boundary condition doing something like this
Code:
```    var
{
type            groovyBCJump;
value           uniform 0;
patchType       cyclic;
jumpExpression  "pos().x*pos().x+2*pos().x+3";
}```
Have a look at the example case Examples/test/jumpChannel for additional inspiration.

Of course you'll have to make sure that the other physical quantities can live with the cyclic

 July 27, 2012, 09:34 patch to patch mapping #6 Senior Member   Sören Join Date: Mar 2012 Posts: 102 Rep Power: 5 Hi, what do you exactly mean by "patch to patch mapping"? Right now I'm looking for a tool to map the velocity-field of one model onto the inlet of another model. Is this possible and where do I find an example? What I want to do is the following: simulate a rectangular line -> export the outflow-velocity-profile -> map this outflow-profile onto an inlet-surface.The inlet and outflow geometries are the same. I've already looked into the lid-driven-cavity tutorial but there I mapped an entire Mesh onto a finer one but what if I just want to map one surface...? Kind regards

August 1, 2012, 17:18
#7
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by despaired student Hi, what do you exactly mean by "patch to patch mapping"?
To make this clear: I was speaking of swak, not OF in general

Quote:
 Originally Posted by despaired student Right now I'm looking for a tool to map the velocity-field of one model onto the inlet of another model. Is this possible and where do I find an example? What I want to do is the following: simulate a rectangular line -> export the outflow-velocity-profile -> map this outflow-profile onto an inlet-surface.The inlet and outflow geometries are the same. I've already looked into the lid-driven-cavity tutorial but there I mapped an entire Mesh onto a finer one but what if I just want to map one surface...? Kind regards
The technology to do something like this during a simulation is there (have a look at the cht-solver and the boundary conditions used there).

If you want something like the mapFields utility but only for one boundary: could be done with the above stuff, but I'm not aware of such a utility (which doesn't mean that it doesn't exist)

September 19, 2012, 17:21
#9
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
I don't quite understand what you mean with "different" results. That the three variants above give different results (not much a surprise with 3)? Or that there are different gradients in each direction (the gradient is always defined as perpendicular to the face)

Variant 2 (the groovyBC one) should be equivalent to
Code:
```{
type             mixed;
refValue uniform 0;
valueFraction uniform 0;
}```
(it has been reported in the past that there are differences in the result to 1)
__________________
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 19, 2012, 19:37 #10 New Member   anonymous Join Date: Sep 2012 Location: Miami, USA Posts: 7 Rep Power: 4 Thank you for your help! I want to define temperature gradient exactly "-10000" on the pipe. I have tried those 3 cases that I wrote in my previous post separately. Non of them gave me the constant gradient on my pipe. I assume the gradient that I define is the magnitude of gradient normal to surface. Then why sqrt(gradTx^2+gradTy^2+gradTz^2) is so much bigger than that. I tried the Mixed BC that you suggested but still I have that problem. Isn't it because of my mesh? I used blockMesh/snappyHexMesh? Thank you again aa

September 21, 2012, 08:33
#11
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by socrates Thank you for your help! I want to define temperature gradient exactly "-10000" on the pipe. I have tried those 3 cases that I wrote in my previous post separately. Non of them gave me the constant gradient on my pipe. I assume the gradient that I define is the magnitude of gradient normal to surface. Then why sqrt(gradTx^2+gradTy^2+gradTz^2) is so much bigger than that. I tried the Mixed BC that you suggested but still I have that problem. Isn't it because of my mesh? I used blockMesh/snappyHexMesh? Thank you again aa
Don't know the setup of your problem but there are two things that make it possible for the absolute gradient to be bigger:

- you prescribe the gradient on the face. The values you're referring to are calculated in the cell center. May be bigger or smaller (that's discretization)
- you prescribe only the value of the gradient in normal direction. If for instance the normal direction of your patch is y but your model has an implicit gradient in x-direction (for instance because of two fixedValue-BCs with different values) then of course these two give a biggere absolute value

In general be more specific when asking (I don't know how it is with other people, but if I have trouble understanding what your problem actually is I loose interest). To be specific:

- how much is "much bigger than that"? 5%, 100%
- which of the four cases (fixedGradient, mixed and the two groovyBC variants) give the same results (and by how much do they differ)
__________________
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 22, 2012, 05:18
#13
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
Pictures are nice. Numbers are better. But before I even bother to look at the pictures tell me: are you looking at the cell values or at the point values in paraview? If you want to check the results always use the cell values. Because these are the values that OpenFOAM worked with and wrote. The point values are an interpretation by Paraview and may be misleading (especially on the boundary where depending on the reader and the boundary condition the BC-values may or may not be used for interpolation).
So if you're working only use cell values. The point values are only for the presentations afterwards so that the aesthets are not bother with the "steppiness" of the cells
__________________
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 22, 2012, 20:08 #14 New Member   anonymous Join Date: Sep 2012 Location: Miami, USA Posts: 7 Rep Power: 4 Hi Bernhard, I dont know exactly, but I think you are right. here is my fvSchemes: ------------------------------------------- ddtSchemes { default steadyState; } gradSchemes { default Gauss linear; grad(T) Gauss linear; } divSchemes { default none; } laplacianSchemes { default non; laplacian(DT,T) Gauss linear corrected; } interpolationSchemes { default linear; interpolate(T) linear; } snGradSchemes { default corrected; } fluxRequired { default no; T; } // ************************************************** *********************** // I use sample to get the temp. and its gradient on surfaces and patches. My sampleDic is: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // interpolationScheme cellPointFace; setFormat vtk; surfaceFormat vtk; sets (); surfaces ( maxY { type patch; patchName maxY; } minY { type patch; patchName minY; } ); fields ( T gradTy ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // sample results are same as paraFoam. How can I make sure my results are correct? gradSchemes is based on cell enter value. Thank you aa

 December 11, 2012, 15:54 Similar thing #15 New Member   Peter Benovsky Join Date: Jun 2011 Posts: 5 Rep Power: 6 Hi, I would like to have something like timeVaryingFixedGradient. The first thought was to use the groovyBC. The problem is when I do this in the T dictionary boundary(running buoyantPimpleFoam): Code: ```heater { type groovyBC; value uniform 300; valueExpression "300"; gradientExpression "gradT*time()"; fractionExpression "0"; variables "heatFlux=6700;alpha=0.02;gradT=heatFlux/(alpha+alphat)"; }``` then I get floating point exception. If I change fractionExpression "1"; I still get the floating point exception. Now, the interesting bit is that if I use fixedValue or fixed gradient everything runs OK. I wonder where do I try to divide by 0? To check whether swak installed properly I ran some of the examples and there everything works. In my controlDict I have included "libOpenFOAM.so" "libgroovyBC.so" "libgroovyStandardBCs.so". Any ideas where could I have messed up? Cheers Peter

December 11, 2012, 16:10
#16
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by Peter Benovsky Hi, I would like to have something like timeVaryingFixedGradient. The first thought was to use the groovyBC. The problem is when I do this in the T dictionary boundary(running buoyantPimpleFoam): Code: ```heater { type groovyBC; value uniform 300; valueExpression "300"; gradientExpression "gradT*time()"; fractionExpression "0"; variables "heatFlux=6700;alpha=0.02;gradT=heatFlux/(alpha+alphat)"; }``` then I get floating point exception. If I change fractionExpression "1"; I still get the floating point exception. Now, the interesting bit is that if I use fixedValue or fixed gradient everything runs OK. I wonder where do I try to divide by 0? To check whether swak installed properly I ran some of the examples and there everything works. In my controlDict I have included "libOpenFOAM.so" "libgroovyBC.so" "libgroovyStandardBCs.so". Any ideas where could I have messed up? Cheers Peter
I'm afraid that is a bug that showed up a number of times in the last weeks and already is fixed in the development-branch: as a workaround set

refValue uniform 300;

This will only be used during startup (you didn't try to divide by 0. The thermoPhysics-library did with a value that was accidentally set to 0 because the expressions can't be evaluated before all the fields are loaded)
__________________
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

December 11, 2012, 18:53
#17
New Member

Peter Benovsky
Join Date: Jun 2011
Posts: 5
Rep Power: 6
Quote:
 Originally Posted by gschaider I'm afraid that is a bug that showed up a number of times in the last weeks and already is fixed in the development-branch: as a workaround set refValue uniform 300; This will only be used during startup (you didn't try to divide by 0. The thermoPhysics-library did with a value that was accidentally set to 0 because the expressions can't be evaluated before all the fields are loaded)
Thank you very much, Bernhard!
That works, and sorry for the duplicity if it is already mentioned elsewhere.

Bye
Peter

December 12, 2012, 13:24
#18
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by Peter Benovsky Thank you very much, Bernhard! That works, and sorry for the duplicity if it is already mentioned elsewhere.
In this case: no problem about the duplicity. It's hard to spot that it is the same bug if you don't know what is going on (you can't say that about all the bug reports I get here)
__________________
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

December 14, 2012, 04:04
#19
New Member

Peter Benovsky
Join Date: Jun 2011
Posts: 5
Rep Power: 6
Quote:
 Originally Posted by gschaider In this case: no problem about the duplicity. It's hard to spot that it is the same bug if you don't know what is going on (you can't say that about all the bug reports I get here)
Btw. I have noticed, that when using alphatWallFunction and groovyBC, alphat is not evaluated at the patch where groovy is applied. Value uniform=0; is there instead.
Is it the same bug, perhaps?

Peter

December 14, 2012, 05:28
#20
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
Quote:
 Originally Posted by Peter Benovsky Btw. I have noticed, that when using alphatWallFunction and groovyBC, alphat is not evaluated at the patch where groovy is applied. Value uniform=0; is there instead. Is it the same bug, perhaps? Peter
You can only have one BC on a patch at a time. Have you made sure that groovyBC is actually evaluated on that patch (for instance by introducing a syntactic error into an expression - if it fails it's evaluated)

BTW: which version of OF?
__________________
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

 Tags boundary, condition, gradient, groovybc, normal

 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 Attesz CFX 7 January 5, 2013 04:32 benk Main CFD Forum 3 December 28, 2010 06:09 Pankaj CFX 9 November 23, 2009 05:05 mactech001 CFX 6 November 15, 2009 22:25

All times are GMT -4. The time now is 00:49.