CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] groovyBC for coupling of patches

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 16, 2010, 07:32
Default groovyBC for coupling of patches
  #1
Member
 
Nico T
Join Date: Aug 2010
Location: Leipzig, Germany
Posts: 39
Rep Power: 16
deniggo is on a distinguished road
Hello,

I would like to use groovyBC for a periodic inlet/outlet. I tried the tutorial 4.2.3 on http://openfoamwiki.net/index.php/Contrib_groovyBC. In 0/U phi is taken into account and not U directly. So, I modified the BC to:

Code:
inlet
    {
      type                         groovyBC;
      variables                   "Uoutlet@outlet=-1*sum(U);";
      valueExpression        "Uoutlet/sum(mag(Sf()))*normal()";
      fractionExpression     "1"
      value                         $internalField;
}
outlet
    {
        type zeroGradient;
    }
But this error occurs: The expected return type vector is different from the stored result type "tensor".
I guess there's something wrong concerning the definition of U=vector and phi.

What do I have to change to get the bc running?

Thanks for your help,

Nico
deniggo is offline   Reply With Quote

Old   December 16, 2010, 09:13
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by deniggo View Post
Hello,

I would like to use groovyBC for a periodic inlet/outlet. I tried the tutorial 4.2.3 on http://openfoamwiki.net/index.php/Contrib_groovyBC. In 0/U phi is taken into account and not U directly. So, I modified the BC to:

Code:
inlet
    {
      type                         groovyBC;
      variables                   "Uoutlet@outlet=-1*sum(U);";
      valueExpression        "Uoutlet/sum(mag(Sf()))*normal()";
      fractionExpression     "1"
      value                         $internalField;
}
outlet
    {
        type zeroGradient;
    }
But this error occurs: The expected return type vector is different from the stored result type "tensor".
I guess there's something wrong concerning the definition of U=vector and phi.

What do I have to change to get the bc running?

Thanks for your help,

Nico
The problem is that Uoutlet is a vector and normal() is a vector. By convention in OF * is an _outer_ product thus yielding a tensor. Concerning phi have a look at http://openfoamwiki.net/index.php/Ma...ver_is_writing (I guess it is a much better choice as it takes the face sizes into account sum(U) depends on the number of faces the outlet has

Bernhard
gschaider is offline   Reply With Quote

Old   December 22, 2010, 01:09
Default
  #3
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
groovyBC+cyclic patch
hi foamer
i have used groovy BC as cyclic patch but i encounter following warning :

FOAM Warning :
From function PatchResult::getUniformInternal(const label size,bool noWarn)
in file PatchResultI.H at line 96
The minimum value -30172 and the maximum 10751.6 differ. I will use the average -22562.9
any one knows whats the problem here ?

i have an axiymetric tube with one inlet and one outlet as pressure and tempreture are not cyclic
i cant use cyclic boundary condition, another suggestion was direct map boundary condition but it was useless too!!!
any suggestion? i want something that work exactly like cyclic boundary condition but i also can change boundary condition for T too?

P.S.

inlet ----------------------------outlet

---------------------------------------
BC :
U,alpha are cyclic
P are cyclic with pressure jump (pressure gradient is fixed)
(dT/dx)inlet = -(dT/dx)outlet
Luttappy likes this.
nimasam is offline   Reply With Quote

Old   December 22, 2010, 05:46
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by nimasam View Post
groovyBC+cyclic patch
hi foamer
i have used groovy BC as cyclic patch but i encounter following warning :

FOAM Warning :
From function PatchResult::getUniformInternal(const label size,bool noWarn)
in file PatchResultI.H at line 96
The minimum value -30172 and the maximum 10751.6 differ. I will use the average -22562.9
any one knows whats the problem here ?

i have an axiymetric tube with one inlet and one outlet as pressure and tempreture are not cyclic
i cant use cyclic boundary condition, another suggestion was direct map boundary condition but it was useless too!!!
any suggestion? i want something that work exactly like cyclic boundary condition but i also can change boundary condition for T too?

P.S.

inlet ----------------------------outlet

