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

[swak4Foam] groovyBC 2D lookup

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 3 Post By ecbmxer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 22, 2015, 12:05
Default groovyBC 2D lookup
  #1
Member
 
Clint Bedick
Join Date: May 2011
Posts: 43
Rep Power: 14
ecbmxer is on a distinguished road
Has anyone managed to implement a 2D lookup table in groovyBC? I know there was some discussion regarding this, but I haven't seen anything in a while.

Basically I have a bunch of heat flux data as a function of two dimensions. I want to take this and implement it as a BC, shifting it in one dimension at each timestep (so it basically is translating). This appears to be a tough thing to do without writing my own BC.

If there is any other utility that could do this, please let me know.

Thanks!
ecbmxer is offline   Reply With Quote

Old   September 24, 2015, 10:21
Default
  #2
Member
 
Clint Bedick
Join Date: May 2011
Posts: 43
Rep Power: 14
ecbmxer is on a distinguished road
I just wanted to post an update. I was able to implement a 2D lookup table using the native OpenFOAM coded boundary condition and the existing interpolation2DTable class.

This is what the temperature BC looks like for my patch "inner". Note, I am using "codedMixed" so I can set the gradient rather than the value.

inner
{
type codedMixed;
refValue uniform 300;
refGradient uniform 0;
valueFraction uniform 0;
redirectType lookupHeatFluxBC;

codeInclude
#{
#include "interpolation2DTable.H"
#};

code
#{

// Construct interpolation2DTable
fileName fName = "$FOAM_CASE/tableData.dat";
Foam::interpolation2DTable<scalar> lookupTableData(fName);

// Example lookup values
scalar lookupVal1 = 10;
scalar lookupVal2 = 20;

// Set variable gradient field
// Looks up as-> lookupTableData(row,col) in tableData.dat
this->refGrad() = lookupTableData(lookupVal1,lookupVal2);

#};

}

tableData.dat looks like:
Note that you have to repeat the "y" values in each row.


(
( x1 ( (y1 val11) (y2 val12) (y3 val13) .....(ym val1m) ) )
( x2 ( (y1 val21) (y2 val22) (y3 val23) .....(ym val2m) ) )
.
.
(xn ( (y1 valn1) ..................................(ym valnm) ) )
);


If I start to use this functionality more, I'll look into creating a proper new BC vs using the coded BC. But for now, this was the easiest way I could get it up and running. It ends up being a bit slow if you want to lookup values at each coordinate value on the boundary (which I do). You can only pass a scalar to the lookup2DTable, so you have to use nested loops in order to lookup at each point. It would be nice if a whole scalarField could be directly passed in (assuming that would even be faster...maybe it wouldn't).

-Clint
ecbmxer is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[swak4Foam] groovyBC lookup tables for Reynolds stress R tensor field rdbisme OpenFOAM Community Contributions 3 July 19, 2021 02:37
DPMFoam - Serious Error --particle-laden flow in simple geometric config benz25 OpenFOAM Running, Solving & CFD 27 December 19, 2017 20:47
[swak4Foam] Change in alpha and U with groovyBC in twoPhaseEulerFoam dani2702 OpenFOAM Community Contributions 0 November 17, 2016 03:30
[swak4Foam] groovyBC and Eqn.setReference() benk OpenFOAM Community Contributions 3 June 2, 2011 08:49
Convergence on anisotropic tetahedral meshes pbo OpenFOAM Running, Solving & CFD 12 December 14, 2010 11:59


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