Skip to content

Commit 395bca2

Browse files
committed
restore old ParticleIO.H
1 parent 1948688 commit 395bca2

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

Src/Particle/AMReX_ParticleIO.H

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <AMReX_WriteBinaryParticleData.H>
66

7+
namespace amrex {
8+
79
template <typename ParticleType, int NArrayReal, int NArrayInt,
810
template<class> class Allocator, class CellAssignor>
911
void
@@ -51,20 +53,18 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
5153
{
5254
Vector<int> write_real_comp;
5355
Vector<std::string> tmp_real_comp_names;
54-
int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps() - AMREX_SPACEDIM : NStructReal + NumRealComps();
5556

56-
for (int i = 0; i < nrc; ++i )
57+
int first_rcomp = ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
58+
for (int i = first_rcomp; i < NStructReal + NumRealComps(); ++i )
5759
{
5860
write_real_comp.push_back(1);
5961
if (real_comp_names.empty())
6062
{
61-
std::stringstream ss;
62-
ss << "real_comp" << i;
63-
tmp_real_comp_names.push_back(ss.str());
63+
tmp_real_comp_names.push_back(getDefaultCompNameReal<ParticleType>(i));
6464
}
6565
else
6666
{
67-
tmp_real_comp_names.push_back(real_comp_names[i]);
67+
tmp_real_comp_names.push_back(real_comp_names[i-first_rcomp]);
6868
}
6969
}
7070

@@ -75,9 +75,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
7575
write_int_comp.push_back(1);
7676
if (int_comp_names.empty())
7777
{
78-
std::stringstream ss;
79-
ss << "int_comp" << i;
80-
tmp_int_comp_names.push_back(ss.str());
78+
tmp_int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
8179
}
8280
else
8381
{
@@ -90,6 +88,21 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
9088
FilterPositiveID{}, true);
9189
}
9290

91+
template <typename ParticleType, int NArrayReal, int NArrayInt,
92+
template<class> class Allocator, class CellAssignor>
93+
void
94+
ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
95+
::Checkpoint (const std::string& dir, const std::string& name,
96+
const Vector<int>& write_real_comp,
97+
const Vector<int>& write_int_comp,
98+
const Vector<std::string>& real_comp_names,
99+
const Vector<std::string>& int_comp_names) const
100+
{
101+
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
102+
real_comp_names, int_comp_names,
103+
FilterPositiveID{}, true);
104+
}
105+
93106
template <typename ParticleType, int NArrayReal, int NArrayInt,
94107
template<class> class Allocator, class CellAssignor>
95108
void
@@ -98,24 +111,20 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
98111
{
99112
Vector<int> write_real_comp;
100113
Vector<std::string> real_comp_names;
101-
int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps() - AMREX_SPACEDIM : NStructReal + NumRealComps();
102114

103-
for (int i = 0; i < nrc; ++i )
115+
int first_rcomp = ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
116+
for (int i = first_rcomp; i < NStructReal + NumRealComps(); ++i )
104117
{
105118
write_real_comp.push_back(1);
106-
std::stringstream ss;
107-
ss << "real_comp" << i;
108-
real_comp_names.push_back(ss.str());
119+
real_comp_names.push_back(getDefaultCompNameReal<ParticleType>(i));
109120
}
110121

111122
Vector<int> write_int_comp;
112123
Vector<std::string> int_comp_names;
113124
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
114125
{
115126
write_int_comp.push_back(1);
116-
std::stringstream ss;
117-
ss << "int_comp" << i;
118-
int_comp_names.push_back(ss.str());
127+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
119128
}
120129

121130
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
@@ -182,9 +191,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
182191
Vector<std::string> int_comp_names;
183192
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
184193
{
185-
std::stringstream ss;
186-
ss << "int_comp" << i;
187-
int_comp_names.push_back(ss.str());
194+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
188195
}
189196

190197
WriteBinaryParticleData(dir, name,
@@ -211,20 +218,16 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
211218
AMREX_ASSERT(write_int_comp.size() == NStructInt + NArrayInt );
212219

213220
Vector<std::string> real_comp_names;
214-
int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps() - AMREX_SPACEDIM : NStructReal + NumRealComps();
215-
for (int i = 0; i < nrc; ++i )
221+
int first_rcomp = ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
222+
for (int i = first_rcomp; i < NStructReal + NumRealComps(); ++i )
216223
{
217-
std::stringstream ss;
218-
ss << "real_comp" << i;
219-
real_comp_names.push_back(ss.str());
224+
real_comp_names.push_back(getDefaultCompNameReal<ParticleType>(i));
220225
}
221226

222227
Vector<std::string> int_comp_names;
223228
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
224229
{
225-
std::stringstream ss;
226-
ss << "int_comp" << i;
227-
int_comp_names.push_back(ss.str());
230+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
228231
}
229232

230233
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
@@ -259,24 +262,20 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
259262
{
260263
Vector<int> write_real_comp;
261264
Vector<std::string> real_comp_names;
262-
int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps() - AMREX_SPACEDIM : NStructReal + NumRealComps();
263265

264-
for (int i = 0; i < nrc; ++i )
266+
int first_rcomp = ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
267+
for (int i = first_rcomp; i < NStructReal + NumRealComps(); ++i )
265268
{
266269
write_real_comp.push_back(1);
267-
std::stringstream ss;
268-
ss << "real_comp" << i;
269-
real_comp_names.push_back(ss.str());
270+
real_comp_names.push_back(getDefaultCompNameReal<ParticleType>(i));
270271
}
271272

272273
Vector<int> write_int_comp;
273274
Vector<std::string> int_comp_names;
274275
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
275276
{
276277
write_int_comp.push_back(1);
277-
std::stringstream ss;
278-
ss << "int_comp" << i;
279-
int_comp_names.push_back(ss.str());
278+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
280279
}
281280

282281
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
@@ -345,9 +344,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
345344
Vector<std::string> int_comp_names;
346345
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
347346
{
348-
std::stringstream ss;
349-
ss << "int_comp" << i;
350-
int_comp_names.push_back(ss.str());
347+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
351348
}
352349

353350
WriteBinaryParticleData(dir, name,
@@ -374,20 +371,16 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
374371
AMREX_ASSERT(write_int_comp.size() == NStructInt + NumIntComps() );
375372

376373
Vector<std::string> real_comp_names;
377-
int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps() - AMREX_SPACEDIM : NStructReal + NumRealComps();
378-
for (int i = 0; i < nrc; ++i )
374+
int first_rcomp = ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0;
375+
for (int i = first_rcomp; i < NStructReal + NumRealComps(); ++i )
379376
{
380-
std::stringstream ss;
381-
ss << "real_comp" << i;
382-
real_comp_names.push_back(ss.str());
377+
real_comp_names.push_back(getDefaultCompNameReal<ParticleType>(i));
383378
}
384379

385380
Vector<std::string> int_comp_names;
386381
for (int i = 0; i < NStructInt + NumIntComps(); ++i )
387382
{
388-
std::stringstream ss;
389-
ss << "int_comp" << i;
390-
int_comp_names.push_back(ss.str());
383+
int_comp_names.push_back(getDefaultCompNameInt<ParticleType>(i));
391384
}
392385

393386
WriteBinaryParticleData(dir, name, write_real_comp, write_int_comp,
@@ -1283,4 +1276,6 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
12831276
}
12841277
}
12851278

1279+
}
1280+
12861281
#endif /*AMREX_PARTICLEIO_H*/

0 commit comments

Comments
 (0)