CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Programming & Development

groovyBC 2D lookup

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

LinkBack Thread Tools Display Modes
Old   September 22, 2015, 12:05
Default groovyBC 2D lookup
Clint Bedick
Join Date: May 2011
Posts: 38
Rep Power: 8
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.

ecbmxer is offline   Reply With Quote

Old   September 24, 2015, 10:21
Clint Bedick
Join Date: May 2011
Posts: 38
Rep Power: 8
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.

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

#include "interpolation2DTable.H"


// 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).

ecbmxer is offline   Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
DPMFoam - Serious Error --particle-laden flow in simple geometric config benz25 OpenFOAM Running, Solving & CFD 26 July 21, 2016 11:44
groovyBC issue - k and epsilon sagnikmazumdar OpenFOAM Running, Solving & CFD 24 March 1, 2015 08:16
Convergence on anisotropic tetahedral meshes pbo OpenFOAM Running, Solving & CFD 12 December 14, 2010 12:59
Error with 'vanAlbada' scheme Julian K. OpenFOAM Running, Solving & CFD 0 June 18, 2009 09:31
Buoyancydriven cavity flow anita OpenFOAM Running, Solving & CFD 3 March 26, 2008 11:24

All times are GMT -4. The time now is 22:42.