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

HashTable use

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 25, 2015, 03:50
Default HashTable use
  #1
Member
 
Join Date: Jul 2012
Posts: 55
Rep Power: 5
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, 08:00
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 294
Rep Power: 9
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, 06:16
Smile
  #3
Member
 
Join Date: Jul 2012
Posts: 55
Rep Power: 5
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

Thread Tools
Display Modes

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 On
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 2 April 18, 2014 07:44
HashTable use nathanael OpenFOAM Programming & Development 0 April 15, 2014 07:03
multidimensional hashtable? Farshad_Noravesh OpenFOAM 0 January 24, 2011 10:05
HashTable Binary write format deepsterblue OpenFOAM Bugs 1 March 16, 2010 11:03
Ordered HashTable olesen OpenFOAM 1 January 4, 2007 05:17


All times are GMT -4. The time now is 17:53.