---------------------------------------
BC :
U,alpha are cyclic
P are cyclic with pressure jump (pressure gradient is fixed)
(dT/dx)inlet = -(dT/dx)outlet
See the last paragraph in http://openfoamwiki.net/index.php/Co..._other_patches
("It is very important to note, that no form of patch-to-patch interpolation of the fields is performed"). This is what the warning is trying to say "I can not emulate a cylic, I only pass averages"

So I'm afraid groovyBC can not do what you want to do (I never said that it doesn't have limitations)

Bernhard
gschaider is offline   Reply With Quote

Old   December 22, 2010, 23:24
Default
  #5
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
hi bernard
as my input and output face and cell are the same i only want a direct map of out let into inlet for u and alpha as the first step so i did:
inlet
{
type groovyBC;
variables "alphaOutlet@outlet=alpha1;";
valueExpression "alphaOutlet";
value $internalField;

}

outlet
{
type zeroGradient;
}
but i encounter previous warning, is not possible to do this action with groovyBC?
nimasam is offline   Reply With Quote

Old   December 23, 2010, 10:37
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by nimasam View Post
hi bernard
as my input and output face and cell are the same i only want a direct map of out let into inlet for u and alpha as the first step so i did:
inlet
{
type groovyBC;
variables "alphaOutlet@outlet=alpha1;";
valueExpression "alphaOutlet";
value $internalField;

}

outlet
{
type zeroGradient;
}
but i encounter previous warning, is not possible to do this action with groovyBC?
I considered it, but refrained from doing so, because if even both patches of the same size it is not guaranteed that the faces are in the same order or worse, it is not guaranteed that they are in face of the same size and that each cell has a peer on the other patch. So if the data would be silently copied from one patch to the other this could lead to unpredictable (==wrong) results so these things would have to be checked for (nothing worse than a program that silently does the wrong thing) which is enough work in serial, not to speak in parallel. Maybe the directMapped-machinery could be employed for this but currently I have no plans for this (I'm sorry: the way new features get added to the stuff I publish are a) they are trivial b) I need them c) a client needs them. Sounds harsh, but I've only got limited time, too)

Bernhard
gschaider is offline   Reply With Quote

Old   May 7, 2012, 10:54
Default
  #7
Member
 
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 15
latvietis is on a distinguished road
I have a question about this warning.

What does it actually warn me about?

Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResultI.H at line 158
    The minimum value (-0.000616714 -0.000208414 0) and the maximum (0.000596458 0.000472639 0) differ. I will use the average (-6.37906e-07 6.94849e-05 0)
Where this minimum and maximum value can be found and from where it actually is calculated?

BC looks like this:

Code:
    rod1
    {
        type            groovyBC;
    variables       "A_rod1a{rod1a}=A;";
    valueExpression "A_rod1a";
    value           $internalField;
    }
    rod1a
    {
    type        zeroGradient;
    }
latvietis is offline   Reply With Quote

Old   May 7, 2012, 15:33
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by latvietis View Post
I have a question about this warning.

What does it actually warn me about?

Code:
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResultI.H at line 158
    The minimum value (-0.000616714 -0.000208414 0) and the maximum (0.000596458 0.000472639 0) differ. I will use the average (-6.37906e-07 6.94849e-05 0)
Where this minimum and maximum value can be found and from where it actually is calculated?

BC looks like this:

Code:
    rod1
    {
        type            groovyBC;
    variables       "A_rod1a{rod1a}=A;";
    valueExpression "A_rod1a";
    value           $internalField;
    }
    rod1a
    {
    type        zeroGradient;
    }
If a variable from another entity (in your case a patch) is used groovyBC allows only a single value. The reason is that in the general case it is not obvious how different values should be mapped (for instance for patches of different sizes). If the variable you specify is not a single value then the above warning is issued and the average value is calculated and used. So basically the result of your expression is equivalent to

"A_rod1a{rod1a}=average(A);"

If you need to transfer inhomogenous values then you should consider creating patches as cyclics and either use one of the stock BCs that come with OF or groovyBCJump
gschaider is offline   Reply With Quote

