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

Create a labelList from components

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2022, 07:52
Default Create a labelList from components
  #1
New Member
 
Join Date: Feb 2022
Posts: 25
Rep Power: 4
theBananaTrick is on a distinguished road
Hello foamers,

I would like to create a list of integers from components.

Something similar to a vector in the STL:
Code:
    vector<int> v{ 10, 20, 30, 40, 50 };
Is there any OF structure to do this?

labelList does not appear to have this constructor and I would have to:
Code:
    labelList v (5);
    v[0]=10;
    v[1] = 20;
    ...
    v[4] = 50;
theBananaTrick is offline   Reply With Quote

Old   February 22, 2022, 10:40
Default
  #2
New Member
 
Join Date: Feb 2022
Posts: 25
Rep Power: 4
theBananaTrick is on a distinguished road
I guess this will do it:

Code:
labelList v(IStringStream("(0 1 2 3 4 5 6 7 8)")());
theBananaTrick is offline   Reply With Quote

Old   February 22, 2022, 11:51
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,689
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by theBananaTrick View Post
I guess this will do it:

Code:
labelList v(IStringStream("(0 1 2 3 4 5 6 7 8)")());

That is just ugly and old school (pre-c++11). Try with this:
Code:
labelList v
({
    0, 1, 2, 3, 4, 5, 6, 7, 8
});
theBananaTrick likes this.
olesen 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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 91 December 21, 2022 04:50
[blockMesh] edges not aligned with or perpendicular to non-empty directions ynos OpenFOAM Meshing & Mesh Conversion 6 March 26, 2020 15:02
[mesh manipulation] RefineMesh Error and Foam warning jiahui_93 OpenFOAM Meshing & Mesh Conversion 4 March 3, 2018 11:32
Actuator disk model audrich FLUENT 0 September 21, 2009 07:06
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07


All times are GMT -4. The time now is 08:55.