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

externalWallHeatFluxTemperature BC with non-uniform Ta

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 1, 2024, 12:07
Default externalWallHeatFluxTemperature BC with non-uniform Ta
  #1
New Member
 
Adam
Join Date: Oct 2024
Posts: 2
Rep Power: 0
adam_k2024 is on a distinguished road
Hello everyone,


I am trying to run a 2D simulation of some solid heat transfer. I am using openfoam 11 running on Ubuntu 22.04


What I intend to do is study the heat transfer over time through a 2D axi-symmetric wall of a combustion chamber. I want to set the side that faces the combusting fluid to have a varying heat flux based on the heat transfer coefficient formula for forced convection:


\dot{q} = h \cdot (T_a - T_w)


where \dot{q} is the wall heat flux, T_a is the external bulk fluid temperature and T_w is the wall temperature and h is the HTC.


I want to model it such that the fluid temperature across the height of the wall varies (and keep the HTC constant for now). I have a .csv file with z ordinates and its associated Ta value. Ideally I'd want openFOAM to interpolate this table but that's a problem for later.


The best way I found to model this type of boundary condition is to use the externalWallHeatFluxTemperature boundary condition already provided. The only thing is that I can't figure out how to set the Ta variable to be non uniform and vary across space.


Here is how my boundary condition is programmed right now in the 0/T dictionary, trying to imitate what I found online by using the coded function1 type. I am starting off with just making a linear variation across the z-axis.


inner
{

type externalWallHeatFluxTemperature;
mode coefficient;
Ta
{
type coded;
name testTaVarying;

code
#{
scalarField& Ta = this->refValue();
const fvPatch& patch = this->patch();
const vectorField& Cf = patch.Cf(); // Face centers

forAll(Ta, i)
{
scalar z = patch.Cf()[i].z(); // z-coordinate of the face center
Ta[i] = 200 + (400 - 200) * (z / gMax(patch.Cf().component(vector::Z))); // Linear variation from 200 to 400
}
return Ta;

#};
}
h constant 100;
kappaMethod solidThermo;
value $internalField;
}




sources:


https://doc.openfoam.com/2306/tools/...uxTemperature/


https://www.openfoam.com/news/main-n...pre-processing
and the tutorial suggested there:
https://develop.openfoam.com/Develop...ation/0.orig/T




I am getting these errors:

Ta: In member function ‘virtual Foam::scalar Foam::Function1s::testTaVaryingFunction1scalar::va lue(Foam::scalar) const’:
Ta:40:25: error: ‘const class Foam::Function1s::testTaVaryingFunction1scalar’ has no member named ‘refValue’
Ta:41:23: error: ‘fvPatch’ does not name a type
Ta:42:23: error: ‘vectorField’ does not name a type
Ta:46:32: error: ‘patch’ was not declared in this scope; did you mean ‘rpmatch’?



I am not sure what I'm missing or how to proceed with this, as I'm not used to coding snippets in openFOAM and how the classes are all organized.


I tried adding this codeInclude just before the code snippet to see if it helps


codeInclude #{ #include "fvPatch.H" #include "vectorField.H" #};

error log:

could not open file fvPatch.H for source file codedFunction1Template.C due to No such file or directory
Ctoo: codedFunction1Template.C
In file included from codedFunction1Template.C:26:

Does anyone know how I might implement what I am trying to do? Maybe there's an easier way, or maybe I'm just using the coded type wrong. Please let me know.
adam_k2024 is offline   Reply With Quote

Old   October 2, 2024, 09:20
Default
  #2
Member
 
Thiago Parente Lima
Join Date: Sep 2011
Location: Diamantina, Brazil.
Posts: 65
Rep Power: 15
thiagopl is on a distinguished road
Hi Adam,

Ta at the externalWallHeatFluxTemperature boundary condition is a function1 type variable, so you can vary its value in time. At page U-179 of the User Guide of OF12, you have a coded type boundary condition, but again, it is used to vary a value in time:
Code:
inlet
{
type uniformFixedValue;
uniformValue coded;
name pulse;
codeInclude
#{
    #include "mathematicalConstants.H"
#};
code
#{
return scalar
(
    0.5*(1 - cos(constant::mathematical::twoPi*min(x/0.3, 1)))
);
#};
}
Maybe you can use codedFixedValue to vary Ta in space, but I don't know if it works with Ta.
A good news is that In OF12, the HTC is also a function1 type, so you can vary it in time.
__________________
Fields of interest: buoyantFoam, chtMultRegionFoam.
thiagopl is offline   Reply With Quote

Old   October 3, 2024, 06:25
Default
  #3
New Member
 
Adam
Join Date: Oct 2024
Posts: 2
Rep Power: 0
adam_k2024 is on a distinguished road
Hey Thiago,



Thanks for the reply. I read that part of the manual about varying it in time, but it isn't what I'm looking for. I want to make the ambient temperature vary across the height of the wall, and stay constant in time. It seems like the right way to do it is with code functions, but I am having a hard time understanding how the classes and libraries are set up.


In terms of pseudocode, this is what I imagine I need to do:

1. Get the patch of the boundary layer and all of its cells with their associated coordinates. (I'm having problems with getting the right object for this)



3. Form a function (in the mathematical sense) for the Ta value based on z-ordinate based on some user input (csv file, equation etc)



2. For each cell at the patch, assign its Ta value based on the function from earlier


4. Return this set of Ta values to the BC input for the Function1 type (this is where I don't quite get the class structure; do I just return the array and openFOAM converts it into a non-uniform list for Ta?)





If anyone has some expertise with this, let me know
Cheers,
Adam
adam_k2024 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
open Channel, interFoam simulation keep numerically exploding Miguel Hernandez OpenFOAM Running, Solving & CFD 7 April 20, 2022 09:20
Openfoam Turbulent Car Simulation meganrw OpenFOAM Running, Solving & CFD 0 July 5, 2021 16:50
rSF: p divergence in combustor (wt negative value) zonda OpenFOAM Pre-Processing 4 April 10, 2018 07:59
[swak4Foam] Air Conditioned room groovyBC Sebaj OpenFOAM Community Contributions 7 October 31, 2012 15:16
Need help with boundary conditions: open to atmosphere Wolle OpenFOAM 2 April 11, 2011 08:32


All times are GMT -4. The time now is 00:38.