-
Notifications
You must be signed in to change notification settings - Fork 32
[SPH] improve new SPH setup performance #1501
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
Merged
tdavidcl
merged 11 commits into
Shamrock-code:main
from
tdavidcl:patch-2025-12-29-17-38
Dec 29, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b92878b
[SPH] improve new SPH setup perf
tdavidcl a31ee3b
better
tdavidcl 11f4e3b
better
tdavidcl 8e3e0fa
perf report
tdavidcl c17224c
decouple total comm size from msg size
tdavidcl 7205285
lower
tdavidcl 51b0118
try lower
tdavidcl 46d2498
bump insert step
tdavidcl c4a7f95
port default
tdavidcl 6a9684f
few tweaks
tdavidcl 75b6e21
few tweaks
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| // -------------------------------------------------------// | ||
| // | ||
| // SHAMROCK code for hydrodynamics | ||
| // Copyright (c) 2021-2025 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 tabulate.hpp | ||
| * @author Timothée David--Cléris (tim.shamrock@proton.me) | ||
| * @brief | ||
| * | ||
| */ | ||
|
|
||
| #include "shambase/aliases_int.hpp" | ||
| #include "shambase/string.hpp" | ||
| #include <string> | ||
| #include <variant> | ||
| #include <vector> | ||
|
|
||
| namespace shambase { | ||
|
|
||
| template<size_t cols_count> | ||
| struct table { | ||
| struct rule {}; | ||
| struct double_rule {}; | ||
| struct rulled_data { | ||
| std::array<std::string, cols_count> colnames; | ||
| }; | ||
| enum positionning { | ||
| left, | ||
| right, | ||
| center, | ||
| }; | ||
| struct data { | ||
| std::array<std::string, cols_count> cols; | ||
| positionning position; | ||
| }; | ||
|
|
||
| std::vector<std::variant<rule, double_rule, rulled_data, data>> table_lines; | ||
|
|
||
| void add_rule() { table_lines.push_back(rule{}); } | ||
| void add_double_rule() { table_lines.push_back(double_rule{}); } | ||
| void add_rulled_data(std::array<std::string, cols_count> colnames) { | ||
| table_lines.push_back(rulled_data{colnames}); | ||
| } | ||
| void add_data(std::array<std::string, cols_count> cols, positionning position) { | ||
| table_lines.push_back(data{cols, position}); | ||
| } | ||
|
|
||
| std::array<size_t, cols_count> compute_widths() { | ||
| std::array<size_t, cols_count> widths{}; | ||
| for (auto &line : table_lines) { | ||
| if (data *data_line = std::get_if<data>(&line)) { | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| widths[i] = std::max(widths[i], data_line->cols[i].size()); | ||
| } | ||
| } else if (rulled_data *head_and_ruller_line = std::get_if<rulled_data>(&line)) { | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| widths[i] = std::max(widths[i], head_and_ruller_line->colnames[i].size()); | ||
| } | ||
| } | ||
| } | ||
| return widths; | ||
| } | ||
|
|
||
| std::string render() { | ||
|
|
||
| std::array<size_t, cols_count> widths = compute_widths(); | ||
|
|
||
| std::string print = ""; | ||
| for (auto &line : table_lines) { | ||
| if (data *data_line = std::get_if<data>(&line)) { | ||
| print += "\n|"; | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| if (data_line->position == left) { | ||
| print += shambase::format(" {:<{}} |", data_line->cols[i], widths[i]); | ||
| } else if (data_line->position == right) { | ||
| print += shambase::format(" {:>{}} |", data_line->cols[i], widths[i]); | ||
| } else if (data_line->position == center) { | ||
| print += shambase::format(" {:^{}} |", data_line->cols[i], widths[i]); | ||
| } | ||
| } | ||
|
|
||
| } else if (rulled_data *head_and_ruller_line = std::get_if<rulled_data>(&line)) { | ||
| std::string tmp = "+"; | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| tmp += shambase::format( | ||
| " {:^{}} +", head_and_ruller_line->colnames[i], widths[i]); | ||
| } | ||
|
|
||
| auto neigh_char_is_good = [&](char c) -> bool { | ||
| return c == ' ' || c == '-' || c == '<' || c == '>' || c == '+'; | ||
| }; | ||
|
|
||
| std::vector<bool> set_to_space = std::vector<bool>(tmp.size(), false); | ||
| // if the next and previous chars are space and i am a space then set me to true | ||
| for (size_t i = 1; i < tmp.size() - 1; i++) { | ||
| if (tmp[i] == ' ' && neigh_char_is_good(tmp[i - 1]) | ||
| && neigh_char_is_good(tmp[i + 1])) { | ||
| set_to_space[i] = true; | ||
| } | ||
| } | ||
| // replace the spaces by '-' | ||
| for (size_t i = 0; i < tmp.size() - 1; i++) { | ||
| if (set_to_space[i]) { | ||
| tmp[i] = '-'; | ||
| } | ||
| } | ||
| print += "\n" + tmp; | ||
| } else if (rule *rule_line = std::get_if<rule>(&line)) { | ||
| print += "\n+"; | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| print += shambase::format( | ||
| "-{:<{}}-+", std::string(widths[i], '-'), widths[i]); | ||
| } | ||
| } else if (double_rule *double_rule_line = std::get_if<double_rule>(&line)) { | ||
| print += "\n+"; | ||
| for (u32 i = 0; i < cols_count; i++) { | ||
| print += shambase::format( | ||
| "={:<{}}=+", std::string(widths[i], '='), widths[i]); | ||
| } | ||
| } | ||
| } | ||
| return print; | ||
| } | ||
| }; | ||
|
|
||
| } // namespace shambase | ||
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.