CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   groovyBC for coupling of patches (https://www.cfd-online.com/Forums/openfoam-solving/83163-groovybc-coupling-patches.html)

deniggo December 16, 2010 07:32

groovyBC for coupling of patches
 
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

gschaider December 16, 2010 09:13

Quote:

Originally Posted by deniggo (Post 287652)
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

nimasam December 22, 2010 01:09

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

gschaider December 22, 2010 05:46

Quote:

Originally Posted by nimasam (Post 288061)
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

nimasam December 22, 2010 23:24

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?

gschaider December 23, 2010 10:37

Quote:

Originally Posted by nimasam (Post 288217)
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

latvietis May 7, 2012 09:54

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;
    }


gschaider May 7, 2012 14:33

Quote:

Originally Posted by latvietis (Post 359747)
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

latvietis May 20, 2012 11:45

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?

gschaider May 20, 2012 17:38

Quote:

Originally Posted by latvietis (Post 362061)
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

mcdonalds March 11, 2013 18:04

Working with groovyBC jump
 
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

gschaider March 11, 2013 18:23

Quote:

Originally Posted by mcdonalds (Post 413245)
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

mcdonalds March 11, 2013 19:20

Quote:

Originally Posted by gschaider (Post 413253)
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?

gschaider March 12, 2013 11:11

Quote:

Originally Posted by mcdonalds (Post 413262)
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

mcdonalds March 20, 2013 18:30

Almost there!
 
2 Attachment(s)
Quote:

Originally Posted by gschaider (Post 413465)
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

gschaider March 21, 2013 08:25

Quote:

Originally Posted by mcdonalds (Post 415373)
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

mcdonalds March 28, 2013 14:41

Linear function and integral
 
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

gschaider March 29, 2013 04:45

Quote:

Originally Posted by mcdonalds (Post 417057)
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 (Post 417057)
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 (Post 417057)
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

cheng1988sjtu October 2, 2014 02:32

How to use groovyBCJump?
 
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 (Post 413253)
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 October 2, 2014 10:49

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 (Post 512651)
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!!!



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