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

HashTable use

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2015, 02:50
Default HashTable use
  #1
Member
 
Join Date: Jul 2012
Posts: 67
Rep Power: 13
Carlen is on a distinguished road
Hi Foamers,

I am very new to OpenFoam and am looking to use HashTable in my code.
I want to insert a set of keys and their associated values in a HashTable and extract them when needed.

HashTable<label, scalar> findDroplet_;//Creat a Hash-Table
findDroplet_.clear();//Hash-Table initialization
findDroplet_.resize(findDroplet_.size()+1);

I know how to create a HashTable but am stuck at inserting values and finding values in the HashTable. I hope someone who is familiar with such table can shed some light on this.

Thank you very much
Carlen.
Carlen is offline   Reply With Quote

Old   February 27, 2015, 07:00
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
I think resize is not necessary for a HashTable. You can access individual elements with
Code:
findDroplet_[1] = 1.234;
label index = 2;
findDroplet_[index] = 1.234;
info<<findDroplet_[2];
You use label (i.e. integer) as key. You could also use word (i. e. strings).
jherb is offline   Reply With Quote

Old   March 11, 2015, 05:16
Smile
  #3
Member
 
Join Date: Jul 2012
Posts: 67
Rep Power: 13
Carlen is on a distinguished road
Quote:
Originally Posted by jherb View Post
I think resize is not necessary for a HashTable. You can access individual elements with
Code:
findDroplet_[1] = 1.234;
label index = 2;
findDroplet_[index] = 1.234;
info<<findDroplet_[2];
You use label (i.e. integer) as key. You could also use word (i. e. strings).
Thank you Joachim Herb and apologise for the late reply, I figured out how to use HashTable in OpenFoam.

Best regards,
Carlen
Carlen 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
Run time Selection Mechanism - Some help required to understand jaswi OpenFOAM Programming & Development 3 October 29, 2015 13:42
HashTable use nathanael OpenFOAM Programming & Development 0 April 15, 2014 07:03
multidimensional hashtable? Farshad_Noravesh OpenFOAM 0 January 24, 2011 09:05
HashTable Binary write format deepsterblue OpenFOAM Bugs 1 March 16, 2010 10:03
Ordered HashTable olesen OpenFOAM 1 January 4, 2007 04:17


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