Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions src/amr/solvers/solver_ppc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ class SolverPPC : public ISolver<AMR_Types>
std::unordered_map<std::string, ParticleArray> tmpDomain;
std::unordered_map<std::string, ParticleArray> patchGhost;

template<typename Map>
static void add_to(Map& map, std::string const& key, ParticleArray const& ps)
{
// vector copy drops the capacity (over allocation of the source)
// we want to keep the overallocation somewhat - how much to be assessed
ParticleArray empty{ps.box()};

if (!map.count(key))
map.emplace(key, empty);
else
map.at(key) = empty;

auto& v = map.at(key);
v.reserve(ps.capacity());
v.replace_from(ps);
}

}; // end solverPPC

Expand Down Expand Up @@ -206,15 +222,9 @@ void SolverPPC<HybridModel, AMR_Types>::saveState_(level_t& level, ModelViews_t&
ss << state.patch->getGlobalId();
for (auto& pop : state.ions)
{
auto key = ss.str() + "_" + pop.name();
if (!tmpDomain.count(key))
tmpDomain.emplace(key, pop.domainParticles());
else
tmpDomain.at(key) = pop.domainParticles();
if (!patchGhost.count(key))
patchGhost.emplace(key, pop.patchGhostParticles());
else
patchGhost.at(key) = pop.patchGhostParticles();
std::string const key = ss.str() + "_" + pop.name();
add_to(tmpDomain, key, pop.domainParticles());
add_to(patchGhost, key, pop.patchGhostParticles());
}
}
}
Expand Down