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/)
-   -   Some Problems about the Boundary Conditions in OpenFoam (http://www.cfd-online.com/Forums/openfoam-solving/71473-some-problems-about-boundary-conditions-openfoam.html)

lzgwhy January 4, 2010 10:29

Some Problems about the Boundary Conditions in OpenFoam
 
Dear all,

How many kinds of boundary conditions (BCs) in OpenFoam? What are they? And how can I denote them in a BCs file of OpenFoam?

The above are some general problems I want to know. However, I faced a specific problem in practice. When I calculated the 2D flow over a 2D cylinder, I did not how to denote the boundary conditions for the cylinder wall and the external boundary which enclose the physical domain, though I knew the meaning of these BCs mathematically and how to set them in commercial software. In particular, how can I set pressure BC for a wall in OpenFoam, if there is no need to set value pressure or pressure gradient to the wall in advance? And how can I set velocity BC for a pressure outlet boundary, if there is no need to set value velocity to it in advance?

Thanks in advance!

Why

Axel_T January 5, 2010 16:56

Hi Why,

there are many types of BC, right. But they are all set in the fieldvariables in your first time-dictionary.

A simple pipe for example would have a inlet, outlet and fixed walls, when you defined the boundaries right during mesh-generation.
In the time-dictionary /0 must be for example the file of the pressure variable: /0/p
In that file there is a entry for the initial state:
internalField uniform 100000;
and a sub-dictionary for the boundaries:
boundaryField
{
inlet
{
type fixedValue;
value uniform 1.1e5;
}

fixedWalls
{
type zeroGradient;
}

outlet
{
type fixedValue;
value uniform 1e5;
}
}
For the velocity at the inlet, there is a BC called pressureInletOutletVelocity which calculates the velocity depending on the pressure.

Take a look at the OF-UserGuide chapter 5.2 especially page U-133

bye
Axel

lzgwhy January 7, 2010 07:48

Hi,Axel.

Thank you for your help. However, I tried to set new boundary conditions (BCs) again and re-calculate my problem with icoFoam solver. In these cases, OpenFoam could not conduct calculation correctly. I read the chaper you suggested, and I have some questions. Firstly, there is one kind of boundary, on which mathematically just one quantity is needed to set, for example, just velocity is needed to set and pressure will be calculated by the velocity field. How can I set this kind boundary condition for pressure and velocity boundary files in OpenFoam, i.e. p file and U file? The second question is about the selection of the solver in OpenFoam. Do you think I am right if I choose the icoFoam solver for the problem of fluid flow over a 2D cylinder, which is a classical external fluid flow problem? If not, which one solver would you like to suggest to me?

Thanks.

Why

openfoam1 January 7, 2010 13:10

yes , me too , i have the same problem ,, I have a velocity data and i want to put them in the inlet of my domain as a boundary condition
any one can help
thanks

Axel_T January 7, 2010 22:57

Hello Why,

I don't know if it would help a lot, but I show you the way I solved it at my problem: A chamber with only one inlet, where the pressure raises over time.

The pressure-boundary is in the file "p"
dimensions [1 -1 -2 0 0 0 0];

internalField uniform 400000;

boundaryField
{
inlet
{
type timeVaryingUniformFixedValue;
fileName "inlet_p.dat";
outOfBounds warn;
}

fixedWalls
{
type zeroGradient;
}
}
There used the timeVaryingUniformFixedValue to get the pressure growing over time. It loads the file "inlet_p.dat", which I created in this syntax:
(
(t0 p0)
(t1 p1)
...
(tn pn)
)

This file needs a strikt format, I think. So don't insert extra spaces or something like that. Just time and pressure.
The keyword outOfBounds says what to do when you enter a timestep which is not listet in the dat-file. There "warn" will hold the last value of the specified range and give you a warning message. Other options are error, clamp and repeat.


Then I defined my "U"-file in this way:
dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
inlet
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}

fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}
}

ThepressureInletOutletVelocity can also be used when the flux can change direction, when you are shure that you will always have a inflow, the pressureInletVelocity would do it either.
I don't know why there must be specified a value for the inlet, because it's calculated, but it won't run without.

