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

codedMixed B. C. with table values.

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By LongGe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 16, 2023, 20:46
Default codedMixed B. C. with table values.
  #1
New Member
 
Felipe Noh
Join Date: Aug 2014
Posts: 8
Rep Power: 11
fnohpat is on a distinguished road
I am solving a classic heat transfer problem in the ceiling wall, considering heat conduction and heat loss through convection. For simplicity, I am using a one-dimensional model. I have employed the solvers "laplacianFoam" and "chtMultiregionFoam." Both the upper and lower surfaces experience heat transfer through convection.

Inside the wall, there is a fixed ambient temperature and a constant coefficient "h" for convection. On the outer surface, the external air temperature and "h" (depending on wind speed) are measured every 10 minutes. The boundary condition on the external surface, using the "codedMixed" type, is as follows:

{
type codedMixed;

refValue uniform 0;
refGradient uniform 0;
valueFraction uniform 1;
value $internalField;
name robin; // name of generated BC

code
#{
scalar Tinf = 293; // ambient temperature (k)
scalar hc = 12; // heat transfer coefficient (w/m^2k)
scalar k = 1.5; // thermal conductivity (w/mk)

forAll((*this), i)
{
scalar delta =this->patch().deltaCoeffs()[i];
this->refValue() = Tinf;
this->valueFraction() = 1.0/(1+k*delta/hc);
}
#};


}


Could someone please advise me on how to conduct a simulation for an entire day? The ambient temperature and "h" values need to be read every 600 seconds from a CSV table in the format "Time, Tinf, hc". Due to the small simulation time step, linear interpolation of values for intermediate times is necessary.

Thank you in advance for your assistance.

Best regards, Felipe Noh.

Last edited by fnohpat; August 17, 2023 at 00:17.
fnohpat is offline   Reply With Quote

Old   August 17, 2023, 00:31
Default
  #2
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 13
LongGe is on a distinguished road
Hello Noh

How about using the Function1 class?

The following is a simple usage of Function 1.

1. test-code using OpenFOAM-v2306 via OpenCFD

#include "argList.H"
#include "IOstreams.H"
#include "Function1.H"
#include "IOdictionary.H"

using namespace Foam;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
argList::noParallel();

const word dictName("yourDict"); <- NOTEs::yourDict" must always be "function1Properties".

#include "setRootCase.H"
#include "createTime.H"
#include "setConstantRunTimeDictionaryIO.H"

#if (OPENFOAM > 2212)
dictionary propsDict(IOdictionary::readContents(dictIO));
#else
dictionary propsDict(static_cast<dictionary&&>(IOdictionary(d ictIO)));
#endif

auto Ta = Function1<scalar>::New("Ta", propsDict);
Ta().writeData(Info);

auto ha = Function1<scalar>::New("ha", propsDict);
ha().writeData(Info);

//for time = 10
Info << "Ta(10)=" << Ta().value(10) << endl;
Info << "ha(10)=" << ha().value(10) << endl;

return 0;
}

2. input tables
2-a yourDict in constant/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object function1Properties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Ta
{
type table;
file "<constant>/your-Ta";
}

ha
{
type table;
file "<constant>/your-ha";
}

// ************************************************** *********************** //

2-b your-Ta in constant
// time[sec] Ta[K]
(
(0 273.15)
(60 283.15)
(120 293.15)
);

// ************************************************** *********************** //

2-c your-ha in constant
// time[sec] ha[W/m2/K]
(
(0 15)
(60 16)
(120 17)
);

// ************************************************** *********************** //


3. Execution Result for this test-code
$ Test-code
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2306 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : v2306 OPENFOAM=2306 version=v2306
Arch : "LSB;label=32;scalar=64"
Exec : Test-code
Date : Aug 17 2023
Time : 13:29:14
Host : gauss
PID : 5783
I/O : uncollated
Case :
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Ta table;
TaCoeffs
{
file "<constant>/your-Ta";
}
ha table;
haCoeffs
{
file "<constant>/your-ha";
}
Ta(10)=274.817
ha(10)=15.1667
__________________
Our Work: https://www.idaj.co.jp/product/ennovacfd/openfoam_gui/
Powered by Ennova : https://ennova-cfd.com/
Ennova's Channel Partners : http://www.wolfdynamics.com/
LongGe is offline   Reply With Quote

Old   August 17, 2023, 01:01
Default
  #3
New Member
 
Felipe Noh
Join Date: Aug 2014
Posts: 8
Rep Power: 11
fnohpat is on a distinguished road
Dear Tatsuya Shimizu

Thank you for your prompt response.

On the other hand, I am new to OpenFOAM and don't have experience with programming. I am using OpenFOAM 9. Should I include the code you suggest within the codedMixed code in my boundart condition?

Thank you in advance for your assistance.
fnohpat is offline   Reply With Quote

Old   August 17, 2023, 01:10
Default
  #4
Member
 
Tatsuya Shimizu
Join Date: Jul 2012
Posts: 42
Rep Power: 13
LongGe is on a distinguished road
Hello Noh

For inputs where the physical quantity is time-varying, it is best implemented using the Function1 class. Also, Function1 can easily read an external Table, which would match your application.
olesen likes this.
__________________
Our Work: https://www.idaj.co.jp/product/ennovacfd/openfoam_gui/
Powered by Ennova : https://ennova-cfd.com/
Ennova's Channel Partners : http://www.wolfdynamics.com/
LongGe is offline   Reply With Quote

Old   August 22, 2023, 09:29
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by fnohpat View Post
Dear Tatsuya Shimizu

Thank you for your prompt response.

On the other hand, I am new to OpenFOAM and don't have experience with programming. I am using OpenFOAM 9. Should I include the code you suggest within the codedMixed code in my boundart condition?

Thank you in advance for your assistance.

The advice is to leverage existing boundary condition types whenever possible and avoid doing coding. The Function1 and PatchFunction1 provide a fairly general way to hook in different types of input (table, function, code, expressions, ...) and are supported by a number of different regular boundary conditions. You might, for example, start with an "externalWallHeatFluxTemperature" boundary condition and then specify "Ta" and "h" as different types of Function1 or PatchFunction1.
olesen is offline   Reply With Quote

Reply

Tags
codedmixed, interpolation, openfoam, table


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
Values for nu t and nu tilda Phizz82 OpenFOAM Running, Solving & CFD 1 March 2, 2020 06:00
What is the table values for amplitude in uniformFixedvalue bc? sinhavivekananda318 OpenFOAM Running, Solving & CFD 0 May 5, 2017 02:11
Field Function for interpolating a table to regulate a mass-flow Eike STAR-CCM+ 0 August 7, 2012 03:59
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 12:04
Generating table values in a loop Jarrod Sinclair Siemens 1 November 26, 2003 19:26


All times are GMT -4. The time now is 06:05.