Old   May 20, 2012, 12:45
Default
  #9
Member
 
Martin
Join Date: Dec 2011
Location: Latvia
Posts: 54
Rep Power: 15
latvietis is on a distinguished road
Problem is that there is no simple tutorial how to do this and my skills are so low...

How this groovyBCJump is working? Any example for this?
latvietis is offline   Reply With Quote

Old   May 20, 2012, 18:38
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by latvietis View Post
Problem is that there is no simple tutorial how to do this and my skills are so low...

How this groovyBCJump is working? Any example for this?
It is basically the regular jump-BC but the jumpValue is calculated from an expression. A small demo-case comes with swak under Examples/tests/jumpChannel
Luttappy likes this.
gschaider is offline   Reply With Quote

Old   March 11, 2013, 18:04
Default Working with groovyBC jump
  #11
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 14
mcdonalds is on a distinguished road
Hi Bernhard,

I looked at some documentation on groovybcjump and it may be what I need. It says this:
HTML Code:
**** Boundary condition =groovyBCJump=     Boundary condition that imposes a jump in the value on a cyclic     boundary condition pair (based on =jumpCyclic=). Only works for     scalar values
Now let's say I want to make the value of both cyclic boundaries zero. What would I need to put into the boundaryfile folder?

Right now I have this:

HTML Code:
    bottomcathode
    {
        type            groovyBCJump;
        patchType       cyclic;
        jumpExpression  "0";
        value           uniform 0;
    }
Sincerely,

Benjamin
the_ichthyologist likes this.
mcdonalds is offline   Reply With Quote

Old   March 11, 2013, 18:23
Default
  #12
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mcdonalds View Post
Hi Bernhard,

I looked at some documentation on groovybcjump and it may be what I need. It says this:
HTML Code:
**** Boundary condition =groovyBCJump=     Boundary condition that imposes a jump in the value on a cyclic     boundary condition pair (based on =jumpCyclic=). Only works for     scalar values
Now let's say I want to make the value of both cyclic boundaries zero. What would I need to put into the boundaryfile folder?

Right now I have this:

HTML Code:
    bottomcathode
    {
        type            groovyBCJump;
        patchType       cyclic;
        jumpExpression  "0";
        value           uniform 0;
    }
Sincerely,

Benjamin
Jump means that if one side has the value p1 and you specify a jump deltaP then the other side will have a value p2=p1+deltaT. Seeting the jump value to 0 should give you p1==p2
__________________
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 offline   Reply With Quote

Old   March 11, 2013, 19:20
Default
  #13
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 14
mcdonalds is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Jump means that if one side has the value p1 and you specify a jump deltaP then the other side will have a value p2=p1+deltaT. Seeting the jump value to 0 should give you p1==p2
Ok, that makes sense. What if I wanted to make a zero flux on both cyclic boundary patches. Anyway to do that? Also, when I assign cyclic am I restricted to only using groovyBCjump or can I use the plethora of groovybc types, including groovybc itself?
the_ichthyologist likes this.
mcdonalds is offline   Reply With Quote

Old   March 12, 2013, 11:11
Default
  #14
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mcdonalds View Post
Ok, that makes sense. What if I wanted to make a zero flux on both cyclic boundary patches. Anyway to do that? Also, when I assign cyclic am I restricted to only using groovyBCjump or can I use the plethora of groovybc types, including groovybc itself?
The reason why you're not making them walls is because all other quantities should be transported across in a "cyclic" way? Problem is that if the patch is cyclic you can't set a "fixedValue" there. Would have to play around with it myself, but I think one way to go would be to make the patches "mapped", set U with fixedValue and "transport" the other stuff by using the mapped functionality
the_ichthyologist likes this.
__________________
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 offline   Reply With Quote

Old   March 20, 2013, 18:30
Default Almost there!
  #15
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 14
mcdonalds is on a distinguished road
Quote:
Originally Posted by gschaider View Post
The reason why you're not making them walls is because all other quantities should be transported across in a "cyclic" way? Problem is that if the patch is cyclic you can't set a "fixedValue" there. Would have to play around with it myself, but I think one way to go would be to make the patches "mapped", set U with fixedValue and "transport" the other stuff by using the mapped functionality
Hi Bernhard,