I hope I was able to point you in the right direction about that.

Good luck!

Axel

hamcer February 8, 2010 07:35

normal velocity
 
hello,

I try to determine the normal velocity at each point on the boundary which declared as zerogradient, how can I do that?

Thanks in advance.

heavy_user February 8, 2010 11:57

fixed value + alternating BC boundary condition = ??
 
Hi Folks,

i am running a case with reactingFoam.
I use steady BC, but the BC vary with each time Step :eek:..
WHHYYY ??

My BC are:

Code:

pressure:

    inlet         
    {
        type            fixedValue;
        value          uniform 100000;
    }

T:
    inlet         
    {
        type            fixedValue;
    value        uniform 296;
    }
U:

 inlet
    {
        type            fixedValue;
        value          nonuniform List<vector>
100
(
(0 0 67.552)
(0 0 67.77)
(0 0 67.035)
(0 0 65.8686)
(0 0 64.7974)
(0 0 63.5496)
(0 0 61.7962)
(0 0 59.7163)
(0 0 57.5885)
(0 0 54.9667)
(0 0 50.2231)
(0 0 36.2949)
(0 0 0.315833)
(0 0 6.57834)
(0 0 7.44999)
(0 0 7.96628)
(0 0 8.26225)
(0 0 8.49278)
(0 0 8.65498)
(0 0 8.76455)
(0 0 8.83736)
(0 0 8.88867)
(0 0 8.932)
(0 0 8.97775)
(0 0 9.03216)
(0 0 9.0771)
(0 0 9.2)
(0 0 9.2)
.
.
.
)
;
    }

Species:
C3H8 for r/R<1.
"AIR" for r/R>1.

so NOT time dependent BC.

When I check velocity with sample i get different results for each timstep:
(I use sample from (0 0 0) to (0 0.15 0) which should be exactly my (2D) inlet)

The Geometry is a box, with 2 adverce faces asigned the inlet and outlet, 2 adverse faces are declared empty, one face assigned symmetry and the other "wall"(here all BCs are assiged zeroGradient)

One of my favourite results:
(location Ux Uy Uz)

Code:

0 2.31962e-20    -0.308472    65.1918   
0.00015015 3.18149e-21    -0.0180087    67.4434   
0.0003003 -9.95544e-36    1.46518e-16    67.481   
0.00045045 0    0    66.9175   
0.000600601 0    0    66.1129   
0.000750751 0    0    65.2443   
0.000900901 0    0    64.3746   
0.00105105 0    5.15872e-16    63.3375   
0.0012012 0    -3.35738e-16    62.151   
0.00135135 0    -3.35738e-16    60.8089   
0.0015015 0    0    59.3887   
0.00165165 0    -6.66706e-16    57.9029   
0.0018018 0    1.33341e-15    56.3505   
0.00195195 0    0    54.0607   
0.0021021 0    0    50.486   
0.00225225 0    0    44.7908   
0.0024024 0    0    32.4953   
0.00255255 0    0    18.0146   
0.0027027 0    0    9.53493   
0.00285285 0    0    3.99707   
0.003003 0    0    5.9627   
0.00315315 0    0    7.18547   
0.0033033 1.54684e-34    5.29596e-15    7.55476   
0.00345345 0    0    7.83008   
0.0036036 0    0    8.0389   
0.00375375 0    0    8.19776   
0.0039039 0    0    8.32852   
0.00405405 -2.80758e-34    -4.26399e-15    8.4364   
0.0042042 -2.80758e-34    -4.26399e-15    8.53066   
0.00435435 2.75369e-34    -1.57786e-15    8.60796   
0.0045045 0    0    8.67098   
0.00465465 2.73743e-34    2.24416e-15    8.72545   
0.0048048 0    0    8.76632   
0.00495495 -1.36664e-34    -1.67595e-15    8.80503   
0.00510511 0    0    8.8319   
0.00525526 0    0    8.85877   
0.00540541 0    0    8.87967   
0.00555556 -2.68723e-34    5.9232e-15    8.89947   
0.00570571 -2.61375e-34    7.59204e-15    8.91845   
0.00585586 -2.61375e-34    7.59204e-15    8.93644   
0.00600601 0    0    8.95444   
0.00615616 -3.70648e-37    6.9118e-15    8.97396   
0.00630631 -3.70648e-37    6.9118e-15    8.99351   
0.00645646 0    0    9.01273   
0.00660661 0    0    9.03147   
0.00675676 0    0    9.05022   
0.00690691 4.66049e-34    -3.62717e-15    9.07803   
0.00705706 0    0    9.10858   
0.00720721 0    0    9.13892   
0.00735736 4.50919e-34    1.7008e-15    9.16062   
0.00750751 0    0    9.18232   
0.00765766 2.14111e-34    1.03588e-16    9.2   
0.00780781 0    0    9.2   
0.00795796 0    0    9.2   
0.00810811 0    0    9.2   
0.00825826 0    0    9.2   
0.00840841 0    0    9.2   
0.00855856 -4.06648e-34    5.09e-15    9.2   
0.00870871 0    0    9.2   
0.00885886 0    0    9.2   
 
