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

Multi-Dimensional Array - 4th order

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Tobi
  • 1 Post By marupio

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2015, 14:10
Default Multi-Dimensional Array - 4th order
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi all,

I think it is a very stupid question but how can I build a 4th order array in FOAM?

Code:
T[w][x][y][z]

like:

vector< vector< vector< vector<double> > > > T
Thanks in advance,
t.oliveira likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   February 10, 2015, 10:39
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
What do you want to do with the data? There's a number of OpenFOAM-ish ways to do that, each with different advantages.

In OpenFOAM, "List" is (very close to) a std::vector.
List<List<List<scalarList> > > T();

or with math operators
List<List<scalarFieldField> > T();

You could also use PtrList, or UPtrList if unallocated.
t.oliveira likes this.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   February 10, 2015, 10:53
Default
  #3
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi,

thanks for your replay. I store thermodynamic values in that array. Maybe you know the flamelet model? There you have all thermodynamic values based on three variables - with defect you have four variables. Therefore I have to store it in an very big array.

Like

phi of enthalpy, dissipation rate, mixture fraction and varianz mixture fraction
\phi = f(h,\chi,Z,Z'')

Hence this I need a 4d array:
Code:
T[h][chi][Z][Zvar]
Hope its clearer.
I only have to read a file, store the date in the array and then extract the data again (no mathematical operations are needed within this array).
So do you think, list is a good choice ?

Thanks in adavance,
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   January 20, 2021, 11:00
Default converting 3D array to a 4D array
  #4
New Member
 
Prabhu Kankatala
Join Date: Sep 2020
Posts: 2
Rep Power: 0
Prabs27 is on a distinguished road
Hi @Tobi , this thread seems to be a decade old but i hope you still remember what you were talking about and hope you figured out. You seem to have some experience in working with multi-dimensional arrays in openFoam. I have to convert a 3 dimensional array into 4 dimensional one in a humongous code. For eg:

lift[i][j][k]=0.5*Cl[i][j][k]*Vmag[i][j][k]*Vmag[i][j][k]*chord*db[i][k];

can you suggest any sources where i can learn to add an index say l to make it like [i][j][k][l] throughout my code consistently.




Regards
Prabs
Prabs27 is offline   Reply With Quote

Old   January 20, 2021, 11:29
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
You can use the <map> container and use keys. http://www.cplusplus.com/reference/map/map/
__________________
Keep foaming,
Tobias Holzmann
Tobi 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
Runge Kutta 4th Order Source Code sugu Main CFD Forum 4 October 26, 2012 03:15
4th and 5th Order TVD Runge-Kutta Methods saygin Main CFD Forum 2 January 30, 2006 11:45
Help on fortran code for FD 4th order Miguel Main CFD Forum 0 November 14, 2005 10:58
Higher order discretization on staggered grid Chandra Shekhar Main CFD Forum 9 January 27, 2005 16:31
Neighboring cells in TETRA_4 unstructured grids Amaresh Dalal Main CFD Forum 12 September 19, 2004 11:54


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