So I was able to map patches for one field doing what you said and create a fixedValue for another field. Good news is I am getting the same results as when I used groovyBC, and without the warning message to boot. Bad news is is that they are still incorrect results. What I should be getting is a linear curve (I run plot over line in paraview on the y-axis and just look at my H2O scalarField), but I get linear up to my boundary and then parabolic afterwards. Is there anyway I can get linear throughout the whole domain, like it should be? (Actually if you look at H2 it has a linear result, as it should)

I have attached my case file and my solver. They are very basic. I just run blockMesh, waterFoam2 and paraFoam to view it.

Hopefully, you can take a quick look to see if is possible to get a linear curve.

Sincerely,

Benjamin
Attached Files
File Type: gz Waterman5.tar.gz (5.6 KB, 19 views)
File Type: gz waterFoam2.tar.gz (3.2 KB, 15 views)

Last edited by mcdonalds; March 20, 2013 at 19:09.
mcdonalds is offline   Reply With Quote

Old   March 21, 2013, 08:25
Default
  #16
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mcdonalds View Post
Hi Bernhard,

So I was able to map patches for one field doing what you said and create a fixedValue for another field. Good news is I am getting the same results as when I used groovyBC, and without the warning message to boot. Bad news is is that they are still incorrect results. What I should be getting is a linear curve (I run plot over line in paraview on the y-axis and just look at my H2O scalarField), but I get linear up to my boundary and then parabolic afterwards. Is there anyway I can get linear throughout the whole domain, like it should be? (Actually if you look at H2 it has a linear result, as it should)

I have attached my case file and my solver. They are very basic. I just run blockMesh, waterFoam2 and paraFoam to view it.

Hopefully, you can take a quick look to see if is possible to get a linear curve.
Don't hold your breath as I won't have time to look at it this week.

Also: this is more about the physics than swak, right? Because the value on the jump is right, the problem occurs on the interior (where the solver is responsible), right? Only thing I can suggest without having looked at the stuff is to check the BC on "the other side" of the parabola
__________________
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 offline   Reply With Quote

Old   March 28, 2013, 14:41
Default Linear function and integral
  #17
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 14
mcdonalds is on a distinguished road
Hi Bernhard,

I have a two real quick questions about openfoam.

1) I'd like to create a variable, let's say D and make it a function of y. So something like D=5y+6. Is this possible in openFoam?

2) I'd like to integrate over a length in the y-direction. I was going to put my field (let's say jbv) in my time step and use the += function to sum up. However, I would have to also multiply by the size of the cell along the y-direction at each time step (They are uniform in my model). Do you know how to reference the length of the cell in the y-direction?

It would look something like this: P += jbv*dy (where dy is the length of the cell in the y-direction)

Sincerely,

Benjamin
mcdonalds is offline   Reply With Quote

Old   March 29, 2013, 04:45
Default
  #18
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mcdonalds View Post
Hi Bernhard,

I have a two real quick questions about openfoam.
Really OpenFOAM? Because then the thread is a bit inappropriate
Quote:
Originally Posted by mcdonalds View Post
1) I'd like to create a variable, let's say D and make it a function of y. So something like D=5y+6. Is this possible in openFoam?
The quick answer is: Of course it is
The long answer is: You're very vague. What is the context? What are you using D for? With y do you mean what? The position?
Quote:
Originally Posted by mcdonalds View Post
2) I'd like to integrate over a length in the y-direction. I was going to put my field (let's say jbv) in my time step and use the += function to sum up. However, I would have to also multiply by the size of the cell along the y-direction at each time step (They are uniform in my model). Do you know how to reference the length of the cell in the y-direction?

It would look something like this: P += jbv*dy (where dy is the length of the cell in the y-direction)
You could get the points of the cell and calc the maximum nīminus the minimum y of those
__________________
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 offline   Reply With Quote

Old   October 2, 2014, 03:32
Wink How to use groovyBCJump?
  #19
Member
 