.....
....
....
0.142492 0    0    9.2   
0.142643 0    0    9.2   
0.142793 0    0    9.2   
0.142943 0    0    9.2   
0.143093 0    0    9.2   
0.143243 0    0    9.2   
0.143393 0    0    9.2   
0.143544 0    0    9.2   
0.143694 0    -1.13922e-14    9.2   
0.143844 0    0    9.2   
0.143994 0    0    9.2   
0.144144 0    0    9.2   
0.144294 0    0    9.2   
0.144444 0    0    9.2   
0.144595 0    0    9.2   
0.144745 0    -1.13922e-14    9.2   
0.144895 0    -0.0605795    6.54958   
0.145045 0    -0.130931    3.47163   
0.145195 0    -0.201282    0.393675   
0.145345 0    -0.271634    -2.68428   
0.145495 0    -0.341985    -5.76223   
0.145646 0    -0.412336    -8.84018   
0.145796 0    -0.482688    -11.9181   
0.145946 0    -0.553039    -14.9961   
0.146096 0    -0.623391    -18.074   
0.146246 0    -0.693742    -21.152   
0.146396 0    -0.764093    -24.2299   
0.146547 0    -0.834445    -27.3079   
0.146697 0    -0.904796    -30.3858   
0.146847 0    -0.975147    -33.4638   
0.146997 0    -1.0455    -36.5418   
0.147147 0    -1.11585    -39.6197   
0.147297 0    -1.1862    -42.6977   
0.147447 0    -1.25655    -45.7756   
0.147598 0    -1.3269    -48.8536   
0.147748 0    -1.39726    -51.9315   
0.147898 0    -1.46761    -55.0095   
0.148048 0    -1.53796    -58.0874   
0.148198 0    -1.60831    -61.1654   
0.148348 0    -1.67866    -64.2433   
0.148498 0    -1.74901    -67.3213   
0.148649 0    -1.81936    -70.3992   
0.148799 0    -1.88972    -73.4772   
0.148949 0    -1.96007    -76.5551   
0.149099 0    -2.03042    -79.6331   
0.149249 0    -2.10077    -82.711   
0.149399 0    -2.17112    -85.789   
0.14955 0    -2.24147    -88.8669   
0.1497 0    -2.31182    -91.9449   
0.14985 0    -2.38217    -95.0228

I have no clue why it is doing this!
It does not go along with my understanding of "fixedValue" used for BC.

When I use calcMassflow on that Patch i get corresponding(same cracyness) results.

can anyone give me a hint on that, plz!?

regards !

jignesh_thaker2007 February 6, 2012 12:58

hi openfoamers
 
i have doubt in my problem like that

I have pipe flow problem ok so i enter the fluid inside the pipe so i give the velocity inlet values now i know that at inlet pressure is 1 pascal so and at the outlet pressure outlet condition is there so plz tel me at inlet how can i set the pressure?

