Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
04bb452
Base structure for scientific defaults
franzpoeschel Jan 12, 2026
d67e3a5
Start adding defaults
franzpoeschel Jan 12, 2026
f7e67f2
debugging output
franzpoeschel Jan 12, 2026
2bb5492
Fixes
franzpoeschel Jan 12, 2026
2919dcd
BaseRecord --> unitDimension
franzpoeschel Jan 12, 2026
cb76326
nunja hehe
franzpoeschel Jan 12, 2026
b7afd8d
Fixes
franzpoeschel Jan 12, 2026
8f5567d
Further fixes
franzpoeschel Jan 13, 2026
8e9ae16
further fixes
franzpoeschel Jan 13, 2026
dc02217
tests temporarily passing :D
franzpoeschel Jan 13, 2026
a154726
Cleanup
franzpoeschel Jan 13, 2026
11ffcac
UnitDimension for position/positionOffset
franzpoeschel Jan 13, 2026
d492f82
WIP: RecordComponent stuff
franzpoeschel Jan 13, 2026
ab5e74f
Fix coretests
franzpoeschel Jan 14, 2026
dd8abd7
Clean up Iteration finalizing logic
franzpoeschel Jan 14, 2026
cbc18e2
Add defaults for Iteration class
franzpoeschel Jan 14, 2026
bc54d31
Fix variadic template template parameters
franzpoeschel Jan 15, 2026
34f6fb4
Remove flush-time check for populized components
franzpoeschel Jan 16, 2026
a0d94fd
Make the default specification more flexible
franzpoeschel Jan 16, 2026
d1a6308
WIP
franzpoeschel Jan 20, 2026
e04bec9
continue
franzpoeschel Jan 20, 2026
4376ff0
Split this into internal and public header
franzpoeschel Jan 21, 2026
75240b1
Distinguish writing from reading
franzpoeschel Jan 21, 2026
b113a0a
Tests now working again
franzpoeschel Jan 21, 2026
9d618e1
Mostly move Mesh reading to ScientificDefaults
franzpoeschel Jan 21, 2026
276d348
Fix type conversions between char and string
franzpoeschel Jan 21, 2026
1632f87
Somewhat working Mesh reading
franzpoeschel Jan 21, 2026
f4a3651
Fix little parent call bug
franzpoeschel Jan 22, 2026
4f09f2a
Mention expected datatypes in attribute reading error messages
franzpoeschel Jan 22, 2026
670d8b9
Move Iteration reading to ScientificDefaults class
franzpoeschel Jan 22, 2026
3bd203d
Introduce genericsetter, use for unitDimension
franzpoeschel Jan 22, 2026
5ccb280
Record / BaseRecord Reading
franzpoeschel Jan 22, 2026
d2b6872
Readers for everything now except version-dependent stuff
franzpoeschel Jan 22, 2026
4ab9f0f
Add gridUnitDimension in ScientificDefaults
franzpoeschel Jan 23, 2026
3ef3a33
Do not use templates for defaults setter
franzpoeschel Jan 26, 2026
785bdfa
Wew NewAttributeReader
franzpoeschel Jan 27, 2026
f0d1eae
Fixes
franzpoeschel Jan 27, 2026
4ca158d
Fixes
franzpoeschel Jan 27, 2026
deecaa4
Defaults for patchRecord
franzpoeschel Jan 27, 2026
07be509
Adapt PatchRecordComponent
franzpoeschel Jan 27, 2026
afa8d86
Fixes
franzpoeschel Jan 27, 2026
6bf3571
Cleanup
franzpoeschel Jan 28, 2026
5355d2a
Cleanup
franzpoeschel Jan 28, 2026
855bd82
Avoid overcomplex attribute type conversions
franzpoeschel Jan 28, 2026
04dbd3f
reduce binary size a bit
franzpoeschel Jan 28, 2026
987c85f
Try further reducing amount of lambdas...
franzpoeschel Jan 28, 2026
0cec645
Annotate MB sizes
franzpoeschel Jan 28, 2026
6b6d01c
Reduce implementation sizes for RequireScalar / RequireVector
franzpoeschel Jan 29, 2026
edabcb7
vibe-coded suggestions for size optimization
franzpoeschel Jan 29, 2026
5239087
Avoid using lambdas for require_type
franzpoeschel Jan 29, 2026
4e620f5
Change code order
franzpoeschel Jan 29, 2026
4f60c5f
Replace if constexpr with SFINAE
franzpoeschel Jan 30, 2026
81d986a
Fix nvhpc/msvc builds
franzpoeschel Jan 30, 2026
2b2463e
doxygen fix
franzpoeschel Feb 2, 2026
996051d
Cleanup
franzpoeschel Feb 4, 2026
865e15f
scientificdefaults_internal.cpp
franzpoeschel Feb 24, 2026
f04a7d9
Add visitor pattern
franzpoeschel Feb 24, 2026
93f1ec2
wip: ScientificDefaults without CRT
franzpoeschel Feb 24, 2026
6b4253b
Move defaults impl to classes
franzpoeschel Feb 24, 2026
2be85f0
Fix visitHierarchy
franzpoeschel Feb 24, 2026
e9a242c
Fix visithierarchy
franzpoeschel Feb 24, 2026
7e46729
Compiles
franzpoeschel Feb 24, 2026
7ef8956
Fix inheritance issue
franzpoeschel Feb 25, 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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ set(CORE_SOURCE
src/backend/PatchRecord.cpp
src/backend/PatchRecordComponent.cpp
src/backend/Writable.cpp
src/backend/ScientificDefaults.cpp
src/backend/ScientificDefaults_auxiliary.cpp
src/backend/ScientificDefaults_impl.cpp
src/auxiliary/OneDimensionalBlockSlicer.cpp
src/helper/list_series.cpp
src/snapshots/ContainerImpls.cpp
Expand Down
21 changes: 19 additions & 2 deletions 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
{
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;

public:
Iteration(Iteration const &) = default;
Expand Down Expand Up @@ -268,6 +272,14 @@ class Iteration : public Attributable
[[deprecated("This attribute is no longer set by the openPMD-api.")]] bool
closedByWriter() const;

template <typename Visitor>
void visitHierarchy(Visitor &&v)
{
v(*this);
meshes.visitHierarchy(v);
particles.visitHierarchy(v);
}

Container<Mesh> meshes{};
Container<ParticleSpecies> particles{}; // particleSpecies?

Expand Down Expand Up @@ -337,6 +349,8 @@ class Iteration : public Attributable
void readMeshes(std::string const &meshesPath);
void readParticles(std::string const &particlesPath);

void setDefaultAttributes();

/**
* Status after beginning an IO step. Currently includes:
* * The advance status (OK, OVER, RANDOMACCESS)
Expand Down Expand Up @@ -421,14 +435,17 @@ class Iteration : public Attributable
*
* @param w The Writable representing the parent.
*/
virtual void linkHierarchy(Writable &w);
void linkHierarchy(Writable &w) override;

/**
* @brief Access an iteration in read mode that has potentially not been
* parsed yet.
*
*/
void runDeferredParseAccess();

protected:
void defaults_impl(bool write, OpenpmdStandard) override;
}; // Iteration

extern template float Iteration::time<float>() const;
Expand Down
12 changes: 12 additions & 0 deletions 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 @@ -41,6 +43,7 @@ class Mesh : public BaseRecord<MeshRecordComponent>
{
friend class Container<Mesh>;
friend class Iteration;
friend class internal::ScientificDefaults;

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

protected:
void defaults_impl(bool write, OpenpmdStandard) override;
}; // 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
16 changes: 15 additions & 1 deletion include/openPMD/ParticleSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,34 @@
#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
{
friend class Container<ParticleSpecies>;
friend class Container<Record>;
friend class Iteration;
template <typename T>
friend T &internal::makeOwning(T &self, Series);
friend class internal::ScientificDefaults;

public:
ParticlePatches particlePatches;

template <typename Visitor>
void visitHierarchy(Visitor &&v)
{
Container<Record>::visitHierarchy(v);
particlePatches.visitHierarchy(v);
}

private:
ParticleSpecies();

Expand All @@ -53,6 +64,9 @@ class ParticleSpecies : public Container<Record>
{
return m_containerData;
}

protected:
void defaults_impl(bool write, OpenpmdStandard) override;
};

namespace traits
Expand Down
7 changes: 7 additions & 0 deletions include/openPMD/Record.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "openPMD/RecordComponent.hpp"
#include "openPMD/UnitDimension.hpp"
#include "openPMD/backend/BaseRecord.hpp"
#include "openPMD/backend/ScientificDefaults.hpp"

#include <string>
#include <type_traits>
Expand All @@ -34,6 +35,7 @@ class Record : public BaseRecord<RecordComponent>
friend class Container<Record>;
friend class Iteration;
friend class ParticleSpecies;
friend class internal::ScientificDefaults;

public:
Record(Record const &) = default;
Expand All @@ -55,8 +57,13 @@ class Record : public BaseRecord<RecordComponent>
flush_impl(std::string const &, internal::FlushParams const &) override;

[[nodiscard]] internal::HomogenizeExtents read();

protected:
void defaults_impl(bool write, OpenpmdStandard) override;
}; // Record

