|
[Sponsors] |
A general openfoam development question about boundary condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 12, 2011, 07:30 |
A general openfoam development question about boundary condition
|
#1 |
Member
|
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... //Kai |
|
May 12, 2011, 08:27 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
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 |
|
May 14, 2011, 11:50 |
|
#3 |
Member
|
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; } ... } 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 ( ); } ... } // Kai |
|
May 14, 2011, 16:12 |
|
#4 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
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>; } which also explains how to do it for a fixedGradient boundary type. |
|
May 14, 2011, 20:55 |
|
#5 | |
Member
|
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:
// Kai |
||
May 15, 2011, 06:34 |
|
#6 |
Member
|
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) // Kai |
|
May 15, 2011, 11:26 |
|
#7 |
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19 |
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.
|
|
May 16, 2011, 10:31 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
|
||
August 27, 2011, 04:00 |
|
#9 |
Member
|
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 |
|
August 27, 2011, 12:09 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
|
||
August 15, 2012, 13:51 |
Which file do I put this code in?
|
#11 | |
Member
Ronald McDonald
Join Date: Jul 2012
Posts: 38
Rep Power: 14 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wind turbine simulation | Saturn | CFX | 60 | July 17, 2024 06:45 |
General OpenFOAM question | Madeleine P. Vincent | OpenFOAM | 1 | May 5, 2011 14: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 17:40 |
Question about the outlet boundary condition. | G.H.Lee | Main CFD Forum | 5 | April 29, 1999 05:50 |