CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

A general openfoam development question about boundary condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 12, 2011, 06:30
Default A general openfoam development question about boundary condition
  #1
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 15
kaifu is on a distinguished road
Hi Foamers,

A general question: could I use a boundary condition that would be updated from time to time in openfoam? for example, on a wall patch, I would like to specify my wall temperature. But I cannot apply the zero gradient or fixed value into wall condition because it is in function of other parameters. Of course I can get the specified value for each wall patch during calculation. My question is could i put the value directly into the wall patch? like
Code:
Tw[iFace]=...value...
Thanks.

//Kai
kaifu is offline   Reply With Quote

Old   May 12, 2011, 07:27
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
I would advise you to have a look at groovyBC or swak4Foam

http://openfoamwiki.net/index.php/Contrib_groovyBC
http://openfoamwiki.net/index.php/Contrib/swak4Foam
Bernhard is offline   Reply With Quote

Old   May 14, 2011, 10:50
Default
  #3
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 15
kaifu is on a distinguished road
Hi Bernhard

Thanks for your advice! After using the library groovyBC in swak4Foam, I still have some questions. First of all, I would like specify my problem. It is about near wall cell's liquid temperature and wall patch temperature. I would like to set the wall patch temperature to a value which could be obtained by other sub models. And then I will calculate the liquid temperature in a energy eq. I hope in the liquid energy eq. I could use this "wall temperature" for boundary conditions instead of the value of zero gradient interpolation of liquid temperature in near wall cells.

I have thought if I could set the specified value into each wall patch, but it doesn't work obviously. And the lib groovyBC could not set a value for a specified face label "iFace" as well. I figured out I could create a volScalarField Tw with zero gradient boundary conditions. Each time I put a value into the cell center of field Tw for near wall cells and hope its value on the wall patch should be the same. And then the liquid enthalpy (or the temperature is similar) boundary conditions could be constructed as follows,

Code:
boundaryField
{
    ...
    walls
    {
        type                  groovyBC;
        variables            "cpl=1419.8;T_sat=359.881;H_sat=292530.0;"
        valueExpression   "cpl*(Tw-T_sat)+H_sat";
        value                 uniform 269740;
    }
       ...
}
The above shows the initial boundary conditions for liquid enthalpy.

However, if i check the boundary conditions after several iteration of my solver, I get the output of enthalpy boundary conditions as,

Code:
boundaryField
{
    ...
    walls
    {
        type                     groovyBC;
        refValue                uniform 0;
        refGradient            uniform 0;
        valueFraction         uniform 1;
        value                    uniform 0;
        valueExpression      "0";
        gradientExpression  "0";
        fractionExpression   "1";
        variables               "cpl=1419.8;T_sat=359.881;H_sat=292530.0;";
        timelines       (
);
        lookuptables    (
);
    }
 ...
}
It seems I get a uniform value for the enthalpy BC. That is not what I wanted, since Tw is not a uniform volScalarField. That is really a big confusion. I wonder if I get something wrong when I used the groovyBC...

// Kai
kaifu is offline   Reply With Quote

Old   May 14, 2011, 15:12
Default
  #4
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Here's a way to do it without groovyBC:


Just say your patch name is "WallBoundary", and your field name is "Temperature" then set the boundary for the Temperature field to a fixedValue.

Then, to change that fixedValue during runtime, use this code:
Code:
fixedValueFvPatchScalarField& WallTemperature = refCast<fixedValueFvPatchScalarField>(Temperature.boundaryField()[WallBoundary]);	
scalarField& TemperatureValue  = WallTemperature;

forAll (TemperatureValue,i) {
TemperatureValue[i] = <INSERT WHATEVER VALUE YOU WANT>;
}
There's a bit more info here: http://www.cfd-online.com/Forums/ope...tml#post271623

which also explains how to do it for a fixedGradient boundary type.
benk is offline   Reply With Quote

Old   May 14, 2011, 19:55
Default
  #5
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 15
kaifu is on a distinguished road
Hi Ben,

Thanks for you advice. I will look into the codes.


BTW there is a bug in swak4Foam apparently. After I compiled the main lib swak4FoamParsers and lib groovyBC, it seems the environment of openfoam changed. If I type 'icoFoam -help' in cmd, it doesn't work unless i "source /opt/openfoam171/etc/bashrc" again. And all the solver do not work any more. It always comes out
Quote:
icoFoam: error while loading shared libraries: libfiniteVolume.so: cannot open shared object file: No such file or directory
when i test some case. Anybody knows how to figure it out? Thx.

// Kai

kaifu is offline   Reply With Quote

