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

lzgwhy January 4, 2010 09: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 15: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 06: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 12: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 21: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 06: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 10: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 11: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 09: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 03: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 00: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 10: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 11: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 12: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 16:46

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

wyldckat October 31, 2015 16: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)


sabago October 31, 2015 17:00

HERE'S what i get

Checking geometry...
Overall domain bounding box (0 0 0) (0.0001 0.00057 5e-05)
Mesh (non-empty, non-wedge) directions (1 1 0)
Mesh (non-empty) directions (1 1 0)
All edges aligned with or perpendicular to non-empty directions.
Boundary openness (2.34216e-17 0 4.68431e-17) OK.
Max cell openness = 1.0982e-16 OK.
Max aspect ratio = 43.6937 OK.
Minimum face area = 1.14433e-10. Maximum face area = 5e-09. Face area magnitudes OK.
Min volume = 1.14433e-14. Max volume = 5.72165e-14. Total volume = 2.85e-12. Cell volumes OK.
Mesh non-orthogonality Max: 0 average: 0
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 0.197788 OK.
Coupled point location match (average 0) OK.

Mesh OK.

End

wyldckat October 31, 2015 17:57

Then shouldn't the file "tcath.dat" have these values?
Code:

(
(0.00000 2.5)
(0.00025 3)
(0.00035 4)
)

I say this because of this:
Code:

Overall domain bounding box (0 0 0) (0.0001 0.00057 5e-05)
In addition to this, in ParaView, are you looking at the last time snapshot?

sabago November 1, 2015 03:05

i am checking the last time step in paraview. and i have this for my .dat file

Code:

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


)

____________

i also tried
Code:

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


)

____________

i am checking the last time step in paraview. and i have this for my .dat file

Code:

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


)

and
Code:

(
(570e-6 2.5)
(545e-6 3)
(535e-6 4)
)

____________

I notice that you use a name different from the .dat file name as I do. COuld that be causing my problems?

wyldckat November 1, 2015 15:39

Hi Sandra,

Quote:

Originally Posted by sabago (Post 571251)
Code:

(
(570e-6 2.5)
(545e-6 3)
(535e-6 4)
)


It's best to use the first column ordered from smallest to largest:
Code:

(
(535e-6 4)
(545e-6 3)
(570e-6 2.5)
)

But there is something strange with these numbers... what is the mesh resolution that you are using? Because this assumes that you have at least 3 cells between "535e-6" and "570e-6".


Quote:

Originally Posted by sabago (Post 571251)
I notice that you use a name different from the .dat file name as I do. COuld that be causing my problems?

This would only be a problem if you are not editing the file "tcath.dat" in the correct folder.
Try running this command inside the case folder:
Code:

find -name tcath.dat
it will tell you the paths where it finds this file is located.

If this doesn't help, then I strongly suggest that you take a step back and test with another test case, preferably one of OpenFOAM's tutorial cases. I say this because sometimes there are certain details that we only see when we look at them from a different perspective.

Best regards,
Bruno

sabago November 2, 2015 05:51

Quote:

Originally Posted by wyldckat (Post 571331)
Hi Sandra,


It's best to use the first column ordered from smallest to largest:
Code:

(
(535e-6 4)
(545e-6 3)
(570e-6 2.5)
)

But there is something strange with these numbers... what is the mesh resolution that you are using? Because this assumes that you have at least 3 cells between "535e-6" and "570e-6".
Best regards,
Bruno

hi Bruno,, how can i determine my resolution? all i know is that the parameter that i want to change is 50micron along y

wyldckat November 2, 2015 17:08

Quote:

Originally Posted by sabago (Post 571424)
hi Bruno,, how can i determine my resolution? all i know is that the parameter that i want to change is 50micron along y

Quick answer: If you created the mesh, you should know what resolution you have defined ;)

If you used blockMesh, check how you defined the blocks. For example, in the tutorial case "incompressible/icoFoam/cavity", the following definitions were used:
Code:

convertToMeters 0.1;

