CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   boundaries and patches (http://www.cfd-online.com/Forums/openfoam/74043-boundaries-patches.html)

piprus March 23, 2010 08:36

boundaries and patches
 
Hi all,

I have some questions concerning patches in OpenFOAM.

Is it possible to define a patch which allows the medium (gas, liquid... doesn't matter) to pass through this patch only when the pressure of that medium reaches a certain level, but when the pressure decreases below that certain limit in the time of simulation the patch behaves like a wall again? Of course I would like to prevent either a back flow with this model. Roughly speaking is it possible to model a simple check valve?

The other question is. Is there a type of inlet patch in which I could set up decreasing/increasing flow due to a change of a pressure against time?

kev4573 March 23, 2010 10:40

Yes, you could probably do both of those with groovyBC fairly easily.

gschaider March 23, 2010 12:34

Quote:

Originally Posted by kev4573 (Post 251273)
Yes, you could probably do both of those with groovyBC fairly easily.

First one: yes. Second one only if there is already a field that holds dp/dt (groovy doesn't calculate time derivatives)

Bernhard

piprus March 23, 2010 13:06

If you say groovyBC, then ok, but I would appreciate some help from expirienced users of this tool like you :) I need some more information.

I will focus now on the first idea - the checkValve case:

First of all, in a boundary file I have an 'outlet' which is of type patch, like below:

Code:

    outlet
    {
        type            patch; ....

and which suppose to be a wall for the most time, since the pressure is lower than my assumed value (let say 7e6). My question is, should I keep it as it is or change it to a wall-type (so the groovy could change it later)?

I have a quite simple case, so I'm using only p, U and alpha1 fields in it. Since the outlet now is open those fields are defined in following manner:

Code:

alpha1
outlet
{
        type        inletOutlet;
        inletValue    uniform 0;
        value        uniform 0;
}

Code:

p
outlet
{
    type    fixedValue;
    value    uniform 1e5;
}

Code:

U
outlet
{
        type            pressureInletOutletVelocity;
        value          uniform (0 0 0);
}

How should I change them, assuming that those conditions are valid only when the patch is 'open' for a medium due to its high pressure (over 7e6)?

piprus March 23, 2010 13:22

Quote:

Originally Posted by piprus (Post 251299)
My question is, should I keep it as it is or change it to a wall-type (so the groovy could change it later)?

Ok, I feel I wrote something entirely stupid :D It's obvious that it has to stay as a patch.... Sorry for that I'm just confused!!

kev4573 March 25, 2010 12:26

You would change all those boundary conditions to use groovyBC, and then write the expressions. You'd probably use the ? : operators to get your check valve operating correctly. Something like p < 7e6 ? closedValue : openValue . If you formulate the expressions right you should be able to create the inletOutlet bc's you need.

piprus March 25, 2010 13:06

Quote:

Originally Posted by kev4573 (Post 251647)
You would change all those boundary conditions to use groovyBC, and then write the expressions. You'd probably use the ? : operators to get your check valve operating correctly. Something like p < 7e6 ? closedValue : openValue . If you formulate the expressions right you should be able to create the inletOutlet bc's you need.

This is actually what I expected from groovy... I was thinking about that in this way, so I tried to write something like this:

Code:

alpha1
outlet
{
 type goovyBC;
 valueExpression "p > 7e6 ? (uniform 0) : (zeroGradient)";
}

But this won't work and I didn't really expect it will run in this form :P that's why I'm still asking. I'm so eager to know how to use it though.

Normally when I run the simulation and I want to change the conditions I just stop the process and rerun from the last step under new conditions. But this approach is not really accurate and BTW time consuming when you running in parallel more than one simulation at that time.

But what I was doing by hand was to set up the close-conditions for the outlet in order to allow the system to reach the over pressure level. So it looked like a wall more or less at the beginning:

Code:

    outlet
    {
        type            zeroGradient;
    }

and later like an outlet:

Code:

outlet
    {
        type        inletOutlet;
        inletValue    uniform 0;
        value        uniform 0;
    }

This is of course just an alpha case, but I understand I have to rewrite all of the field-files.

I'm sure it can't be so difficult to apply this tool in my case, but I'm a bit green here.

Thanks for all of the advices you have already given and for all of those that will show up here later, of course hopefully soon :)

gschaider March 25, 2010 13:42

Quote:

Originally Posted by piprus (Post 251662)
This is actually what I expected from groovy... I was thinking about that in this way, so I tried to write something like this:

Code:

alpha1
outlet
{
 type goovyBC;
 valueExpression "p > 7e6 ? (uniform 0) : (zeroGradient)";
}

But this won't work and I didn't really expect it will run in this form :P that's why I'm still asking. I'm so eager to know how to use it though.

You can do that with the fractionExpression (that says whether the BC is a Dirichlet or a Neumann)

Have a look at the second BC in this example:
http://openfoamwiki.net/index.php/Co...ulsedPitzDaily
This should give you an idea hwo to implement your BC
(of course the question is whether you'll want to switch the whole patch at the same time or each face individually, which is the default behaviour, for the whole patch you'll have to use max(p) or something similar)

Bernhard

piprus March 25, 2010 14:33

Ok, as far as I understood I can't use my conditions explicitly, writing e.g.:
Code:

fractionExpression "(max(p) > 7e6) ? uniform 0 : zeroGradient"
but what I can do is to switch between Dirichlet's or Neumanns conditions. So assuming that when the outlet is closed (there is no gradient) I should have apply Dirichlet's conditions, but when it's open it has to be Neumann. Then my expression should look like this:
Code:

fractionExpression "(max(p) > 7e6) ? 0 : 1"
Is that right?

gschaider March 25, 2010 15:15

Quote:

Originally Posted by piprus (Post 251687)
Ok, as far as I understood I can't use my conditions explicitly, writing e.g.:
Code:

fractionExpression "(max(p) > 7e6) ? uniform 0 : zeroGradient"
but what I can do is to switch between Dirichlet's or Neumanns conditions. So assuming that when the outlet is closed (there is no gradient) I should have apply Dirichlet's conditions, but when it's open it has to be Neumann. Then my expression should look like this:
Code:

fractionExpression "(max(p) > 7e6) ? 0 : 1"
Is that right?

Yep.

You could add a condition for phi if you expect backflow in the "open"-case (inletOutlet-style)

piprus March 25, 2010 15:44

Quote:

Originally Posted by gschaider (Post 251695)
Yep.

Looks like there remains only one question to solve, before I run the simulation. I mean how should I define BC for p (pressure)? I want to keep the idea of 1e5 MPa at the outlet when it's open.

Quote:

Originally Posted by gschaider (Post 251695)
You could add a condition for phi if you expect backflow in the "open"-case (inletOutlet-style)

I know that I used inletOutlet before, but now it seems to be no longer valid. There won't be any backflow, since it will be a very simple model of a checkValve, but thanks for idea. Will be useful later in a different case.

piprus March 27, 2010 19:29

I did some changes of the conditions and my outlet looks as shown below:

0/alpha1
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    //valueExpression "zeroGradient"; // (1) Dirichlet
    gradientExpression "0"; // (0) Neumann
    }

0/p
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    //valueExpression "zeroGradient"; // (1) Dirichlet
    gradientExpression "1e5"; // (0) Neumann
    }

