4
4
5
5
#include < AMReX_WriteBinaryParticleData.H>
6
6
7
+ namespace amrex {
8
+
7
9
template <typename ParticleType, int NArrayReal, int NArrayInt,
8
10
template <class > class Allocator , class CellAssignor >
9
11
void
@@ -51,20 +53,18 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
51
53
{
52
54
Vector<int > write_real_comp;
53
55
Vector<std::string> tmp_real_comp_names;
54
- int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps () - AMREX_SPACEDIM : NStructReal + NumRealComps ();
55
56
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 )
57
59
{
58
60
write_real_comp.push_back (1 );
59
61
if (real_comp_names.empty ())
60
62
{
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));
64
64
}
65
65
else
66
66
{
67
- tmp_real_comp_names.push_back (real_comp_names[i]);
67
+ tmp_real_comp_names.push_back (real_comp_names[i-first_rcomp ]);
68
68
}
69
69
}
70
70
@@ -75,9 +75,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
75
75
write_int_comp.push_back (1 );
76
76
if (int_comp_names.empty ())
77
77
{
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));
81
79
}
82
80
else
83
81
{
@@ -90,6 +88,21 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
90
88
FilterPositiveID{}, true );
91
89
}
92
90
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
+
93
106
template <typename ParticleType, int NArrayReal, int NArrayInt,
94
107
template <class > class Allocator , class CellAssignor >
95
108
void
@@ -98,24 +111,20 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
98
111
{
99
112
Vector<int > write_real_comp;
100
113
Vector<std::string> real_comp_names;
101
- int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps () - AMREX_SPACEDIM : NStructReal + NumRealComps ();
102
114
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 )
104
117
{
105
118
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));
109
120
}
110
121
111
122
Vector<int > write_int_comp;
112
123
Vector<std::string> int_comp_names;
113
124
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
114
125
{
115
126
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));
119
128
}
120
129
121
130
WriteBinaryParticleData (dir, name, write_real_comp, write_int_comp,
@@ -182,9 +191,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
182
191
Vector<std::string> int_comp_names;
183
192
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
184
193
{
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));
188
195
}
189
196
190
197
WriteBinaryParticleData (dir, name,
@@ -211,20 +218,16 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
211
218
AMREX_ASSERT (write_int_comp.size () == NStructInt + NArrayInt );
212
219
213
220
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 )
216
223
{
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));
220
225
}
221
226
222
227
Vector<std::string> int_comp_names;
223
228
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
224
229
{
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));
228
231
}
229
232
230
233
WriteBinaryParticleData (dir, name, write_real_comp, write_int_comp,
@@ -259,24 +262,20 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
259
262
{
260
263
Vector<int > write_real_comp;
261
264
Vector<std::string> real_comp_names;
262
- int nrc = ParticleType::is_soa_particle ? NStructReal + NumRealComps () - AMREX_SPACEDIM : NStructReal + NumRealComps ();
263
265
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 )
265
268
{
266
269
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));
270
271
}
271
272
272
273
Vector<int > write_int_comp;
273
274
Vector<std::string> int_comp_names;
274
275
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
275
276
{
276
277
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));
280
279
}
281
280
282
281
WriteBinaryParticleData (dir, name, write_real_comp, write_int_comp,
@@ -345,9 +344,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
345
344
Vector<std::string> int_comp_names;
346
345
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
347
346
{
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));
351
348
}
352
349
353
350
WriteBinaryParticleData (dir, name,
@@ -374,20 +371,16 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
374
371
AMREX_ASSERT (write_int_comp.size () == NStructInt + NumIntComps () );
375
372
376
373
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 )
379
376
{
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));
383
378
}
384
379
385
380
Vector<std::string> int_comp_names;
386
381
for (int i = 0 ; i < NStructInt + NumIntComps (); ++i )
387
382
{
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));
391
384
}
392
385
393
386
WriteBinaryParticleData (dir, name, write_real_comp, write_int_comp,
@@ -1283,4 +1276,6 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
1283
1276
}
1284
1277
}
1285
1278
1279
+ }
1280
+
1286
1281
#endif /* AMREX_PARTICLEIO_H*/
0 commit comments