Old   May 15, 2011, 05:34
Default
  #6
Member
 
Kai
Join Date: May 2010
Location: Shanghai
Posts: 61
Blog Entries: 1
Rep Power: 15
kaifu is on a distinguished road
Hi Ben and Foamers, again,

When I used the code above, it seems a new field is created, which means I lose the mesh info. i.e. the 'i' in
Code:
forAll (TemperatureValue,i)
does not refer to iCell or iFace in mesh any more. Any suggestion? Thx.

// Kai
kaifu is offline   Reply With Quote

Old   May 15, 2011, 10:26
Default
  #7
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Quote:
Originally Posted by kaifu View Post
When I used the code above, it seems a new field is created, which means I lose the mesh info. i.e. the 'i' in
Code:
forAll (TemperatureValue,i)
does not refer to iCell or iFace in mesh any more. Any suggestion? Thx.
In this case, it will only loop over the boundary values of the WallBoundary patch. So index i=0..n refers to the ith boundary node of the Temperature field, not the internal nodes of the Temperature field. To get the internal nodes, you can do a forAll(Temperature, i) loop, which will go through all internal mesh points but not the boundary points.
benk is offline   Reply With Quote

Old   May 16, 2011, 09:31
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by kaifu View Post
Hi Ben,

Thanks for you advice. I will look into the codes.


BTW there is a bug in swak4Foam apparently. After I compiled the main lib swak4FoamParsers and lib groovyBC, it seems the environment of openfoam changed. If I type 'icoFoam -help' in cmd, it doesn't work unless i "source /opt/openfoam171/etc/bashrc" again. And all the solver do not work any more. It always comes out

when i test some case. Anybody knows how to figure it out? Thx.

// Kai
As long as you compiled it with a straight ./Allwmake there should be no such problem. If you used the Makefile I can't guarantee for anything
gschaider is offline   Reply With Quote

Old   August 27, 2011, 03:00
Default
  #9
Member
 
s.rasoul_varedi
Join Date: Feb 2010
Posts: 82
Rep Power: 15
desert_1250 is an unknown quantity at this point
Send a message via Yahoo to desert_1250
Hi, i hope that you are well,
can everey one tell me how to define the (( 1-exp(-y^2)+0.5Cos2t)) profile with groovyBC? i can do ((1-exp(-y^2)) with nonuniform BCs and 0.5Cos2t with oscillating BCs, but i dont know how to exert the summation of these two profile at inlet BCs

____
Rasoul
desert_1250 is offline   Reply With Quote

Old   August 27, 2011, 11:09
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by desert_1250 View Post
Hi, i hope that you are well,
can everey one tell me how to define the (( 1-exp(-y^2)+0.5Cos2t)) profile with groovyBC? i can do ((1-exp(-y^2)) with nonuniform BCs and 0.5Cos2t with oscillating BCs, but i dont know how to exert the summation of these two profile at inlet BCs

____
Rasoul
I don't quite get your problem: groovyBC supports the summation of expressions (with the + operator. This is a notation that is not uncommon in the scientific literature. In fact: you used it too in your question)
gschaider is offline   Reply With Quote

Old   August 15, 2012, 12:51
Default Which file do I put this code in?
  #11
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 13
mcdonalds is on a distinguished road
Quote:
Originally Posted by benk View Post
Here's a way to do it without groovyBC:


Just say your patch name is "WallBoundary", and your field name is "Temperature" then set the boundary for the Temperature field to a fixedValue.

Then, to change that fixedValue during runtime, use this code:
Code:
fixedValueFvPatchScalarField& WallTemperature = refCast<fixedValueFvPatchScalarField>(Temperature.boundaryField()[WallBoundary]);    
scalarField& TemperatureValue  = WallTemperature;

forAll (TemperatureValue,i) {
TemperatureValue[i] = <INSERT WHATEVER VALUE YOU WANT>;
}
There's a bit more info here: http://www.cfd-online.com/Forums/ope...tml#post271623

which also explains how to do it for a fixedGradient boundary type.
which file do I put this code in?
mcdonalds is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 58 July 3, 2020 01:13
General OpenFOAM question Madeleine P. Vincent OpenFOAM 1 May 5, 2011 13:12
a simple Boundary condition question prapanj OpenFOAM Running, Solving & CFD 1 March 16, 2009 07:51
simple question about fan boundary condition Jane FLUENT 0 June 24, 2004 16:40
Question about the outlet boundary condition. G.H.Lee Main CFD Forum 5 April 29, 1999 04:50


All times are GMT -4. The time now is 04:34.