Compilation fails under OF1806+
Hello,
I have an OpenFOAM code that compiles and runs properly under OpenFOAM 6. Now I switched to OpenFOAM V1806 but unfortunately the code doesn't compile. After reading the errors reported by the compiler, I understand that the problem is caused by hashtable, so I decided to isolate the problem and I created the sample code below that produces the same error: The code: Code:
#include "fvCFD.H" Code:
... Could you please help me debug this problem, is it a bug? Update: After changing the type of key to word it works, Could you please confirm that hashtables in OpenFOAM v1806 work only with string keys? |
Problem solved!
using: Code:
|
Your posted solution is correct
Code:
Code:
As you've discovered, the HashTable uses a 'word' as its default key, and hashes on that accordingly. If you change the type of the key used in the HashTable, you should be careful that the hashing method also matches. With Code:
HashTable<List<label>, label> myHash; Code:
/home/evren/OpenFOAM/OpenFOAM-v1806/src/OpenFOAM/lnInclude/HashTableI.H:35: error: no match for call to ‘(Foam::string::hash) (const int&)’ Since using a 'label' as the key for a HashTable is fairly useful, you would expect that it must be easier than all of this (with much less typing). Indeed it is. The updated code that you should actually be using would be a Map: Code:
Map<labelList> myHash; /mark |
Quote:
Could also use something this Code:
void fillHashTable(Map<labelList>& hashTable, label maxN) |
Thank you very much for the detailed answer
|
All times are GMT -4. The time now is 09:09. |