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/)
-   -   0/T two boundary conditions on one wall (https://www.cfd-online.com/Forums/openfoam-pre-processing/254348-0-t-two-boundary-conditions-one-wall.html)

Ibrahim_I February 4, 2024 14:31

0/T two boundary conditions on one wall
 
Hi, in my 0/T folder on one wall I need a heat flux (W/m^2) and convective heat flux (W/m^2K). I tried defining these conditions separately for the same wall or putting it in the same bracket but openfoam only uses one of them not both. Is there a way of doing this without using swak4foam? Example code below in which openfoam only uses the second condition.

top_wall
{
type externalWallHeatFluxTemperature;
value $internalField;
q uniform 1000.0;
mode flux;
kappaMethod solidThermo;
qr none;
kappa none;
thicknessLayers ();
kappaLayers ();
}

top_wall
{
type externalWallHeatFluxTemperature;
mode coefficient;
Ta constant 313.0;
h uniform 17.0;
value $internalField;
}

powabna February 9, 2024 19:40

Hi!

I don't know if you found a solution, but... I faced similar challenges with BC on a wall. I've experimented with some OF options and at the end codedMixed worked just fine.

Link to documentation, it has a nice simple example:
https://www.openfoam.com/documentati...atchField.html

If you would have any questions feel free to ask! :)

olesen February 13, 2024 05:14

Quote:

Originally Posted by Ibrahim_I (Post 864226)
Hi, in my 0/T folder on one wall I need a heat flux (W/m^2) and convective heat flux (W/m^2K). I tried defining these conditions separately for the same wall or putting it in the same bracket but openfoam only uses one of them not both. Is there a way of doing this without using swak4foam? Example code below in which openfoam only uses the second condition.

top_wall
{
type externalWallHeatFluxTemperature;
value $internalField;
q uniform 1000.0;
mode flux;
kappaMethod solidThermo;
qr none;
kappa none;
thicknessLayers ();
kappaLayers ();
}

top_wall
{
type externalWallHeatFluxTemperature;
mode coefficient;
Ta constant 313.0;
h uniform 17.0;
value $internalField;
}

What you are attempting simply does not make sense and will not work. The OpenFOAM files are essentially the same as a dictionary format, which means that the second entry will partly overwrite the first entry and partly be merged into it.

If you test with the following, you will see what OpenFOAM itself sees:
Code:

foamDictionary -expand 0/T
Your only option will be to write your own coded (mixed) BC, use an expressions BC - both of which mean lots of copy/paste from the externalWallHeatFluxTemperature code. Alternatively, if you can cleanly formulate what your new mode should be called and how it works, can consider opening a request for enhancement:
https://develop.openfoam.com/Develop...foam/-/issues/

olesen February 13, 2024 05:22

Quote:

Originally Posted by powabna (Post 864464)
Hi!

I don't know if you found a solution, but... I faced similar challenges with BC on a wall. I've experimented with some OF options and at the end codedMixed worked just fine.

Link to documentation, it has a nice simple example:
https://www.openfoam.com/documentati...atchField.html

If you would have any questions feel free to ask! :)

For many in-between cases, it may also be possible to use "uniformMixed" BC
(https://api.openfoam.com/2312/classF...atchField.html) which allows you to use a PatchFunction1 for each of the three constituent parts.
This can be especially convenient (compared to a complete coded mixed BC) since you can potentially specify some parts as constant or some other PatchFunction1, which include expressions and coded.
IMO it is probably the best of both worlds - it offers full flexibility without necessarily needing to compile additional code.

agustinvo February 15, 2024 03:54

If you check the Code off that BC you Will see that you can use several BC for that wall, you just need to add all the needed parameters in the same boundary.

Ibrahim_I February 19, 2024 15:09

Quote:

Originally Posted by agustinvo (Post 864735)
If you check the Code off that BC you Will see that you can use several BC for that wall, you just need to add all the needed parameters in the same boundary.

Hi, how should I do this? I tried this but it only did the 1k flux and not the convection, because I compared it by removing convection parts and it gave same result

topWall
{
type externalWallHeatFluxTemperature;
mode coefficient;
mode flux;
Ta constant 313;
h uniform 17;
q uniform 1000.0;
value $internalField;
kappaMethod solidThermo;
qr none;
kappa none;
thicknessLayers ();
kappaLayers ();
}

Ibrahim_I February 19, 2024 15:10

Quote:

Originally Posted by powabna (Post 864464)
Hi!

I don't know if you found a solution, but... I faced similar challenges with BC on a wall. I've experimented with some OF options and at the end codedMixed worked just fine.

Link to documentation, it has a nice simple example:
https://www.openfoam.com/documentati...atchField.html

If you would have any questions feel free to ask! :)

Hi, I'm not sure how to make heatflux and convection in codedMixed. Do you know how to?

olesen February 19, 2024 18:24

Quote:

Originally Posted by Ibrahim_I (Post 864986)
Hi, I'm not sure how to make heatflux and convection in codedMixed. Do you know how to?


Can you at least write out what your BC is supposed to look like in mathematical form in terms of value and gradient of temperature??

Ibrahim_I February 20, 2024 12:59

Quote:

Originally Posted by olesen (Post 864990)
Can you at least write out what your BC is supposed to look like in mathematical form in terms of value and gradient of temperature??

The equation for that boundary is: q+h(Tinf-T)=-k*dT/dx

where q is flux W/m^2, h is HTC W/m^2K, k is thermal conductivity W/mK. Tinf is the ambient temperature, T is the boundary temperature.

An article posted this code for groovyBC for this type of boundary:
boundary
{
type groovyBC;
variables "h=10.0;Tinf=100.0;k=10.0;q=150.0;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*h))";
value uniform 100;
gradientExpression "q/k";
}
I'm struggling to get swak4foam on Mac, so I'm trying to use this as codedMixed, but I get error saying delta is undeclared identifier. How do I define delta?

powabna March 11, 2024 18:16

Quote:

Originally Posted by Ibrahim_I (Post 865037)
The equation for that boundary is: q+h(Tinf-T)=-k*dT/dx

where q is flux W/m^2, h is HTC W/m^2K, k is thermal conductivity W/mK. Tinf is the ambient temperature, T is the boundary temperature.

An article posted this code for groovyBC for this type of boundary:
boundary
{
type groovyBC;
variables "h=10.0;Tinf=100.0;k=10.0;q=150.0;";
valueExpression "Tinf";
fractionExpression "1.0/(1.0 + k/(mag(delta())*h))";
value uniform 100;
gradientExpression "q/k";
}
I'm struggling to get swak4foam on Mac, so I'm trying to use this as codedMixed, but I get error saying delta is undeclared identifier. How do I define delta?



Hey, in my case I used deltaCoeffs(), it's a variable of a boundary patch that can be accessed
Over here you can find a definition: (https://openfoamwiki.net/index.php/O...n;;deltaCoeffs)

I hope that helps! :)


All times are GMT -4. The time now is 16:21.