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

Question about Converting Vector Arrays to Regular Arrays

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 3, 2008, 23:30
Default Hi all, I have a question
  #1
Member
 
Heng Xiao
Join Date: Mar 2009
Location: Zurich, Switzerland
Posts: 58
Rep Power: 17
xiao is on a distinguished road
Hi all,

I have a question encountered during code coupling (coupling OF with an external code). Any suggestions would be appreciated!

During coupling, OF needs to give a "vector array" to the external code (say, the velocity at N points). Suppose this velocity array is declared as:

vector vp[4];
The values are:
vp[0] = (v0x, v0y, v0z);
vp[1] = (v1x, v1y, v1z);
...
vp[N-1] = (vnx, vny, vnz);

However, the external code does not have a "vector" data structure. Instead, it assume the velocity to be 1D array of size (3*N), N being the number of point. In this case, "vp" need to be as follows in order to be passed to this external code:

double vp[3*N];

vp ={v0x, v0y, v0z, v1x, v1y, v1z, ... }

Now, every time during the "communication" of the the two code, I setup a temperary array "vtmp", copy the velocity components from the vector array to a regular 1D array "vtmp", and then pass "vtmp" to the external code. When the array size N is big and the communication is frequent, this waste a lot of time.

Could any one give me a better suggestion? Particularly, is there any structure we can assume about the storage of the components of "vector" data structure? say, are the components contiguous in the memory? e.g. in the example above, is "v0x" and "v0y" next to each other in the memory? or even further, are "v0z" and "v1x" next to each other?

Thanks very much in advance!

Heng
xiao 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
Field of arrays alberto OpenFOAM Running, Solving & CFD 12 October 4, 2017 06:14
Problems of convergencia in arrays Jussara Zanote CFX 3 February 22, 2005 17:29
Arrays in Fortran & C SwF Main CFD Forum 11 January 14, 2005 08:43
about multidimensional arrays in C Adriana Main CFD Forum 3 June 29, 2003 17:37
on taylor's series and C++ arrays yfyap Main CFD Forum 9 June 22, 2001 14:24


All times are GMT -4. The time now is 01:04.