static_assert(internal::HasScientificDefaults_v<Record>);

template <typename T>
inline T Record::timeOffset() const
{
Expand Down
19 changes: 16 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
, protected internal::ScientificDefaults
{
template <typename T, typename T_key, typename T_container>
friend class Container;
Expand All @@ -128,6 +131,7 @@ class RecordComponent : public BaseRecordComponent
friend class MeshRecordComponent;
template <typename T>
friend T &internal::makeOwning(T &self, Series);
friend class internal::ScientificDefaults;

public:
enum class Allocation
Expand Down Expand Up @@ -482,11 +486,17 @@ class RecordComponent : public BaseRecordComponent
auto visit(Args &&...args) -> decltype(Visitor::template call<char>(
std::declval<RecordComponent &>(), std::forward<Args>(args)...));

template <typename Visitor>
void visitHierarchy(Visitor &&v)
{
v(*this);
}

static constexpr char const *const SCALAR = "\vScalar";

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

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

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

template <typename T>
void verifyChunk(Offset const &, Extent const &) const;

void verifyChunk(Datatype, Offset const &, Extent const &) const;

protected:
void defaults_impl(bool write, OpenpmdStandard) override;
}; // RecordComponent

namespace internal
Expand Down
7 changes: 7 additions & 0 deletions include/openPMD/Series.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,13 @@ class Series : public Attributable
*/
void close();

template <typename Visitor>
void visitHierarchy(Visitor &&v)
{
v(*this);
get().iterations.visitHierarchy(v);
}

/**
* This overrides Attributable::iterationFlush() which will fail on Series.
*/
Expand Down
50 changes: 50 additions & 0 deletions include/openPMD/auxiliary/TypeTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ namespace detail
{
constexpr static bool value = true;
};

template <typename T>
struct ScalarType
{
using type = T;
};
template <typename T>
struct ScalarType<std::vector<T>>
{
using type = T;
};
template <typename T, size_t N>
struct ScalarType<std::array<T, N>>
{
using type = T;
};
} // namespace detail

