Skip to content

Commit 1c4a19b

Browse files
committed
Clean up Iteration finalizing logic
1 parent 097ecb3 commit 1c4a19b

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

include/openPMD/Mesh.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class Mesh
4545
{
4646
friend class Container<Mesh>;
4747
friend class Iteration;
48-
friend class internal::ScientificDefaults<Mesh>;
48+
template <typename>
49+
friend class internal::ScientificDefaults;
4950

5051
public:
5152
Mesh(Mesh const &) = default;

include/openPMD/ParticleSpecies.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class ParticleSpecies
4040
friend class Iteration;
4141
template <typename T>
4242
friend T &internal::makeOwning(T &self, Series);
43-
friend class internal::ScientificDefaults<ParticleSpecies>;
43+
template <typename>
44+
friend class internal::ScientificDefaults;
4445

4546
public:
4647
ParticlePatches particlePatches;

src/Iteration.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,20 +113,12 @@ Iteration &Iteration::close(bool _flush)
113113
// yet keeps it re-openable)
114114
break;
115115
}
116+
116117
{
117118
Access at = IOHandler()->m_frontendAccess;
118119
finalize(at);
119-
for (auto &[_, mesh] : meshes)
120-
{
121-
(void)_;
122-
mesh.internal::ScientificDefaults<Mesh>::finalize(at);
123-
}
124-
for (auto &[_, ps] : particles)
125-
{
126-
(void)_;
127-
ps.finalize(at);
128-
}
129120
}
121+
130122
if (_flush)
131123
{
132124
if (flag == StepStatus::DuringStep)

src/backend/ScientificDefaults.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,26 @@ void ScientificDefaults<Child>::finalize(Access at)
134134
}
135135
}
136136
}
137+
// sic! no else
137138

138-
if constexpr (std::is_same_v<Child, ParticleSpecies>)
139+
if constexpr (std::is_same_v<Child, Iteration>)
140+
{
141+
for (auto &[_, right] : asChild().meshes)
142+
{
143+
(void)_;
144+
right.ScientificDefaults<Mesh>::finalize(at);
145+
}
146+
for (auto &[_, right] : asChild().particles)
147+
{
148+
(void)_;
149+
right.ScientificDefaults<ParticleSpecies>::finalize(at);
150+
}
151+
}
152+
else if constexpr (std::is_same_v<Child, ParticleSpecies>)
139153
{
140154
for (auto &[_, right] : asChild().particlePatches)
141155
{
156+
(void)_;
142157
right
143158
.ScientificDefaults<BaseRecord<PatchRecordComponent>>::finalize(
144159
at);

0 commit comments

Comments
 (0)