[Core][Future] New data containers for entities#14588
Draft
loumalouomega wants to merge 17 commits into
Draft
Conversation
- Introduced `DataHistoryPolicyBase`, `NonHistoricalDataPolicy`, and `HistoricalDataPolicy` to manage step history in data containers. - Implemented cloning and step index management functionalities in historical policies. - Added `DataValuePolicyBase` and derived classes (`DataValuePolicy`, `LayeredDataValuePolicy`, `SparseDataValuePolicy`) for managing value storage in data chunks. - Defined `StepCategory` enum to categorize solution steps for better data management. - Ensured policies support type erasure and provide necessary operations for data handling.
- Implemented comprehensive tests for DataContainer functionality, including data addition, retrieval, and lifecycle management. - Added tests for DataHistoryPolicy to verify step indexing and cycling behavior. - Created tests for DataValuePolicy and SparseDataValuePolicy to ensure compatibility and correct behavior under various scenarios. - Included checks for error handling in DataContainer operations, ensuring robustness against invalid operations.
…default zero value behavior
…ay_1d for correct behavior
loumalouomega
had a problem deploying
to
github-pages
July 18, 2026 06:20 — with
GitHub Actions
Failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
name: ✨ Feature
about: New data containers for entities
📝 Description
Adds a
Kratos::Futureentity-data manager that lets the entities of aModelPart—Node,Element,Condition,Geometry,MasterSlaveConstraint— use the new coreDataContainer(fromcore/new-data-containers) as a parallel, DataContainer-backed storage path, alongside their existing storage. The integration lives entirely underkratos/future/and is compiled only with-DKRATOS_USE_FUTURE=ON; no entity class, and no existing storage/serialization/hot path, is touched. When the flag is off, nothing changes.The access point is at ModelPart level (
model_part_data.Nodes().GetValue(node, VAR)), not on the entity classes. This is a deliberate design decision:KRATOS_USE_FUTUREis scoped to KratosCore's own compilation and does not reach application translation units, so an#ifdef-gated data member onNode/Element/… would give those classes a different layout in core vs. in applications — a silent ABI/ODR break. Keeping the storage in a ModelPart-owned manager avoids any entity-layout change.Continues #14587
Key changes
Future::EntityDataContainer(kratos/future/containers/entity_data_container.{h,cpp}) — the bridge between Id-addressed entities and the slot-addressedDataContainer. Owns oneDataContainerplus anId → dense slotmap. Entities are registered (slots assigned in registration order); variables are added per container:AddVariable(V)→ non-historical dense (NonHistoricalDataPolicy),AddHistoricalVariable(V)→ TimeStep-buffered (HistoricalDataPolicy, buffer size from the ModelPart),Add(V, value_policy, history_policy)passthrough for sparse/custom.Access via
GetValue/SetValue/Has(by entity or Id, with an optional step for historical data) and O(1) bulk access viaGetDataSpan(accessor)[Index(entity)]. Dense chunks grow automatically as entities register (viaDataContainer::Resize).Future::ModelPartDataContainer(model_part_data_container.{h,cpp}) — a per-ModelPartaggregate exposing oneEntityDataContainerper entity kind (Nodes(),Elements(),Conditions(),Geometries(),MasterSlaveConstraints()), snapshotting the entities at construction, plusUpdate()(register entities added later) andCloneStepData(StepCategory)(advance historical buffers in lockstep withModelPart::CloneTimeStep).add_entity_data_to_python.{h,cpp}, registered infuture/python/kratos_python.cpp): both classes underKratosMultiphysics.Future, per-type Add/Get/Set fordouble/int/array_1d<double,3>/std::string, and zero-copy NumPy spans reusing the Phase IDataContainerbindings.docs/pages/Kratos/For_Developers/Data_Structures/Data_Container.md(architecture, old-API → manager-API mapping, and the limitation list).Notable semantic point for reviewers:
Element/Conditionnon-historical data traditionally lives on the sharedGeometry, so two elements over the same geometry share it. The manager keys by element/condition Id, so those values are independent per entity — an intentional difference, documented.Known limitations (documented, out of scope here): component variables (e.g.
DISPLACEMENT_X) and ublasVector/Matrixcannot be stored (the value policy needs a booloperator==, and a component's source type cannot be recovered fromVariable<double>); entity removal leaves an unreclaimed slot hole; buffer size is snapshotted at construction; no serialization/MPI of the manager data yet; the manager must not outlive itsModel.Validation
Configure with
-DKRATOS_USE_FUTURE=ON, then:KratosCoreTest --gtest_filter='KratosCoreFutureSuite.*EntityDataContainer*:KratosCoreFutureSuite.*ModelPartDataContainer*'→ 15/15 pass (registration/growth/error paths/shallow-copy; per-node historical + non-historical round trips withCloneTimeStep+CloneStepData; both-way non-contamination against the legacyFastGetSolutionStepValue/GetValue;Update; element/condition independence; geometries incl. a standalone one; master-slave constraint; an end-to-end loop).python3 kratos/future/tests/test_entity_data_container.py→ 9/9 pass (registered intest_KratosFutureCore.py, run via thehasattr(KratosMultiphysics, "Future")guard intest_KratosCore.py).KratosCoreTestpasses with Future ON.-DKRATOS_USE_FUTURE=OFFand rebuilding compiles cleanly — nothing outsidekratos/future/references the new classes.🆕 Changelog
Future::EntityDataContainer— maps aModelPart's entities onto a chunkedDataContainer(Id→slot), with non-historical, historical and sparse variables.Future::ModelPartDataContainer— per-ModelPartaggregate exposing DataContainer-backed storage for nodes, elements, conditions, geometries and master-slave constraints, withCloneStepData/Update.KratosMultiphysics.FuturePython bindings for both classes (per-type Add/Get/Set + NumPy spans).KratosCoreFutureSuite) and Python (test_entity_data_container.py) test coverage.KRATOS_USE_FUTURE; entity classes and their existing storage are unchanged.