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

A general openfoam development question about boundary condition

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools 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: Stockholm
Posts: 40
Rep Power: 7
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: 12
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: Stockholm
Posts: 40
Rep Power: 7
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: 10
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: Neumann boundary conditions

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: Stockholm
Posts: 40
Rep Power: 7
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: Stockholm
Posts: 40
Rep Power: 7
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: 10
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: 3,915
Rep Power: 40
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 1, 2011, 09:35
Default
  #9
New Member
 
Krzysztof Arendt
Join Date: Feb 2011
Posts: 13
Rep Power: 6
kriztof 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: Neumann boundary conditions

which also explains how to do it for a fixedGradient boundary type.
I find your clue very valuable. However, I still have a following problem...
I use buoyantPimpleFoam and I want to be able to change patch temperatures (BC type = fixedValue).
In order to be able to read the temperatures during the calculations, I have added the following line to the createFields.H:

Code:
    autoPtr<basicRhoThermo> pThermo
    (
        basicRhoThermo::New(mesh)
    );
    basicRhoThermo& thermo = pThermo();

    const volScalarField& T = thermo.T(); // MY NEW LINE 
Now I used your code, to change field T at each time step, but I get a compilation error:
Code:
from buoyantPimpleFoam_FDM.C:36:
/opt/openfoam200/src/OpenFOAM/lnInclude/typeInfo.H: In function ‘To& 
Foam::refCast(From&) [with To = Foam::fixedValueFvPatchField<double>, 
From = const Foam::fvPatchField<double>]’:
buoyantPimpleFoam_FDM.C:277:   instantiated from here
/opt/openfoam200/src/OpenFOAM/lnInclude/typeInfo.H:110: error: cannot dynamic_cast
 ‘(const Foam::fvPatchField<double>&)((const Foam::fvPatchField<double>*)r)’ (of type ‘const struct Foam::fvPatchField<double>&’) to type ‘class 
Foam::fixedValueFvPatchField<double>&’ (conversion casts away constness)
It is probably because I defined field T as const, but otherwise I am not able to define it at all, because I get:
Code:
error: invalid initialization of reference of type ‘Foam::volScalarField&’ 
from expression of type ‘const Foam::GeometricField<double, Foam::fvPatchField,
 Foam::volMesh>’
How to overcome this?

Thanks in advance for any help...
kriztof is offline   Reply With Quote

Old   August 27, 2011, 03:00
Default
  #10
Member
 
s.rasoul_varedi
Join Date: Feb 2010
Posts: 82
Rep Power: 6
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
  #11
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
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?
  #12
Member
 
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 5
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: Neumann boundary conditions

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

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 34 October 16, 2014 05:27
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 08: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 12:20.