CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Need help evaluating field by interpolation with a "lookup table" (http://www.cfd-online.com/Forums/openfoam-programming-development/89887-need-help-evaluating-field-interpolation-lookup-table.html)

JohnRHawk June 24, 2011 13:39

Need help evaluating field by interpolation with a "lookup table"
 
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 June 28, 2011 12:30

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!

bigphil June 28, 2011 13:27

Quote:

Originally Posted by JohnRHawk (Post 313446)
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


All times are GMT -4. The time now is 21:32.