yipiyaya8 February 28, 2012 10:28

Quote:

Originally Posted by Axel_T (Post 241840)

Then I defined my "U"-file in this way:
dimensions [0 1 -1 0 0 0 0];

internalField uniform (0 0 0);

boundaryField
{
inlet
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}

fixedWalls
{
type fixedValue;
value uniform (0 0 0);
}
}

ThepressureInletOutletVelocity can also be used when the flux can change direction, when you are shure that you will always have a inflow, the pressureInletVelocity would do it either.


Hi Axel

My case is i know inlet T, P...also outlet P....

Hoever i want to let the openfoam to calculate the Inlet Velocity ...I tried to use

oulet
{
type pressureInletOutletVelocity;
value uniform (0 0 0);
}


but i dont know if this information is enough?!
}

paladin December 23, 2012 04:34

Hi foamers !

Sorry to dig up this post, but i'm facing the same problem here..

I have a flame in the open, where i've imposed inlet velocity (because i have the velocity datas) and outlet pressure (atm. pressure, because it's in the open)

At first i've put a zeroGradient condition on the outlet velocity, but my domain is too short so the solver can't respect both conditions, a zerogradient velocity and a pressure that still have a gradient at the outlet.. So it seems like i also have to let openfoam calculate outlet velocity based on the pressure gradient at the outlet.

Anyway, does anyone knows why we can't just put a "calculated" type for the outlet velocity and (0 0 0) for initial value?

I get

Quote:

--> FOAM FATAL ERROR:

gradientInternalCoeffs cannot be called for a calculatedFvPatchField
on patch Outer of field U in file ".../SwirlFlame_kEps_calculatedVelocity/0/U"
You are probably trying to solve for a field with a default boundary condition.

From function calculatedFvPatchField<Type>::gradientInternalCoef fs() const
in file fields/fvPatchFields/basic/calculated/calculatedFvPatchField.C at line 186.

FOAM exiting

I've tried type pressureInletOutletVelocity and pressureInletVelocity types, but it doesn't change anything. (I use OF 2.0.x)

shipman January 14, 2013 01:15

urgent help
 
Hi eveybody,

I am the new user of the openFoam and nowadays tried to learn how i can use it. For one example i have used multiphase solver and apllied it to the 2-D symmetric nozzle which surface has been created in Star-CD and converted to OpenFoam. My question is that how can change the velocity values. You can see P and V BC are set as follow.

Thanks in advance for help.

object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 -1 -2 0 0];

internalField uniform 300e5;

boundaryField
{
Default
{
type totalPressure;
U U;
phi phiv;
rho rho;
psi none;
gamma 1;
p0 uniform 2e5;
}

Default_5
{
type fixedValue;
value uniform 1e5;
}

Default_10
{
type zeroGradient;
}
}

object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0];

internalField uniform (0 0 0);

