CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (https://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   How to define a dependent boundary condition (https://www.cfd-online.com/Forums/openfoam-pre-processing/173206-how-define-dependent-boundary-condition.html)

laurentD June 15, 2016 10:29

How to define a dependent boundary condition
 
Hi,

i would like to define a boundary condition which is dependent of a quantity which is not the time (but the inlet velocity).

To be clear, i am currently using externalWallHeatFluxTemperature boundary condition and i would like to use a value of h calculated by a function, from the value of the velocity on the inlet of my geometry (a sort of pipe).

Is there a way to use a function of this type or must i create a new boundary condition ?

I think i have to use the nonuniform option and the "include file" command but i don't see any examples of the use of such a function.

If you need more precision to answer this question, ask questions.
Thank you.

Laurent

rapierrz June 15, 2016 13:29

Hi Laurent,

You can use groovyBC for this purpose.

laurentD June 16, 2016 03:39

Thx a lot, i will take a look on it.
Laurent

laurentD June 16, 2016 04:14

So i have looked for informations related to groovyBC.

I have some questions to do what i want to do :
- Do i have to install groovyBC utility ? (i am using OF2.3.1)
- What about swak4Foam ?
- Is there anywhere a tutorial for this kind of boundary conditions (not in my OF files anyway) ?

Thanks everybody who spend some time to help me.

Laurent

Astrodan June 16, 2016 04:28

Quote:

Originally Posted by laurentD (Post 605128)
- Do i have to install groovyBC utility ? (i am using OF2.3.1)
- What about swak4Foam ?

Just install swak4Foam, it includes groovyBC
Quote:

Originally Posted by laurentD (Post 605128)
- Is there anywhere a tutorial for this kind of boundary conditions (not in my OF files anyway) ?

Look at the openfoam wiki or just search the web, there are tons of presentations describing the topic.

For specific help I fear an actual example (just try to use the BC and see what happens) would be useful.

laurentD June 17, 2016 08:22

I have installed swak4Foam, following the commands given by :

https://openfoamwiki.net/index.php/I...tion/swak4Foam

Now i will try to use it to define the value of the h convection coefficient by a function (or a table depending on another quantity which is the velocity on a specific region).

When i look availables examples, the BC used is : groovyBC. For example :
Code:

  atmosphere         
{       
type            groovyBC;       
variables "r1=0.25*(max(pts().x)-min(pts().x));r2=r1*0.2*(1-0.5*cos(54*time()));";       
valueExpression "(sqrt(pow(pos().x-r1*sin(10*time()),2)+pow(pos().z-r1*cos(15*time()),2))<r2) ? 1 : 0"; 
value          uniform 0;   
}

In my case i want to use the externalWallHeatFluxTemperature one, with a manual expression for the value of h. My next question is the following :
Can i use the externalWallHeatFluxTemperature linked with the groovyBC ?
Or:
Do i have to extract expressions used by externalWallHeatFluxTemperature and construct a new one with the changes i want ?

Thanks a lot.
Laurent

Astrodan June 17, 2016 08:32

First a small sugesstion, what is rarely shown, but makes things a lot easier to read, reformat the variables section so you can have one variable per line:
Code:

atmosphere         
{
    type            groovyBC;
    variables
    (
        "r1=0.25*(max(pts().x)-min(pts().x));"
        "r2=r1*0.2*(1-0.5*cos(54*time()));"
    );
    valueExpression "(sqrt(pow(pos().x-r1*sin(10*time()),2)+pow(pos().z-r1*cos(15*time()),2))<r2) ? 1 : 0";
    value          uniform 0;
}

For your special purpose I believe you cannot use an existing BC directly, at least that's from I take from this post. So you will probably have to copy the expression used in the BC; however, this should not be too difficult.

Alternatively use any textbook on heat transfer (or you knowledge) to specify a suitable equation yourself. Reading the C++ code can be confusing if you're not used to it.

laurentD June 17, 2016 08:57

Thank you for the tip, it is very easier to read.

Quote:

For your special purpose I believe you cannot use an existing BC directly, at least that's from I take from this post. So you will probably have to copy the expression used in the BC; however, this should not be too difficult.
Yes it seems not so difficult, but it was a good thing to verify if there exists a faster way to do. I will try to do that.

Another question : Can i use a function name or a function number for the expression of a variable (h in my case) and fill the function in another file (with a include file i suppose) ?

Last one (for the moment) : Can i use a tabular in place of the expression, with for example a value of h depending on the value of Uinlet ? In this case, the tabular can be written in another file.

Thanks for your time.

Astrodan June 17, 2016 11:39

Quote:

Originally Posted by laurentD (Post 605366)
Another question : Can i use a function name or a function number for the expression of a variable (h in my case) and fill the function in another file (with a include file i suppose) ?

No clue, but I guess the #include directive works as before.

Quote:

Originally Posted by laurentD (Post 605366)
Last one (for the moment) : Can i use a tabular in place of the expression, with for example a value of h depending on the value of Uinlet ? In this case, the tabular can be written in another file.

http://www.cfd-online.com/Forums/ope...le-values.html

laurentD June 20, 2016 06:39

I have read the topic you have indicated to me. It is very useful thank you very much.

Only one thing is still a problem.
Can i use groovyBC but with a lookuptables for a variable and not for the main field ?

For example, in the case :
Code:

ailetteFace
    {
        type            groovyBC;
        variables    ("hBC=50.0;"
                        "Ta=20.0;"
                        "kBC=0.5;");
        valueExpression    "Ta";
        fractionExpression "1.0/(1.0 + kBC/(mag(delta())*hBC))";
        value          uniform 293.15;
    }

i would like to apply a lookuptables to hBC. And i don't know if it is possible. It seems that i am not the first person to ask it but i don't find any answer...

Laurent

laurentD June 20, 2016 08:04

I think i am on the right road to my objective.
Doing this for example :
Code:

    ailetteFace
    {
        type            groovyBC;
      variables          (//"hBC=50.0;"
                            "Ta=20.0;"
                            "kBC=0.5;");
        lookuptables (
            {
              name data;
              outOfBounds clamp;
              fileName "$FOAM_CASE/data.data";
            }
        );
    valueExpression    "Ta";
        fractionExpression "1.0/(1.0 + kBC/(mag(delta())*data(kBC)))";
        value          uniform 293.15;
    }

and filling the file data.data with
Code:

(
    (0 0)
    (1 0.1)
    (3 0.1)
    (4 -0.1)
)

i think i have succeed to define hBC as a function of a value, which is defined by the tabular included in data.data.
Can anyone confirm it is the good way ?
(don't be affraid about the numerical values, it is completely crazy, i am just trying to build the boundary condition as i want for the moment. I will fulfill the good values and the good dependencies after.)

How can i verify that the value written on the tabular are read correctly ?

Thanks.
Laurent

laurentD June 20, 2016 08:24

I think i am on the right road to my objective.
Doing this for example :
Code:

    ailetteFace
    {
        type            groovyBC;
      variables          (//"hBC=50.0;"
                            "Ta=20.0;"
                            "kBC=0.5;");
        lookuptables (
            {
              name data;
              outOfBounds clamp;
              fileName "$FOAM_CASE/data.data";
            }
        );
    valueExpression    "Ta";
        fractionExpression "1.0/(1.0 + kBC/(mag(delta())*data(kBC)))";
        value          uniform 293.15;
    }

and filling the file data.data with
Code:

(
    (0 0)
    (1 0.1)
    (3 0.1)
    (4 -0.1)
)

i think i have succeed to define hBC as a function of a value, which is defined by the tabular included in data.data.
Can anyone confirm it is the good way ?

(don't be affraid about the numerical values, it is completely crazy, i am just trying to build the boundary condition as i want for the moment. I will fulfill the good values and the good dependencies after.)

How can i verify that the value written on the tabular are read correctly ?

Thanks.
Laurent


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