aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/ParticleCreation/SmartCopy.cpp
blob: 88e687503fe85ba5f0b18cbb8724f26e67d6004b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "SmartCopy.H"

SmartCopyTag getSmartCopyTag (const NameMap& src, const NameMap& dst)
{
    SmartCopyTag tag;

    // we use the fact that maps are sorted
    auto i_src = src.begin();
    auto i_dst = dst.begin();
    while ( (i_src != src.end()) and (i_dst != dst.end()) )
    {
        if (i_src->first < i_dst->first)
        {
            // names are not the same and src is lower
            ++i_src;
        }
        else if (i_src->first > i_dst->first)
        {
            // names are not the same and dst is lower
            ++i_dst;
        }
        else
        {
            // name is in both...
            tag.common_names.push_back(i_src->first);
            tag.src_comps.push_back(i_src->second);
            tag.dst_comps.push_back(i_dst->second);
            ++i_src;
            ++i_dst;
        }
    }

    return tag;
}