boundaryField
{
Default
{
type zeroGradient;
value uniform (0 0 0);
}

Default_5
{
type zeroGradient;
value uniform (0 0 0);
}

Default_10
{
type fixedValue;
value uniform (0 0 0);
}

Default corresponds to Inlet
default_5 ==> outlet
Default?10==> walls

giack April 11, 2013 11:31

Hi to all
Someone know how velocity is obtained from pressure in pressureInletOutletVelocity?

thank to all

samice2008 May 16, 2014 12:55

Boundary condition for sphere in OpenFOAM
 
1 Attachment(s)
Hi,

I am trying to solve the sphere problem in the attachment. I have solved the problem with a fixedValue at the boundary but do not know what to do with this boundary conditions.

The challenge in the boundary is the direction of the normal vector. if it is in the positive X- direction then have a value of +1 but if it in the negative X-direction then the value is -1. Similarly for Y and Z axis.

FYI: The sphere is created from an .stl file and using blockMesh for a hexagon and the snappyHexMesh has been used to generate the mesh.

Desperatly looking for help

thanks
claire

iczajka July 8, 2014 06:17

normal velocity
 
Is there possibility in openfoam to specify outlet velocity as normal ?

sabago October 23, 2015 06:41

Did you get to figure this out?

I would like to set BC that are a function of space. Is there a way to set the BC with a function such that I do not have to write out the value at each mesh size. In other words, I want the code to be reusable.

Thanks.

wyldckat October 31, 2015 11:54

Greetings to all!

@Sandra: I'm going to use part of the PM you sent me to answer your question, since the two topics are related:
Quote:

Originally Posted by sabago
I saw a few of your posts on GroovyBC which helped me come up with something that probably needs minimal debugging.
I have a variable called tcath which I'm setting in the 0 folder as below. My understanding is that the "value" parameter in GroovyBC is used for only the first time step but when I check the variable that I get after some linear calculation with tcath, it's the same at all time steps ie looks like OF is not reading my lookup table. What I'm I doing wrong?

"tcath"
Code:

dimensions      [0 0 0 0 0 0 0];

internalField  uniform 4;

boundaryField
{
    cathode_inlet
    {
    type groovyBC ;

    fields
    (y tc);

    lookuptables (
    {
    name tcath;
    outOfBounds clamp;
    fileName "$FOAM_CASE/tcath.dat";
    }
    );

    valueExpression "tcath(y)";
   
    value uniform 3;
    }

   
    fixedWalls
    {
        type groovyBC ;

    fields
    (y tc);


    lookuptables (
    {
    name tcath;
    outOfBounds clamp;
    fileName "$FOAM_CASE/tcath.dat";
    }
    );

    valueExpression "tcath(y)";
   
    value uniform 2.5;
   
    }
    frontAndBack
    {
        type            empty;
    }
    cathode_to_electrolyte
    {
      type            fixedValue;
        value          uniform 4;
    }
}

and below is my lookup table
Code:

//y tc
(
(0 2.5)
(25 3)
(35 4)
)


This is one of those situations I have to test things myself, namely to do some trial-and-error. I've tested the following in the tutorial case "incompressible/icoFoam/cavity":
  1. In "0/U":
    Code:

        movingWall
        {
            type groovyBC;

            lookuptables (
                {
                    name dataMe;
                    outOfBounds clamp;
                    fileName "$FOAM_CASE/data.dat";
                }
            );

            valueExpression "vector(dataMe(pos().x),0.0,0.0)";
            value          uniform (1 0 0);
        }

  2. Created the file "data.dat" in the "cavity" folder:
    Code:

    (
    (0    2.5)
    (0.05 3)
    (0.1  4)
    )

  3. In "system/controlDict" I added this line:
    Code:

    libs ("libgroovyBC.so");
And it ran fine. The detail is that you are trying to use the field name "y", when you should instead use "pos().y":
Code:

tcath(pos().y)
I think that the entry "fields" is not used, namely this one:
Code:

fields
    (y tc);

If this still doesn't work, then perhaps the values for "pos().y" aren't the ones you're planning for? For example, if your calculations are in millimetre, but the mesh is in metre, then it's somewhat natural that this problem occurs.

Best regards,
Bruno

sabago October 31, 2015 12:49

I tries po().y and it didn't help.
IN my polyMesh, I have "convert to microns" but I input my data in meters just as in the blockMeshDict.
Does it mean that I should use microns in my data file?

wyldckat October 31, 2015 13:36

Quote:

Originally Posted by sabago (Post 571183)
IN my polyMesh, I have "convert to microns" but I input my data in meters just as in the blockMeshDict.

If you have this defined in "blockMeshDict":
Code:

convertToMeters 0.000001;
then technically everything is still in metre, but scaled to the micron scale. In which case, you should have something like this:
Code:

(
(0e-6 2.5)
(25e-6 3)
(35e-6 4)
)


sabago October 31, 2015 17:46

changed the data file as suggested and still tcath is fixed at the initial value/ value in groovyBC.
:-(

wyldckat October 31, 2015 17:52

OK, run this command:
Code:

checkMesh -constant
It should tell you the actual domain that the mesh uses, something like this:
Code:

Checking geometry...
    Overall domain bounding box (0 0 0) (0.1 0.1 0.01)



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