-
Notifications
You must be signed in to change notification settings - Fork 25
[Scheduler] introduce synchronized data directly in the scheduler #1704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
tdavidcl
wants to merge
7
commits into
Shamrock-code:main
Choose a base branch
from
tdavidcl:patch-2026-03-08-14-07
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d78151
try to add synchronized edges to the scheduler
tdavidcl ce026b2
[Scheduler] introduce synchronized data directly in the scheduler
tdavidcl 52c51e1
Update src/shamrock/include/shamrock/solvergraph/ScalarEdgeSerializab…
tdavidcl 2175b1b
clean names
tdavidcl 8ffa4d2
move JsonSerializable to standalone file
tdavidcl f1e9de9
cleaner
tdavidcl 9bc88dd
Merge branch 'main' into patch-2026-03-08-14-07
tdavidcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
38 changes: 38 additions & 0 deletions
38
src/shamrock/include/shamrock/solvergraph/JsonSerializable.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // -------------------------------------------------------// | ||
| // | ||
| // SHAMROCK code for hydrodynamics | ||
| // Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me> | ||
| // SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1 | ||
| // Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information | ||
| // | ||
| // -------------------------------------------------------// | ||
|
|
||
| #pragma once | ||
|
|
||
| /** | ||
| * @file JsonSerializable.hpp | ||
| * @author Timothée David--Cléris (tim.shamrock@proton.me) | ||
| * @brief | ||
| */ | ||
|
|
||
| #include "shamrock/solvergraph/IEdge.hpp" | ||
| #include <nlohmann/json.hpp> | ||
| #include <string> | ||
|
|
||
| namespace shamrock::solvergraph { | ||
|
|
||
| struct JsonSerializable { | ||
| virtual ~JsonSerializable() {}; | ||
|
|
||
| virtual void to_json(nlohmann::json &j) = 0; | ||
| virtual void from_json(const nlohmann::json &j) = 0; | ||
|
|
||
| virtual std::string type_name() = 0; | ||
| }; | ||
|
|
||
| inline bool json_serializable_edge_constraint( | ||
| const std::shared_ptr<shamrock::solvergraph::IEdge> &edge) { | ||
| // check that the edge can be cross-casted to JsonSerializable | ||
| return bool(std::dynamic_pointer_cast<JsonSerializable>(edge)); | ||
| }; | ||
| } // namespace shamrock::solvergraph |
85 changes: 85 additions & 0 deletions
85
src/shamrock/include/shamrock/solvergraph/ScalarEdgeSerializable.hpp
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // -------------------------------------------------------// | ||
| // | ||
| // SHAMROCK code for hydrodynamics | ||
| // Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me> | ||
| // SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1 | ||
| // Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information | ||
| // | ||
| // -------------------------------------------------------// | ||
|
|
||
| #pragma once | ||
|
|
||
| /** | ||
| * @file ScalarEdgeSerializable.hpp | ||
| * @author Timothée David--Cléris (tim.shamrock@proton.me) | ||
| * @brief | ||
| * | ||
| */ | ||
|
|
||
| #include "shambase/exception.hpp" | ||
| #include "shambase/pre_main_call.hpp" | ||
| #include "shambase/string.hpp" | ||
| #include "shambase/type_name_info.hpp" | ||
| #include "nlohmann/json_fwd.hpp" | ||
| #include "shamrock/scheduler/PatchScheduler.hpp" | ||
| #include "shamrock/solvergraph/IEdge.hpp" | ||
| #include "shamrock/solvergraph/ScalarEdge.hpp" | ||
| #include <memory> | ||
| #include <stdexcept> | ||
|
|
||
| namespace shamrock::solvergraph { | ||
|
|
||
| template<class T> | ||
| class ScalarEdgeSerializable : public ScalarEdge<T>, public JsonSerializable { | ||
| public: | ||
| using ScalarEdge<T>::ScalarEdge; | ||
| using ScalarEdge<T>::value; | ||
|
|
||
| virtual void to_json(nlohmann::json &j) { | ||
| j = nlohmann::json{ | ||
| {"type", type_name()}, | ||
| {"value", value}, | ||
| {"label", this->get_label()}, | ||
| {"tex_symbol", this->get_raw_tex_symbol()}}; | ||
| }; | ||
|
|
||
| virtual void from_json(const nlohmann::json &j) { | ||
| std::string type = j.at("type"); | ||
|
|
||
| if (type != type_name()) { | ||
| throw shambase::make_except_with_loc<std::runtime_error>(shambase::format( | ||
| "error when deserializing ScalarEdgeSerializable, expected type info " | ||
| "\"{}\" but got \"{}\"", | ||
| type_name(), | ||
| type)); | ||
| } | ||
|
|
||
| value = j.at("value").get<T>(); | ||
| }; | ||
|
|
||
| inline static std::string type_name_static() { | ||
| return "ScalarEdgeSerializable<" + shambase::get_type_name<T>() + ">"; | ||
| } | ||
|
|
||
| virtual std::string type_name() { return type_name_static(); }; | ||
| }; | ||
|
|
||
| } // namespace shamrock::solvergraph | ||
|
|
||
| template<class T> | ||
| void register_ctor_deser() { | ||
|
|
||
| auto ctor = [](const nlohmann::json &j) -> std::shared_ptr<shamrock::solvergraph::IEdge> { | ||
| std::string label = j.at("label").get<std::string>(); | ||
| std::string tex_symbol = j.at("tex_symbol").get<std::string>(); | ||
|
|
||
| return std::make_shared<shamrock::solvergraph::ScalarEdgeSerializable<T>>( | ||
| label, tex_symbol); | ||
| }; | ||
|
|
||
| deser_map.insert({shamrock::solvergraph::ScalarEdgeSerializable<T>::type_name_static(), ctor}); | ||
| } | ||
|
|
||
| PRE_MAIN_FUNCTION_CALL([&]() { | ||
| register_ctor_deser<f64>(); | ||
| }) |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.