template <typename T>
Expand All @@ -141,6 +157,12 @@ using IsPointer_t = typename detail::IsPointer<T>::type;
template <typename C>
inline constexpr bool IsChar_v = detail::IsChar<C>::value;

template <typename T>
using ScalarType_t = typename detail::ScalarType<T>::type;

template <typename T>
using VectorType_t = std::vector<ScalarType_t<T>>;

/** Emulate in the C++ concept ContiguousContainer
*
* Users can implement this trait for a type to signal it can be used as
Expand Down Expand Up @@ -203,6 +225,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
3 changes: 3 additions & 0 deletions include/openPMD/backend/Attributable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace internal
class IterationData;
class SeriesData;
struct HomogenizeExtents;
struct ConfigAttribute;

class SharedAttributableData
{
Expand Down Expand Up @@ -244,6 +245,7 @@ class Attributable
friend class internal::AttributableData;
friend class Snapshots;
friend struct internal::HomogenizeExtents;
friend struct internal::ConfigAttribute;

protected:
// tag for internal constructor
Expand Down Expand Up @@ -276,6 +278,7 @@ class Attributable
template <typename T>
bool setAttribute(std::string const &key, T value);
bool setAttribute(std::string const &key, char const value[]);
bool setAttribute(std::string const &key, Attribute value);
/** @}
*/

Expand Down
25 changes: 23 additions & 2 deletions include/openPMD/backend/Attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,30 @@ class Attribute
template <typename U>
std::optional<U> getOptional() const;

private:
template <typename U>
std::variant<U, std::runtime_error> get_impl() const;
std::variant<U, std::runtime_error> getOrError() const;

/**
* Force this attribute into a vector type.
* If it is scalar, convert to a vector with a single element.
* If it is an array, convert it to a vector.
*
* @return On success, a new Attribute with underlying vector type.
* On failure, an error with a description of what went wrong
* (e.g. when the base type is bool).
*/
[[nodiscard]] std::variant<Attribute, std::runtime_error>
requireVector() const;
/**
* Force this attribute into a scalar type.
* If it is a vector attribute with a single entry, convert to a scalar.
*
* @return On success, a new Attribute with underlying scalar type.
* On failure, an error with a description of what went wrong
* (e.g. when a vector with size other than 1 was provided).
*/
[[nodiscard]] std::variant<Attribute, std::runtime_error>
requireScalar() const;
};

namespace detail
Expand Down
Loading
Loading