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

labelListList handling

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2014, 07:14
Default
  #21
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
@Daniel:

Quote:
Because when i write : "const labelListList & listlist; " i get the error because of non-initialization.
You are trying to bind a const reference to nothing. References are aliases to objects, put most simply. Se this SO answer for information on the differences between pointers and references.

If you need an empty object, do this:

Code:
    labelListList listlist;
If you are going to use the listlist in the constructor and zero-initialize it, it makes no sense to declare it const. The member functions will not be able to modify the zero-initialized listlist. So, just use the listlist as a regular object as in the code snippet above.

If you need a dynamic list of label lists, using the DynamicList template with default template arguments for container expansion, it looks like this:

Code:
    // Shorten the type name. Note the space between the last '> >' -
    // unless you are using the C++11 standad.  
    typedef DynamicList<DynamicList<label> > dynamicLabelListList;

    // Use your new type name alias and declare an empty list object.
    dynamicLabelListList listList;

    // append a label

    listList.append(0);
Note that even though the dynamic list is dynamic the cost of expansion is still slightly better than O(n) (because of a default expansion strategy that reserves extra capacity). If you are using the list to store 100 labels, you won't see the difference. With 1e06 labels you will, and you should initialize the list with a reasonable starting size.

Good luck, hope this helps.T
Daniel73 likes this.
__________________
When asking a question, prepare a SSCCE.
tomislav_maric is offline   Reply With Quote

Old   May 20, 2014, 09:20
Default
  #22
New Member
 
Join Date: Oct 2013
Posts: 19
Rep Power: 13
Daniel73 is on a distinguished road
Many Thanks
Daniel73 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
Problem with handling LES modeling with dynamic mesh g.akbari OpenFOAM Running, Solving & CFD 0 March 8, 2010 17:18
Error%7eerror triggers crash after handling exceptions thrown by errorexit twice 7islands OpenFOAM Bugs 2 September 4, 2007 06:24
Handling axisymmetry terms on the symmetry line Sonny Main CFD Forum 4 December 9, 2005 17:22
macros handling vectors sivakumar FLUENT 0 January 18, 2002 17:16


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