Skip to content

Commit 78bdf0f

Browse files
authored
Fix: Names in PC::make_alike (#4322)
## Summary The ParticleContainer's `make_alike` function must not forget the names of the SoA components. Currently, it creates a new container with the same components, but default names. ## Additional background First seen in BLAST-WarpX/warpx#5481 ## Checklist The proposed changes: - [x] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 779df09 commit 78bdf0f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Src/Particle/AMReX_ParticleContainer.H

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,11 +1374,25 @@ public:
13741374
{
13751375
ContainerLike<NewAllocator> tmp(m_gdb);
13761376

1377+
std::vector<std::string> const real_names = this->GetRealSoANames();
1378+
std::vector<std::string> real_ct_names(NArrayReal);
1379+
for (int ic = 0; ic < NArrayReal; ++ic) { real_ct_names.at(ic) = real_names[ic]; }
1380+
1381+
std::vector<std::string> const int_names = this->GetIntSoANames();
1382+
std::vector<std::string> int_ct_names(NArrayInt);
1383+
for (int ic = 0; ic < NArrayInt; ++ic) { int_ct_names.at(ic) = int_names[ic]; }
1384+
1385+
tmp.SetSoACompileTimeNames(real_ct_names, int_ct_names);
1386+
13771387
// add runtime real comps to tmp
1378-
for (int ic = 0; ic < this->NumRuntimeRealComps(); ++ic) { tmp.AddRealComp(false); }
1388+
for (int ic = 0; ic < this->NumRuntimeRealComps(); ++ic) {
1389+
tmp.AddRealComp(real_names.at(ic + NArrayReal), false);
1390+
}
13791391

13801392
// add runtime int comps to tmp
1381-
for (int ic = 0; ic < this->NumRuntimeIntComps(); ++ic) { tmp.AddIntComp(false); }
1393+
for (int ic = 0; ic < this->NumRuntimeIntComps(); ++ic) {
1394+
tmp.AddIntComp(int_names.at(ic + NArrayInt), false);
1395+
}
13821396

13831397
return tmp;
13841398
}

0 commit comments

Comments
 (0)