|
[Sponsors] |
Space varying temperature boundary condition |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 19, 2021, 02:44 |
Space varying temperature boundary condition
|
#1 | |
Member
L S
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
Dear All,
I have been trying to simulate nucleate boiling in OpenFOAM. With present model in phaseChangeHeatFoam the wall constant wall temperature can be applied throughout the wall having fixed value. Which generates a thin vapor layer first and then it breaks into several nucleation sites due to density difference. (See bottom nucleation image file attached below) Now, What I want to do is, apply random value of wall temperature only at certain provided locations (also randomly chosen locations) in lookup table (see posx image file attached below). I want the nucleation to start only at certain locations and not from entire wall. I have tried to write following groovyBC boundary condition for temperature: Code:
bottom { type groovyBC; valueExpression "data(pos().x)"; value uniform 373.15; /* fields ( pos().x T ); */ lookuptables ( { name data; outOfBounds clamp; fileName "$FOAM_CASE/temp.dat"; } ); } Code:
( (375 0.0005) (378 0.001) (377 0.0015) (380 0.002) ) This is giving me a warning and a fatal error for the side walls as: Quote:
Kindly help. Last edited by silviliril; July 19, 2021 at 04:07. |
||
July 20, 2021, 04:44 |
|
#2 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
I haven't used GroovyBC before, but the program is complaining about a missing definition of the walls patch.
Can you share de 0/T file so we can check if there is something missing? |
|
July 20, 2021, 06:58 |
|
#3 |
Member
L S
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
Thank you for replying.
I have managed to solve the problem. I did some mistake in understanding how lookup table actually works. I have attached the temperature file and .dat file for someone if they face similar issues. But, I came to know that lookup table feature in groovyBC is only applicable for 1D data. e.g. Position of X axis and corresponding Temperate values. For, 2D data, we need to user interpolation2DTable feature under codedMixed boundary condition. I need to provide temperature only on certain provided coordinates on heated wall patch. I have written following boundary condition after reading another post from cfd-online. Code:
bottom { type codedMixed; refValue uniform 373.15; refGradient uniform 0; valueFraction uniform 0; redirectType lookupHeatFluxBC; codeInclude #{ #include "interpolation2DTable.H" #}; code #{ // Construct interpolation2DTable fileName fName = "$FOAM_CASE/temp.dat"; Foam::interpolation2DTable<scalar> lookupTableData(fName); // Example lookup values scalar lookupVal1 = 0.001; scalar lookupVal2 = 374; // Set variable gradient field // Looks up as-> lookupTableData(row,col) in tableData.dat this->refGrad() = lookupTableData(lookupVal1,lookupVal2); #}; } Code:
( (0.0001 ((0.0001 374) (0.0002 375))) (0.0002 ((0.0001 378) (0.0002 376))) ) But, I am getting some erratic results, it is not applying the temperature spatially as I asked for, instead it is applying temperature (that too erratic) with time. What can be the issue? Where am I making mistake? |
|
July 20, 2021, 13:12 |
|
#4 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hi Sabrina,
There are several things in the code you shared that make the code not working as described:
Code:
hot { type codedMixed; value uniform 373.15; refValue uniform 10; refGradient uniform 0; valueFraction 1; // <-- FixedValue not gradientValue redirectType lookupHeatFluxBC; codeInclude #{ #include "interpolation2DTable.H" #}; code #{ fileName fName("$FOAM_CASE/temp.dat"); Foam::interpolation2DTable<scalar> lookupTableData(fName); const vectorField& centers = this->patch().Cf(); // Loop acros al the faces conforming the patch forAll(centers, facei) { // Interpolate the value of each of the faces. // In the case I tested x corresponds with z so change this accordingly. scalar out = lookupTableData( centers[facei].z(), centers[facei].y() ); // Set the value to refValue instead of refGrad() for each face this->refValue()[facei] = out; } #}; } |
|
July 21, 2021, 03:33 |
|
#5 |
Member
L S
Join Date: Apr 2016
Posts: 63
Rep Power: 10 |
This is like miracle. This worked like charm. Thanks for the help.
|
|
August 16, 2021, 05:41 |
|
#6 |
New Member
Joao Coelho
Join Date: Jun 2021
Posts: 23
Rep Power: 5 |
Hey, do you know how to adapt this to OF9?
I guess the interpolate2DTable function is no longer present in this version; UniformTable instead. However, I am having a hard time adapting your code to it. Do you have any idea how to do it? My problem is related to how to change the code, and not on the uniform table generation in particular. I really need to use OF9 since I am using the new feature of using a combination of thermophysical properties that were not compatible in previous versions. Thank you very much! Last edited by jcoelho5; August 16, 2021 at 06:26. Reason: add more info |
|
August 31, 2021, 06:02 |
|
#7 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hi Joao,
I've been looking around for some time on how to adapt the code to OF9. It seems that they have introduced a Function2 which is intended to combine all the two dimensional interpolation in one library. The solution I found is a little bit cumbersome, but it should work. On the boundary condition use: Code:
hot { type codedFixedValue; value uniform 373.15; name lookupHeatFluxBC; codeInclude #{ #include "Function2.H" #}; code #{ const fvMesh& mesh = patch().boundaryMesh().mesh(); dictionary F2Dict; IOobject FDictIO ( "F2Dict", // name of the file mesh.time().path(), // path to where the file is mesh, // reference to the mesh needed by the constructor IOobject::MUST_READ // indicate that reading this dictionary is compulsory ); F2Dict = IOdictionary(FDictIO); autoPtr<Function2<scalar>> function_ ( Function2<scalar>::New("function", F2Dict) ); const vectorField& centers = this-> patch().Cf(); forAll(centers, facei) { (*this)[facei] = function_->value( centers[facei].y(), centers[facei].z() ); } #}; } Notice that I have changed the type of the boundary condition to codedFixedValue instead of codedMixed as it is more suited to the intended purpose. The asignation of the field values is the main significant change. This file should look like this one: Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 7 | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location ""; object F2Dict; } /* ------------------------------------------------------------------------- */ function uniformTable; low (-50 0); high (230 140); values 3 3 ( ( 0 0 0 ) ( 0 35 140 ) ( 0 70 280 ) ); Sadly I didn't find any way to do it directly from a csv file, which would be very much convienient, probably it will be developmed in further versions. I hope that helps! |
|
September 3, 2021, 12:38 |
|
#8 |
New Member
Joao Coelho
Join Date: Jun 2021
Posts: 23
Rep Power: 5 |
Dear Carlos,
This was perfect! Got it working exactly as I wanted. Thank you very much!! (tip for people trying to run this in parallel: you should copy the file for each processor's folder) Everything else, working fine. I believe if I wanted to use this with the gradient (input would be space varying gradient instead of space varying temperature), we could use codedMixed BC, with valueFraction 0, right? Thank you again, Carlos. Best regards. |
|
September 3, 2021, 13:32 |
|
#9 |
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 11 |
Hi again Joao,
Glad to know the code works properly. Concerning the parallel issues you mentioned, yes the code reads on the local time. That means that, right now, to run on parallel running the file should be duplicated on each processor. This is an avoidable cumbersome, as the solution is simply change the IOObject to: Code:
IOobject FDictIO ( "F2Dict", mesh.time().globalPath(), mesh, IOobject::MUST_READ ); Concerning the codedMixed, yes it should be possible to switch between the two with minor changes. Take a look to the previous version on the code and let me know if you find any difficulties with it. Best regards. |
|
Tags |
codedfixedvalue, groovybc, openfoam, phasechangeheatfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Varying wall temperature boundary condition | mj2malik | FLUENT | 11 | January 12, 2018 05:09 |
2D time varying boundary condition | Hillie | OpenFOAM Running, Solving & CFD | 0 | January 22, 2017 23:38 |
Basic Nozzle-Expander Design | karmavatar | CFX | 20 | March 20, 2016 09:44 |
Problem in setting Boundary Condition | Madhatter92 | CFX | 12 | January 12, 2016 05:39 |
Dynamic Temperature Boundary Condition | Kshitij | FLUENT | 0 | October 12, 2005 14:40 |