vertices
(
    (0 0 0)
    (1 0 0)
    (1 1 0)
    (0 1 0)
    (0 0 0.1)
    (1 0 0.1)
    (1 1 0.1)
    (0 1 0.1)
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
);

Which means that the mesh is 0.1 by 0.1 by 0.01 (m) in total dimensions, divided in a cell distribution of 20 by 20 by 1, which equals to a resolution of 0.005 by 0.005 by 0.01 (m).

sabago November 2, 2015 17:11

oh, my resolution is 100micronx5.7micronx50micron

wyldckat November 7, 2015 11:31

Hi Sandra,

I hope you've figured out what the problem was.
If not, we need a common example to work with, in order to make it easier to diagnose what it is the exact problem. Otherwise we'll be going back and forth with a guessing game for which I don't have enough time for.

If you can share your case at least privately, send me a PM with a download link for the case on DropBox or similar file sharing service. If not, then please use one of OpenFOAM's tutorials as a base for creating a similar case structure and then share it here. That way it's a lot easier to figure out what the exact problem is.

Best regards,
Bruno

sabago November 9, 2015 09:53

will PM you

sabago November 9, 2015 13:54

what did you set as your internalField at 0/U?
It seems that mine only reads the internalField.

Sandra
Quote:

Originally Posted by wyldckat (Post 571171)
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:


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


wyldckat November 15, 2015 13:41

Hi Sandra,

I've finally managed to take a look into this today.
Quote:

Originally Posted by sabago (Post 572657)
what did you set as your internalField at 0/U?
It seems that mine only reads the internalField.

In the test case I did, I only changed the boundary condition, the rest is the original settings in the tutorial.

Quoting from the PM you sent me:
Quote:

Originally Posted by sabago
After running the case, the parameters that I'm looking at in ParaView are "jbvag" and "jbvcg"; after integration, they should be the same within some error.
But changing the values in my .dat files doesn't do anything to the values of "jbvag" and "jbvcg" but changing the internalField shows a difference.

