CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Need help evaluating field by interpolation with a "lookup table"

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 24, 2011, 13:39
Default Need help evaluating field by interpolation with a "lookup table"
  #1
New Member
 
John Hawk
Join Date: Jun 2011
Posts: 2
Rep Power: 0
JohnRHawk is on a distinguished road
I am attempting to create a solver which determines the internalField values of a certain scalar field (effectively a field of coefficients "C") based on interpolative evaluation of another scalar field's internal values.

Foe clarification, if I have a normally-generated (e.g. time-stepping, with boundary conditions, evaluated using .solve) scalar field "T," and a .csv file (or other format) of paired values "Cref" vs. "Tref" for the effective range of "T," I need to evaluate "C" at every cell where "T" is already available by interpolating the Cref/Tref data for every value of "T"s internal field, then storing the field "C" for the time step to later perform other calculations.

I have already explored using both Foam::interpolateXY and Foam:interpolationTable to attempt this task, but I've encountered a unique problem with each:

interpolateXY apparently operates only on "fields," whereas my data is in the form of "lists"; since the Cref/Tref data have no dependence (or information) regarding spatial position. As a result I believe I've failed to understand completely this function's intended use, and now suspect it has nothing to do with what I'm attempting.

Using interpolationTable instead yields me a new problem, in which I can't seem to manage accessing and writing to the internalField lists of either "T" or "C" directly.

For example, I would ideally have code similar to the following:

Code:
interpolationTable lookup(filename); //initialize my interpolationTable with data from file
(do other things)
for (Tnum = 0; Tnum <= T.internalfield.size(); Tnum++) //for each value in T
C.internalField[Tnum] = lookup(T.internalField[Tnum]); //evaluate C for this value of T
However, I can't seem to access internalField list elements by array subscript.
Even the following simple test:
Code:
info << T.internalField[1]
fails to compile, throwing the error
error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript

I would appreciate it if anyone could either alert me to my error, or suggest a better method for evaluating "C" using the interpolation data.

(Thanks!)
JohnRHawk is offline   Reply With Quote

Old   June 28, 2011, 12:30
Default
  #2
New Member
 
John Hawk
Join Date: Jun 2011
Posts: 2
Rep Power: 0
JohnRHawk is on a distinguished road
Additionally, I'm having some difficulty handling deconstruction of the "interpolationTable," but this is a secondary issue. Any help with the original problem would be greatly appreciated!
JohnRHawk is offline   Reply With Quote

Old   June 28, 2011, 13:27
Default
  #3
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,089
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by JohnRHawk View Post
However, I can't seem to access internalField list elements by array subscript.
Even the following simple test:
Code:
info << T.internalField[1]
fails to compile, throwing the error
error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
Hi,

You need to put in brackets with no arguments to access the internal field function i.e.
Code:
info << T.internalField()[1]
Hope it helps,
Philip
bigphil 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
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 04:49
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Field interpolation AlmostSurelyRob OpenFOAM 0 February 2, 2011 09:48
Field interpolation in mesh points code jzlam OpenFOAM Post-Processing 2 December 14, 2010 16:48
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 06:51


All times are GMT -4. The time now is 15:14.