|
[Sponsors] |
How to use the standard C++ vectors in OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 12, 2011, 23:35 |
How to use the standard C++ vectors in OpenFOAM
|
#1 |
New Member
Bruce Hartley
Join Date: Jun 2011
Posts: 9
Rep Power: 15 |
I want to set up some standard C++ type vectors in OpenFoam but OpenFoam has defined its own type of a vector.
How do I use the stadard C++ definitions to set up a vector of a type which I have defined? Something like vector<mystructure> variableName; and use the standard C++ methods on this variable. |
|
October 13, 2011, 00:16 |
|
#2 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
There's nothing stopping you from using STL vectors - that's why namespaces were invented in the first place.
The vector class in OpenFOAM is defined in the 'Foam' namespace, so it's actually a Foam::vector class. To use the STL version, simply use std::vector, or even plain ::vector. |
|
January 29, 2015, 23:44 |
|
#3 |
Senior Member
Freedom
Join Date: May 2014
Posts: 209
Rep Power: 13 |
Then how to convert OF scalarList to STL c++ vector<double>?
|
|
January 30, 2015, 04:51 |
|
#4 |
Senior Member
|
There are simpler solutions for sure, but if anything else fails, just loop over the scalarList and set the particular element of the std::vector to the respective element of scalarList.
__________________
Blog: sourceflux.de/blog "The OpenFOAM Technology Primer": sourceflux.de/book Twitter: @sourceflux_de Interested in courses on OpenFOAM? |
|
January 30, 2015, 07:12 |
|
#5 |
Senior Member
Freedom
Join Date: May 2014
Posts: 209
Rep Power: 13 |
Thank you!
Yes, because they in the different namespace, we can use std::vector<double> to substitute scalarList. |
|
Tags |
openfoam, standard c++, vectors |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compiling OpenFOAM on hpc-fe.gbar.dtu.dk | kaergaard | OpenFOAM Installation | 1 | June 16, 2011 02:33 |
OpenFOAM 1.5.x package - CentOS 5.3 x86_64 | linnemann | OpenFOAM Installation | 7 | July 30, 2009 04:14 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
OpenFOAM Training in Europe and USA | hjasak | OpenFOAM | 0 | August 8, 2008 06:33 |
The OpenFOAM extensions project | mbeaudoin | OpenFOAM | 16 | October 9, 2007 10:33 |