Actually, I had to look at the files "0/anode/pang" and "0/anode/tang", which were the ones with the groovyBC boundary conditions. Fortunately, since you sent me the code for solver as well, I was able to pinpoint the problem.
For example, since the fields "pang" and "tang" are used only for conventional calculations and are not part of equations, then their boundary conditions aren't updated and are used as-is after loading. In order to force the update you need to call the method "correctBoundaryConditions()". For example, for the field "pang" you need to call this method right after loading it:
Code:

    Info<< "Reading pang\n" << endl;
    volScalarField pang
    (
        IOobject
        (
            "pang",
            runTime.timeName(),
            anodeMesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        anodeMesh
    );
    pang.correctBoundaryConditions();

The last line is the new code.

If you do this for all of the relevant fields, then things should finally work as intended.

Best regards,
Bruno

sabago December 14, 2015 09:39

Hi Bruno,

I did try your suggestion but it seems that it's still only reading the internal field.
I PMed you the revised solver (and case).

Best,
Sandra

wyldckat December 28, 2015 18:19

1 Attachment(s)
Hi Sandra,

I have to say that I feel a bit lost on where I should look at to see the problem.
Here are the steps I took:
  1. I downloaded the folders you sent me and I ran inside the folder "ysofcFoam" the following commands:
    Code:

    wclean
    wmake

    Note: I used OpenFOAM 2.3.1.
  2. Then I went to the folder of the case "YSOFC" and ran the solver ysofcFoam.
  3. I aborted the run after several iterations, where it stopped at around "0.00113".
  4. Then I opened the case in ParaView with this command:
    Code:

    paraFoam -builtin
  5. Then I selected only the surface mesh patches "anode/anode_inlet" and "anode/fixedWalls".
  6. From the fields list, I selected only the "pang" field.
  7. Also turned on the "Cube Axes", which is an option more at the bottom of the "Properties" widget (the small window on the bottom left entitled "Properties").
  8. Then clicked on the "Apply" button.
  9. Then went to the next time step "1e-05" and changed the view to see what I see in the attached image.
    • Notice the several settings that are shown in the image, such as the represented field and the represented time step.
As you can see in the attached image, everything seems to be working as intended, given that the "pan.dat" file has this:
Code:

(
(69e-6 0)
(70e-6 0.17)
(90e-6    0.17)
(91e-6  0.3)
(570e-6 0.3)
)

The first column refers to the Y axis position and the second column is the value to be represented in the "pang" field.

If you follow these same steps, are you able to see the same results?
What is the exact problem I should be looking for?

Best regards,
Bruno

sabago January 11, 2016 06:55

how do I get the "represented field" and "time" to show in the plot?

wyldckat January 31, 2016 11:57

Quick question: Are you referring to a 2D plot or a 3D view?

sabago February 24, 2016 13:53

2D plot view

LeeRuns March 25, 2016 12:12

Quote:

Originally Posted by Axel_T (Post 241574)
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


i have run 2 cases (icoFOam and nonNewtonian Icofoam). I see you are defining the initial conditions in your p and u files as individual scalars. All of my are x,y,x component of u or p at that boundary. How are you describing x,y,x with just an individual value?

wyldckat March 28, 2016 15:34

1 Attachment(s)
Greetings to all!

@Sandra:
Quote:

Originally Posted by sabago (Post 586698)
2D plot view

Sorry, but only today did I finally manage to take a look into this. Attached is the image "ParaView 4.4 2D plot options.jpg" that shows how it can be configured in ParaView 4.4. I could not find similar settings on ParaView 4.1.0.
Notice 3 important details on the left side of the image, inside the "Properties" tab:
  1. The gear icon (below the blue question mark "?") is turned on.
  2. The "Series Parameters" has the selection of the desired field to be plotted.
  3. The "Chart Title" is defined as:
    Code:

    Time so far: ${TIME}s
    where "${TIME}" is the place-holder keyword that ParaView provides for representing the time.
  4. A bit below the chart title option, which is not shown in the image, is the option to show the legend with the names of the plotted fields.

@LeeRuns:
Quote:

Originally Posted by LeeRuns (Post 591652)
i have run 2 cases (icoFOam and nonNewtonian Icofoam). I see you are defining the initial conditions in your p and u files as individual scalars. All of my are x,y,x component of u or p at that boundary. How are you describing x,y,x with just an individual value?

For example, this:
Code:

value      uniform 1e5;
means that all entries are uniformly set to 100000. If there was at least one different value, then this would actually be something like:
Code:

value nonuniform 234(1e5 1e5 .... 1e4 ... 1e5);
where the dots are just hinting there there would be more values there.

In order to set values depending on X, Y, Z positions, you can use funkySetFields: http://openfoamwiki.net/index.php/Co...funkySetFields

Best regards,
Bruno

Bharath Bhushan April 15, 2017 03:26

boundary condition
 
hello guys,



I am confused with the boundary conditions. I want to simulate nozzle flow with water as fluid.

I have these values-

velocity at inlet = 1.46m/s
total pressure = 6 Bar
simpleFoam with either kepsilon or kOmega

I set the conditions as

velocity - inlet (fixedValue 1.43), outlet (zeroGradient)
pressure - inlet (zeroGradient), outlet (fixedValue uniform 0)

when I see it in the paraview, the pressure at the inlet shows 2000 pascal, but the actual value is around 5 Bar.

Actually I am confused with the pressure boundary conditions. Whether in simpleFoam, pressure in 0/p takes static or dynamic or total pressure ?.

please can anybody suggest appropriate boundary condition for my case ?


thank you

Bharadwaj

piu58 April 15, 2017 07:35

> total pressure = 6 Bar

I think you mean the pressure difference between inlet and outlet.

You may set this difference and calculate the velocity or set the velocity and calculate the pressure difference.

If you have measured values and the results of your calculation differ, you have a good example to learn how OF needs to be set and which degree of accuracy can be reached with fluid simulations.

Please keep in mind: When simulating incompressible, OF takes the kinematic pressure.


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