0/U
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    valueExpression "vector(0,0,0)"; // (1) Dirichlet
    gradientExpression "vector(0,0,0)"; // (0) Neumann
    value          uniform (0 0 0);
    }

Will this work or should I change something?

I'm asking, cause I tried to run it and I got an error

Code:

Courant Number mean: 0 max: 0
deltaT = 0.001
Time = 0.001

MULES: Solving for alpha1
Liquid phase volume fraction = 0.5110848  Min(alpha1) = 0  Min(alpha2) = 0
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
#0  Foam::error::printStack(Foam::Ostream&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#1  Foam::sigFpe::sigFpeHandler(int) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#2  ?? in "/lib/libc.so.6"
#3  Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#4  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/applications/bin/linux64GccDPOpt/compressibleInterFoam"
#5  main in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/applications/bin/linux64GccDPOpt/compressibleInterFoam"
#6  __libc_start_main in "/lib/libc.so.6"
#7  _start at /build/buildd/eglibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:116
Floating point exception


gschaider March 29, 2010 14:16

Quote:

Originally Posted by piprus (Post 251992)
I did some changes of the conditions and my outlet looks as shown below:

0/alpha1
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    //valueExpression "zeroGradient"; // (1) Dirichlet
    gradientExpression "0"; // (0) Neumann
    }

