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

How can I make my algorithm for finding duplicates more OpenFOAMic

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 16, 2018, 13:11
Default How can I make my algorithm for finding duplicates more OpenFOAMic
  #1
Member
 
Victor Koppejan
Join Date: May 2015
Posts: 40
Rep Power: 11
vkoppejan is on a distinguished road
Dear All,

I've coded the following algorithm to find duplicate entries in a List or Field of vectors.

I first concatenate the coordinates into a string, compute the hash of this string and then request the uniqueOrder of the container of hashes.

However I can't do this without std::string, std::to_string and std::hash. Any tips on how to do this using builtin OpenFOAM structures and functions?

Thanks in advance,

Victor

Code:
    List<label> pointBasedStencil::findUniquePoints(const Field<vector>& src)
    {
        // create hashes for entries in list using to_string
        List<label> hashlist;
        std::hash<std::string> hf;
        forAll(src,i) {
            std::string s(std::to_string(src[i].x() )
                           + std::to_string(src[i].y() )
                           + std::to_string(src[i].z() )
                            );
            hashlist.append(hf(s) );
        }

        // find unique indices
        List<label> order;
        uniqueOrder(hashlist, order);
        return order;
    }
vkoppejan 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
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 04:26
OpenFOAM with IBM AIX matthias OpenFOAM Installation 20 March 25, 2008 02:36
Compiling OpenFOAM13 on AMD64 with OpenSUSE 101 silent_missile OpenFOAM Installation 5 August 10, 2007 07:31
a way to make lots of money quick and easy no lies Dob Main CFD Forum 0 October 10, 2006 16:45
FOAM installation error gcc amp g hanks OpenFOAM Installation 9 January 26, 2006 14:14


All times are GMT -4. The time now is 03:52.