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

Dynamic Arrays in OF 1.6

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 27, 2010, 13:49
Default Dynamic Arrays in OF 1.6 [SOLVED]
  #1
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
Hello everyone,

I am having trouble with a custom post-processor. I want to be able to read in a tab separated file from memory and refer to its values (look-up table essentially). Since the size of the file may change, I was thinking of using dynamic arrays, and was able to write the code for it to work in a program on its own.

The problem I run into is when I try run the program in FOAM. I've included all the necessary header files, and the program compiles just fine. When I run it and I need to allocate space, I get the following errors:

new cannot satisfy memory request.
This does not necessarily mean you have run out of virtual memory.
It could be due to a stack violation caused by e.g. bad use of pointers or an out of date shared library

My table isn't very big, which is why I'm going the array route. Has anyone run into this before. Barring that, how could I implement this type of functionality with the built in foam libraries?

Last edited by mturcios777; September 28, 2010 at 13:13. Reason: Found solution to problem
mturcios777 is offline   Reply With Quote

Old   September 28, 2010, 13:09
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 725
Rep Power: 18
mturcios777 will become famous soon enough
Ok, figured it out. Easiest way to do this is with the interpolationTable library.


Code:
fileName myFile = someDict.lookup("file.ext");

interpolationTable<scalar> myTab(myFile);
file.ext has the usual structure:

Code:
N
(
  (x1 y1)
  (x2 y2)
  ...
  (xN yN)
)
Now whenever I want to interpolate:

Code:
scalar yiVar = myTab(xi);
returns the corresponding y value interpolated from the entries of myTab.
For future reference, I'm going to see if I can do something similar for multidimensional interpolation. Out of curiosity, what is the best way to indicate that I've solved my problem so people browsing the forum for this answer can find it faster?

Last edited by mturcios777; September 28, 2010 at 13:15. Reason: Question for forum tools
mturcios777 is offline   Reply With Quote

Reply

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
Regarding Negative volume detected in Dynamic mesh Vinay Morabad FLUENT 9 April 10, 2015 23:00
k-omega-SST model (OF 1.6) - turbulent flat plate cboss OpenFOAM Running, Solving & CFD 23 November 13, 2011 02:28
Dynamic Mesh moving interface help akash.iitb FLUENT 0 August 23, 2010 23:53
Dynamic Mesh Problem. Tom Clark FLUENT 9 July 7, 2010 07:56
Dynamic mesh + grid adapt = Crash! (Files included BillH FLUENT 4 July 24, 2007 15:31


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