0/p
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    //valueExpression "zeroGradient"; // (1) Dirichlet
    gradientExpression "1e5"; // (0) Neumann
    }

0/U
Code:

    outlet
    {
    type groovyBC;
    fractionExpression "(max(p) > 7e6) ? 0 : 1"
    valueExpression "vector(0,0,0)"; // (1) Dirichlet
    gradientExpression "vector(0,0,0)"; // (0) Neumann
    value          uniform (0 0 0);
    }

Will this work or should I change something?

I'm asking, cause I tried to run it and I got an error

Code:

Courant Number mean: 0 max: 0
deltaT = 0.001
Time = 0.001

MULES: Solving for alpha1
Liquid phase volume fraction = 0.5110848  Min(alpha1) = 0  Min(alpha2) = 0
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
#0  Foam::error::printStack(Foam::Ostream&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#1  Foam::sigFpe::sigFpeHandler(int) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#2  ?? in "/lib/libc.so.6"
#3  Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#4  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&) in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/applications/bin/linux64GccDPOpt/compressibleInterFoam"
#5  main in "/home/piotr/OpenFOAM/OpenFOAM-1.6.x/applications/bin/linux64GccDPOpt/compressibleInterFoam"
#6  __libc_start_main in "/lib/libc.so.6"
#7  _start at /build/buildd/eglibc-2.10.1/csu/../sysdeps/x86_64/elf/start.S:116
Floating point exception


My guess (but can't say for sure unless you produce a stack-trace from a debug-version) is that something is divided by zero. My guess is that it is p. Because you don't define a valueExpression for p/Outlet. So groovy implicitly takes "0" if a dirichlet-condition is used

Bernhard

piprus March 30, 2010 08:23

Quote:

Originally Posted by gschaider (Post 252168)
a stack-trace from a debug-version

I haven't been using debug before and as far as I see in the foamDebugSwitches there is a lot of switches. Could you tell me (step-by-step) how should I use it to get some useful information?

gschaider March 30, 2010 11:54

Quote:

Originally Posted by piprus (Post 252282)
I haven't been using debug before and as far as I see in the foamDebugSwitches there is a lot of switches. Could you tell me (step-by-step) how should I use it to get some useful information?

Have a look at
http://openfoamwiki.net/index.php/Ma...:Ostream.26.29
and
http://openfoamwiki.net/index.php/HowTo_debugging
But before you start compiling your debug-version make sure that p is not 0 in the case of a Dirichlet-condition, and it will be with the conditions you showed above

Bernhard

piprus March 30, 2010 13:16

Quote:

Originally Posted by gschaider (Post 252332)
But before you start compiling your debug-version make sure that p is not 0 in the case of a Dirichlet-condition, and it will be with the conditions you showed above

Thank you so much for this advice, my simulation seems to work now. It has to take some time to check whether it's working as I expect, but if not I will for sure ask more questions :P

helenhunt March 31, 2010 02:55

hiii
 
I can do is to switch between Dirichlet's or Neumanns conditions. So assuming that when the outlet is closed (there is no gradient) I should have apply Dirichlet's conditions, but when it's open it has to be Neumann.

Sealed Lead Acid Battery

Gunn_Elin February 14, 2012 04:31

Quote:

Originally Posted by piprus (Post 252347)
Thank you so much for this advice, my simulation seems to work now. It has to take some time to check whether it's working as I expect, but if not I will for sure ask more questions :P

Hi!
I'm quite new to the use of openFoam, and is currently trying to simulate a check valve for a patch such as yours. Did this groovyBC presented here work for you, or did you change it?

Is it possible for you to post the final boundary conditions you used for the check valve, if you changed them further from whats written here?

Thanks a lot in advance:D.

Gunn_Elin February 14, 2012 10:09

Quote:

Originally Posted by Gunn_Elin (Post 344284)
Hi!
I'm quite new to the use of openFoam, and is currently trying to simulate a check valve for a patch such as yours. Did this groovyBC presented here work for you, or did you change it?

Is it possible for you to post the final boundary conditions you used for the check valve, if you changed them further from whats written here?

Thanks a lot in advance:D.

It look's like the boundaries worked. I'only added the keyword value for alpha1 and the pressure, and the case was running :)


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