Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 9 additions & 0 deletions include/openPMD/RecordComponent.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ RecordComponent::storeChunk(Offset o, Extent e, F &&createBuffer)
dCreate.name = rc.m_name;
IOHandler()->enqueue(IOTask(this, dCreate));
}

if (size == 0)
{
// Don't forward this operation to the backend as it might create ugly
// zero-blocks in ADIOS2
setDirtyRecursive(true);
return DynamicMemoryView<T>();
}

Parameter<Operation::GET_BUFFER_VIEW> getBufferView;
getBufferView.offset = o;
getBufferView.extent = e;
Expand Down
5 changes: 4 additions & 1 deletion include/openPMD/Span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ class DynamicMemoryView
}

public:
explicit DynamicMemoryView() = default;
explicit DynamicMemoryView()
{
m_param.out->backendManagedBuffer = false;
}

/**
* @brief Acquire the underlying buffer at its current position in memory.
Expand Down
1 change: 1 addition & 0 deletions include/openPMD/backend/BaseRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "openPMD/backend/Container.hpp"

#include <array>
#include <optional>
Comment thread
franzpoeschel marked this conversation as resolved.
Outdated
#include <stdexcept>
#include <string>
#include <type_traits> // std::remove_reference_t
Expand Down
27 changes: 21 additions & 6 deletions src/Iteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,14 @@ void Iteration::flush(internal::FlushParams const &flushParams)
s.setMeshesPath("meshes/");
s.flushMeshesPath();
}
meshes.flush(s.meshesPath(), flushParams);
for (auto &m : meshes)
m.second.flush(m.first, flushParams);
if (meshes.dirtyRecursive())
{
meshes.flush(s.meshesPath(), flushParams);
for (auto &m : meshes)
{
m.second.flush(m.first, flushParams);
}
}
}
else
{
Expand All @@ -378,9 +383,14 @@ void Iteration::flush(internal::FlushParams const &flushParams)
s.setParticlesPath("particles/");
s.flushParticlesPath();
}
particles.flush(s.particlesPath(), flushParams);
for (auto &species : particles)
species.second.flush(species.first, flushParams);
if (particles.dirtyRecursive())
{
particles.flush(s.particlesPath(), flushParams);
for (auto &species : particles)
{
species.second.flush(species.first, flushParams);
}
}
}
else
{
Expand Down Expand Up @@ -470,6 +480,11 @@ void Iteration::readGorVBased(

void Iteration::read_impl(std::string const &groupPath)
{
if (!get().m_deferredParseAccess.has_value())
{
throw error::Internal(
"Attempted reparsing an Iteration that is already parsed.");
}
Parameter<Operation::OPEN_PATH> pOpen;
pOpen.path = groupPath;
IOHandler()->enqueue(IOTask(this, pOpen));
Expand Down
4 changes: 4 additions & 0 deletions src/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ template Mesh &Mesh::setTimeOffset(float);
void Mesh::flush_impl(
std::string const &name, internal::FlushParams const &flushParams)
{
if (!dirtyRecursive())
{
return;
}
if (access::readOnly(IOHandler()->m_frontendAccess))
{
auto &m = get();
Expand Down
19 changes: 13 additions & 6 deletions src/ParticleSpecies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ namespace
void ParticleSpecies::flush(
std::string const &path, internal::FlushParams const &flushParams)
{
if (!dirtyRecursive())
{
return;
}
if (access::readOnly(IOHandler()->m_frontendAccess))
{
for (auto &record : *this)
Expand All @@ -168,12 +172,15 @@ void ParticleSpecies::flush(
}
else
{
auto it = find("position");
if (it != end())
it->second.setUnitDimension({{UnitDimension::L, 1}});
it = find("positionOffset");
if (it != end())
it->second.setUnitDimension({{UnitDimension::L, 1}});
if (flushParams.flushLevel != FlushLevel::SkeletonOnly)
{
auto it = find("position");
if (it != end())
it->second.setUnitDimension({{UnitDimension::L, 1}});
it = find("positionOffset");
if (it != end())
it->second.setUnitDimension({{UnitDimension::L, 1}});
}

Container<Record>::flush(path, flushParams);

Expand Down
8 changes: 6 additions & 2 deletions src/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ Record &Record::setUnitDimension(unit_representations::AsMap const &udim)
}
Record &Record::setUnitDimension(unit_representations::AsArray const &udim)
{
return setUnitDimension(
unit_representations::asMap(udim, /* skip_zeros = */ false));
setAttribute("unitDimension", udim);
return *this;
}

void Record::flush_impl(
std::string const &name, internal::FlushParams const &flushParams)
{
if (!dirtyRecursive())
{
return;
}
if (access::readOnly(IOHandler()->m_frontendAccess))
{
if (scalar())
Expand Down
4 changes: 4 additions & 0 deletions src/RecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ bool RecordComponent::empty() const
void RecordComponent::flush(
std::string const &name, internal::FlushParams const &flushParams)
{
if (!dirtyRecursive())
{
return;
}
auto &rc = get();
if (flushParams.flushLevel == FlushLevel::SkeletonOnly)
{
Expand Down
5 changes: 5 additions & 0 deletions src/backend/BaseRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,11 @@ template <typename T_elem>
inline void BaseRecord<T_elem>::flush(
std::string const &name, internal::FlushParams const &flushParams)
{
if (!this->dirtyRecursive())
{
return;
}

if (!this->written() && this->empty() && !this->datasetDefined())
throw std::runtime_error(
"A Record can not be written without any contained "
Expand Down
4 changes: 4 additions & 0 deletions src/backend/MeshRecordComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ void MeshRecordComponent::read()
void MeshRecordComponent::flush(
std::string const &name, internal::FlushParams const &params)
{
if (!dirtyRecursive())
{
return;
}
if (access::write(IOHandler()->m_frontendAccess) &&
!containsAttribute("position"))
{
Expand Down
4 changes: 4 additions & 0 deletions src/backend/PatchRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ PatchRecord::setUnitDimension(std::map<UnitDimension, double> const &udim)
void PatchRecord::flush_impl(
std::string const &path, internal::FlushParams const &flushParams)
{
if (!dirtyRecursive())
{
return;
}
if (!this->datasetDefined())
{
if (IOHandler()->m_frontendAccess != Access::READ_ONLY)
Expand Down
Loading