Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fb251ca
Base structure for scientific defaults
franzpoeschel Jan 12, 2026
205461e
Start adding defaults
franzpoeschel Jan 12, 2026
2d29a95
debugging output
franzpoeschel Jan 12, 2026
372830c
Fixes
franzpoeschel Jan 12, 2026
ca09aa6
BaseRecord --> unitDimension
franzpoeschel Jan 12, 2026
e0a92ef
nunja hehe
franzpoeschel Jan 12, 2026
a7b265b
Fixes
franzpoeschel Jan 12, 2026
9e1070c
Further fixes
franzpoeschel Jan 13, 2026
bfcdb11
further fixes
franzpoeschel Jan 13, 2026
fe005ec
tests temporarily passing :D
franzpoeschel Jan 13, 2026
2970deb
Cleanup
franzpoeschel Jan 13, 2026
e4e5b0a
UnitDimension for position/positionOffset
franzpoeschel Jan 13, 2026
54dc778
WIP: RecordComponent stuff
franzpoeschel Jan 13, 2026
f9ba472
Fix coretests
franzpoeschel Jan 14, 2026
55e9dbf
Clean up Iteration finalizing logic
franzpoeschel Jan 14, 2026
baaa1d5
Add defaults for Iteration class
franzpoeschel Jan 14, 2026
fecdae2
Fix variadic template template parameters
franzpoeschel Jan 15, 2026
af0d1a9
Factor this out: Fix deletion
franzpoeschel Jan 15, 2026
2115ede
Remove flush-time check for populized components
franzpoeschel Jan 16, 2026
03b283b
Make the default specification more flexible
franzpoeschel Jan 16, 2026
7cc2d4e
WIP
franzpoeschel Jan 20, 2026
0b8c9aa
continue
franzpoeschel Jan 20, 2026
9de0afe
Split this into internal and public header
franzpoeschel Jan 21, 2026
9b57d6f
Distinguish writing from reading
franzpoeschel Jan 21, 2026
f1a78a1
Tests now working again
franzpoeschel Jan 21, 2026
935319d
Mostly move Mesh reading to ScientificDefaults
franzpoeschel Jan 21, 2026
c6c99e2
Fix type conversions between char and string
franzpoeschel Jan 21, 2026
055195a
Somewhat working Mesh reading
franzpoeschel Jan 21, 2026
c2cddc5
Fix little parent call bug
franzpoeschel Jan 22, 2026
3e7c542
Mention expected datatypes in attribute reading error messages
franzpoeschel Jan 22, 2026
13cbf3d
Move Iteration reading to ScientificDefaults class
franzpoeschel Jan 22, 2026
76a765a
Introduce genericsetter, use for unitDimension
franzpoeschel Jan 22, 2026
889646d
Record / BaseRecord Reading
franzpoeschel Jan 22, 2026
0b3a8af
Readers for everything now except version-dependent stuff
franzpoeschel Jan 22, 2026
d8c66a6
Add gridUnitDimension in ScientificDefaults
franzpoeschel Jan 23, 2026
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ set(CORE_SOURCE
src/backend/PatchRecord.cpp
src/backend/PatchRecordComponent.cpp
src/backend/Writable.cpp
src/backend/ScientificDefaults.cpp
src/auxiliary/OneDimensionalBlockSlicer.cpp
src/helper/list_series.cpp
src/snapshots/ContainerImpls.cpp
Expand Down
6 changes: 5 additions & 1 deletion include/openPMD/Iteration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "openPMD/auxiliary/Variant.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/Container.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <cstdint>
#include <deque>
Expand Down Expand Up @@ -142,7 +143,9 @@ namespace internal
* @see
* https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#required-attributes-for-the-basepath
*/
class Iteration : public Attributable
class Iteration
: public Attributable
, internal::ScientificDefaults<Iteration>
{
template <typename T, typename T_key, typename T_container>
friend class Container;
Expand All @@ -153,6 +156,7 @@ class Iteration : public Attributable
friend class Writable;
friend class StatefulIterator;
friend class StatefulSnapshotsContainer;
friend class internal::ScientificDefaults<Iteration>;

public:
Iteration(Iteration const &) = default;
Expand Down
14 changes: 13 additions & 1 deletion include/openPMD/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
#include "openPMD/UnitDimension.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/BaseRecord.hpp"
#include "openPMD/backend/Container.hpp"
#include "openPMD/backend/MeshRecordComponent.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <ostream>
#include <string>
Expand All @@ -37,10 +39,14 @@ namespace openPMD
* @see
* https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#mesh-based-records
*/
class Mesh : public BaseRecord<MeshRecordComponent>
class Mesh
: public BaseRecord<MeshRecordComponent>
, internal::ScientificDefaults<Mesh>
{
friend class Container<Mesh>;
friend class Iteration;
template <typename>
friend class internal::ScientificDefaults;

public:
Mesh(Mesh const &) = default;
Expand Down Expand Up @@ -328,8 +334,14 @@ class Mesh : public BaseRecord<MeshRecordComponent>
void
flush_impl(std::string const &, internal::FlushParams const &) override;
void read();
auto retrieveDimensionality() const -> uint64_t;
}; // Mesh

static_assert(internal::IsContainer_v<Mesh>);
static_assert(std::is_same_v<
Container<MeshRecordComponent>,
internal::AsContainer_t<Mesh>>);

template <typename T>
inline std::vector<T> Mesh::gridSpacing() const
{
Expand Down
7 changes: 6 additions & 1 deletion include/openPMD/ParticleSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@
#include "openPMD/Record.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/Container.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <string>

namespace openPMD
{

class ParticleSpecies : public Container<Record>
class ParticleSpecies
: public Container<Record>
, internal::ScientificDefaults<ParticleSpecies>
{
friend class Container<ParticleSpecies>;
friend class Container<Record>;
friend class Iteration;
template <typename T>
friend T &internal::makeOwning(T &self, Series);
template <typename>
friend class internal::ScientificDefaults;

public:
ParticlePatches particlePatches;
Expand Down
9 changes: 8 additions & 1 deletion include/openPMD/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
#include "openPMD/RecordComponent.hpp"
#include "openPMD/UnitDimension.hpp"
#include "openPMD/backend/BaseRecord.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <string>
#include <type_traits>

namespace openPMD
{
class Record : public BaseRecord<RecordComponent>
class Record
: public BaseRecord<RecordComponent>
, internal::ScientificDefaults<Record>
{
friend class Container<Record>;
friend class Iteration;
friend class ParticleSpecies;
template <typename>
friend class internal::ScientificDefaults;

public:
Record(Record const &) = default;
Expand All @@ -57,6 +62,8 @@ class Record : public BaseRecord<RecordComponent>
[[nodiscard]] internal::HomogenizeExtents read();
}; // Record

static_assert(internal::HasScientificDefaults_v<Record>);

template <typename T>
inline T Record::timeOffset() const
{
Expand Down
11 changes: 8 additions & 3 deletions include/openPMD/RecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "openPMD/auxiliary/UniquePtr.hpp"
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/BaseRecordComponent.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

// comment to prevent this include from being moved by clang-format
#include "openPMD/DatatypeMacros.hpp"
Expand Down Expand Up @@ -110,7 +111,9 @@ namespace internal
template <typename>
class BaseRecord;

class RecordComponent : public BaseRecordComponent
class RecordComponent
: public BaseRecordComponent
, internal::ScientificDefaults<RecordComponent>
{
template <typename T, typename T_key, typename T_container>
friend class Container;
Expand All @@ -128,6 +131,8 @@ class RecordComponent : public BaseRecordComponent
friend class MeshRecordComponent;
template <typename T>
friend T &internal::makeOwning(T &self, Series);
template <typename>
friend class internal::ScientificDefaults;

public:
enum class Allocation
Expand Down Expand Up @@ -486,7 +491,7 @@ class RecordComponent : public BaseRecordComponent

protected:
void flush(std::string const &, internal::FlushParams const &);
void read(bool require_unit_si);
void read();

private:
/**
Expand Down Expand Up @@ -534,7 +539,7 @@ OPENPMD_protected
BaseRecordComponent::setData(m_recordComponentData);
}

void readBase(bool require_unit_si);
void readBase();

template <typename T>
void verifyChunk(Offset const &, Extent const &) const;
Expand Down
28 changes: 28 additions & 0 deletions include/openPMD/auxiliary/TypeTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,34 @@ namespace detail
// little trick to avoid trailing commas in the macro expansions below
template <typename Arg, typename... Args>
using variant_tail_t = std::variant<Args...>;

template <template <typename...> class Base, typename... Args>
auto infer_template_args(Base<Args...> &) -> Base<Args...>;

template <
template <typename...> class Base,
typename T,
typename SFINAE = void>
struct IsTemplateBaseOf
{
static constexpr bool value = false;
};

template <template <typename...> class Base, typename T>
struct IsTemplateBaseOf<
Base,
T,
std::void_t<decltype(detail::infer_template_args<Base>(
std::declval<T &>()))>>
{
static constexpr bool value = true;
using type =
decltype(detail::infer_template_args<Base>(std::declval<T &>()));
};
} // namespace detail

template <template <typename...> class Base, typename T>
constexpr bool IsTemplateBaseOf_v = detail::IsTemplateBaseOf<Base, T>::value;
template <template <typename...> class Base, typename T>
using AsTemplateBase_t = typename detail::IsTemplateBaseOf<Base, T>::type;
} // namespace openPMD::auxiliary
4 changes: 4 additions & 0 deletions include/openPMD/backend/Attributable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ namespace internal
class IterationData;
class SeriesData;
struct HomogenizeExtents;
template <typename, typename, typename, typename>
struct ConfigAttributeWithSetterAndReader;

class SharedAttributableData
{
Expand Down Expand Up @@ -244,6 +246,8 @@ class Attributable
friend class internal::AttributableData;
friend class Snapshots;
friend struct internal::HomogenizeExtents;
template <typename, typename, typename, typename>
friend struct internal::ConfigAttributeWithSetterAndReader;

protected:
// tag for internal constructor
Expand Down
4 changes: 4 additions & 0 deletions include/openPMD/backend/BaseRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "openPMD/auxiliary/Variant.hpp"
#include "openPMD/backend/BaseRecordComponent.hpp"
#include "openPMD/backend/Container.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <array>
#include <stdexcept>
Expand Down Expand Up @@ -179,6 +180,7 @@ template <typename T_elem>
class BaseRecord
: public Container<T_elem>
, public T_elem // T_RecordComponent
, internal::ScientificDefaults<BaseRecord<T_elem>>
{
public:
using T_RecordComponent = T_elem;
Expand All @@ -197,6 +199,8 @@ class BaseRecord
friend class internal::ScalarIterator;
template <typename T>
friend T &internal::makeOwning(T &self, Series);
template <typename>
friend class internal::ScientificDefaults;

using Data_t =
internal::BaseRecordData<T_elem, typename T_RecordComponent::Data_t>;
Expand Down
9 changes: 9 additions & 0 deletions include/openPMD/backend/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "openPMD/Error.hpp"
#include "openPMD/IO/Access.hpp"
#include "openPMD/auxiliary/TypeTraits.hpp"
#include "openPMD/backend/Attributable.hpp"

#include <initializer_list>
Expand Down Expand Up @@ -343,5 +344,13 @@ namespace internal

~EraseStaleEntries();
};

template <typename T>
constexpr bool IsContainer_v = auxiliary::IsTemplateBaseOf_v<Container, T>;
template <typename T>
using AsContainer_t = auxiliary::AsTemplateBase_t<Container, T>;

static_assert(!IsContainer_v<int>);
static_assert(IsContainer_v<Container<Attributable>>);
} // namespace internal
} // namespace openPMD
7 changes: 6 additions & 1 deletion include/openPMD/backend/MeshRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once

#include "openPMD/RecordComponent.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <vector>

Expand All @@ -32,14 +33,18 @@ namespace internal
class BaseRecordData;
}

class MeshRecordComponent : public RecordComponent
class MeshRecordComponent
: public RecordComponent
, internal::ScientificDefaults<MeshRecordComponent>
{
template <typename T, typename T_key, typename T_container>
friend class Container;
template <typename>
friend class BaseRecord;
template <typename, typename>
friend class internal::BaseRecordData;
template <typename>
friend class internal::ScientificDefaults;

friend class Mesh;

Expand Down
11 changes: 8 additions & 3 deletions include/openPMD/backend/PatchRecord.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,25 @@

#include "openPMD/backend/BaseRecord.hpp"
#include "openPMD/backend/PatchRecordComponent.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <string>
#include <unordered_map>

namespace openPMD
{
class PatchRecord : public BaseRecord<PatchRecordComponent>
class PatchRecord
: public BaseRecord<PatchRecordComponent>
, internal::ScientificDefaults<PatchRecord>
{
friend class Container<PatchRecord>;
friend class ParticleSpecies;
friend class ParticlePatches;
template <typename>
friend class internal::ScientificDefaults;

public:
PatchRecord &setUnitDimension(std::map<UnitDimension, double> const &);
PatchRecord &setUnitDimension(unit_representations::AsMap const &);
PatchRecord &setUnitDimension(unit_representations::AsArray const &udim);
~PatchRecord() override = default;

private:
Expand Down
7 changes: 6 additions & 1 deletion include/openPMD/backend/PatchRecordComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "openPMD/RecordComponent.hpp"
#include "openPMD/auxiliary/ShareRawInternal.hpp"
#include "openPMD/backend/BaseRecordComponent.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <memory>
#include <sstream>
Expand All @@ -42,7 +43,9 @@ namespace openPMD
/**
* @todo add support for constant patch record components
*/
class PatchRecordComponent : public RecordComponent
class PatchRecordComponent
: public RecordComponent
, internal::ScientificDefaults<PatchRecordComponent>
{
template <typename T, typename T_key, typename T_container>
friend class Container;
Expand All @@ -53,6 +56,8 @@ class PatchRecordComponent : public RecordComponent
friend class ParticlePatches;
friend class PatchRecord;
friend class ParticleSpecies;
template <typename>
friend class internal::ScientificDefaults;

public:
/**
Expand Down
Loading
Loading