Charlie
Join Date: Dec 2010
Location: USA
Posts: 85
Rep Power: 16
cheng1988sjtu is on a distinguished road
I see the example case in Example/tests/jumpChannel/ in the release of swak4Foam.

I tried to understand how they define the pressure jump, because in the example files, they define two jumps, jump1 and jump2 by the following lines:

Quote:
faceSet jump1 new expressionToFace "pos().x>0.3"
faceSet jump2 new expressionToFace "pos().x>0.6"
and they define two different jumps in the 0 files.

So this means that each jump (jump1 and jump2) defines two faces with a pressure difference on the faces, but how do they define the two faces by simply one line, for example, for jump1:

Quote:
faceSet jump1 new expressionToFace "pos().x>0.3"
Now, after I get to understand how to use groovyBCJump, What if I want to define a pressure jump between inlet and outlet? In my case, the inlet and outlet are cyclic, but I want to define a pressure difference between these two faces.

My domain size is (0 0 -0.001) to (0.22 0.3 0.001)

so should I define the jump faces as:

Quote:
faceSet jump1 new expressionToFace "pos().x>=0"
But after I do this, I'll get the following information:

Quote:
mesh not changed.
Reading commands from file "makeFaceSet.setSet"
Please type 'help', 'quit' or a set command after prompt.
Doing:"faceSet jump1 new expressionToFace \"pos().x>=0\""
Set:jump1 Size:0 Action:new
Adding all elements of for which "pos().x>=0" evaluates to true ...
Expression "pos().x>=0" evaluates to cellValue: using boundary
Writing jump1 (size 0) to "constant/polyMesh/sets/jump1" and to vtk file "VTK/jump1/jump1_0.vtk"

This means that I defined 0 faces as a result!!! But Why??? If somebody can help me to understand this, I will really appreciate them!!!

Quote:
Originally Posted by gschaider View Post
Jump means that if one side has the value p1 and you specify a jump deltaP then the other side will have a value p2=p1+deltaT. Seeting the jump value to 0 should give you p1==p2
cheng1988sjtu is offline   Reply With Quote

Old   October 2, 2014, 11:49
Default
  #20
Member
 
Charlie
Join Date: Dec 2010
Location: USA
Posts: 85
Rep Power: 16
cheng1988sjtu is on a distinguished road
OK, It's a silly question here, I know how to specify the pressure difference between two cyclic BC now. It turns out that the purpose of using faceSet is to cut the domain to get two cut faces, and it's not necessary for my case, I just need to use groovyBCJump directly on my cyclic BC.

Hope this is useful for other first users of groovyBCJump, like me. :-)

Quote:
Originally Posted by cheng1988sjtu View Post
I see the example case in Example/tests/jumpChannel/ in the release of swak4Foam.

I tried to understand how they define the pressure jump, because in the example files, they define two jumps, jump1 and jump2 by the following lines:



and they define two different jumps in the 0 files.

So this means that each jump (jump1 and jump2) defines two faces with a pressure difference on the faces, but how do they define the two faces by simply one line, for example, for jump1:



Now, after I get to understand how to use groovyBCJump, What if I want to define a pressure jump between inlet and outlet? In my case, the inlet and outlet are cyclic, but I want to define a pressure difference between these two faces.

My domain size is (0 0 -0.001) to (0.22 0.3 0.001)

so should I define the jump faces as:



But after I do this, I'll get the following information:




This means that I defined 0 faces as a result!!! But Why??? If somebody can help me to understand this, I will really appreciate them!!!
cheng1988sjtu 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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 92 May 21, 2024 08:56
Possible bug with stitchMesh and cyclics in OpenFoam Jack001 OpenFOAM Pre-Processing 0 May 21, 2016 09:00
[blockMesh] Merging edge patches Yosmcer OpenFOAM Meshing & Mesh Conversion 11 November 16, 2014 15:51
Cyclic boundaries in OF 21x morard OpenFOAM 25 May 13, 2013 23:35
[swak4Foam] some questions about neibours of patches in groovyBC immortality OpenFOAM Community Contributions 7 March 3, 2013 12:38


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