CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   groovyBC for pressureInlet (http://www.cfd-online.com/Forums/openfoam-solving/94714-groovybc-pressureinlet.html)

Nico A. November 23, 2011 09:39

groovyBC for pressureInlet
 
Hello,

I got a two phase flow in a plate with two inlets. The second inlet should open at a specified time like:
Code:

inlet
 {
 type            totalPressure;
        p0              uniform 100000;
        U              U;
        phi            phi;
        rho            rho;
        psi            none;
        gamma          1;
        value          uniform 0;
 }
 inlet2
 {
 type                groovyBC;
 valueExpression  "(time()<t0) ? 0 : 1*(pinlet)";          //zeroGradient for time()<t0 (wall), constant value for time()>t0 (pressureInlet)
 variables            "t0=0.1;pinlet@inlet=p;p=100000;";
 value uniform      100000;
 }
 outlet
 {
  type fixedValue;
  value uniform 0.000000;
 }
 outlet2
 {
  type fixedValue;
  value uniform 0.000000;
 }
 
 wall
 {
  type zeroGradient;
 }
 frontback
 {
  type empty;
 }

This case works fine. Now I want to open inlet2 depending on a field value like pressure, alpha volume fraction etc. Is that possible in some way? Thanks for any advice.

Kind regards, Nico

gschaider November 23, 2011 14:59

Quote:

Originally Posted by Nico A. (Post 333278)
Hello,

I got a two phase flow in a plate with two inlets. The second inlet should open at a specified time like:
Code:

inlet
 {
 type            totalPressure;
        p0              uniform 100000;
        U              U;
        phi            phi;
        rho            rho;
        psi            none;
        gamma          1;
        value          uniform 0;
 }
 inlet2
 {
 type                groovyBC;
 valueExpression  "(time()<t0) ? 0 : 1*(pinlet)";          //zeroGradient for time()<t0 (wall), constant value for time()>t0 (pressureInlet)
 variables            "t0=0.1;pinlet@inlet=p;p=100000;";
 value uniform      100000;
 }
 outlet
 {
  type fixedValue;
  value uniform 0.000000;
 }
 outlet2
 {
  type fixedValue;
  value uniform 0.000000;
 }
 
 wall
 {
  type zeroGradient;
 }
 frontback
 {
  type empty;
 }

This case works fine. Now I want to open inlet2 depending on a field value like pressure, alpha volume fraction etc. Is that possible in some way? Thanks for any advice.

Kind regards, Nico

a) from the syntax I see that you're using oldSchool-standalone-groovyBC. Just a remark. If it is sufficient for you, fine

b) I think your comment with inlet2 is incorrect. To get that kind of behaviour you should manipulate fractionExpression

c) I don't see the problem with dependence of fields. Instead of the time-condition "time()<t0" write something like "max(pInlet)>pThres" and off you go (to have a "valve" that stays open once the condition is reached - even if the pressure drops afterwards - you'll need the stored variables in the swak-veriosn of groovBC)

Nico A. November 24, 2011 09:53

Hello Bernhard,
at first, thank you for your reply. Sorry, I posted the wrong code, I actually used that for inlet2, like you already said:
Code:

inlet2
{      type groovyBC;
        valueExpression "1*(pinlet)";
        fractionExpression "(time()<t0) ? 0 : 1";
        variables      "t0=0.1;pinlet@inlet=p;p=100000;";
        timelines      ( )
}

re a) up to now the oldSchool-groovyBC was sufficient for me, but for the next tasks I am not sure.

re c) the problem is that I can only adress the whole field, is that right? I need to extract a specific value of the field, for example a face value at the inlet patch.

gschaider November 24, 2011 18:07

Quote:

Originally Posted by Nico A. (Post 333431)
Hello Bernhard,
at first, thank you for your reply. Sorry, I posted the wrong code, I actually used that for inlet2, like you already said:
Code:

inlet2
{      type groovyBC;
        valueExpression "1*(pinlet)";
        fractionExpression "(time()<t0) ? 0 : 1";
        variables      "t0=0.1;pinlet@inlet=p;p=100000;";
        timelines      ( )
}

re a) up to now the oldSchool-groovyBC was sufficient for me, but for the next tasks I am not sure.

re c) the problem is that I can only adress the whole field, is that right? I need to extract a specific value of the field, for example a face value at the inlet patch.

Just one face should represent the whole inlet instead of (for instance) the average of all the faces on the patch? That's not really what groovyBC was built for, but something like (untested so there may be syntactic problems may be there):

"targetPos=vector(1,2,3);dist=mag(targetPos-pos());minDist=min(dist);pTemp=(dist==minDist) ? p : -1;pUsed=max(pTemp)"

should work.

Hold on.

That won't work exactly like this because as soon as a remote variable is used it is boiled down to a single value. But what should work is

"pUsed@inlet2= ...."

The right hand side you get by substituting the other variables in the expression of the above "recipie". Will be a bit larger, but I guess you get the idea

PS: the "1*(pinlet)" above is necessary? Hopefully not anymore in the swak-Variant of groovy


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