diff options
author | 2020-02-05 12:44:06 -0800 | |
---|---|---|
committer | 2020-02-05 12:44:06 -0800 | |
commit | 5bde8a0df5a404fc2f3622493808930191da03c9 (patch) | |
tree | b3a5e7be14e10bed5193933897911f2877eb541f /Source/Particles/ParticleCreation/SmartCopy.cpp | |
parent | 4fa439b20251e815be8ae724d7ff274affa83c56 (diff) | |
parent | e3f379fd4a19a0c7f540c65f51da9f7531a0d32c (diff) | |
download | WarpX-5bde8a0df5a404fc2f3622493808930191da03c9.tar.gz WarpX-5bde8a0df5a404fc2f3622493808930191da03c9.tar.zst WarpX-5bde8a0df5a404fc2f3622493808930191da03c9.zip |
Merge pull request #598 from atmyers/elementary_process
Elementary process refactor
Diffstat (limited to 'Source/Particles/ParticleCreation/SmartCopy.cpp')
-rw-r--r-- | Source/Particles/ParticleCreation/SmartCopy.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Source/Particles/ParticleCreation/SmartCopy.cpp b/Source/Particles/ParticleCreation/SmartCopy.cpp new file mode 100644 index 000000000..7d323ce39 --- /dev/null +++ b/Source/Particles/ParticleCreation/SmartCopy.cpp @@ -0,0 +1,52 @@ +/* Copyright 2019-2020 Andrew Myers, Axel Huebl, + * Maxence Thevenet + * + * This file is part of WarpX. + * + * License: BSD-3-Clause-LBNL + */ +#include "SmartCopy.H" + +PolicyVec getPolicies (const NameMap& names) noexcept +{ + PolicyVec policies; + policies.resize(names.size()); + for (const auto& kv : names) + { + policies[kv.second] = initialization_policies[kv.first]; + } + return policies; +} + +SmartCopyTag getSmartCopyTag (const NameMap& src, const NameMap& dst) noexcept +{ + 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; +} |