Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ce709a7
[Algs] Implement a inplace variant of sparse comm
tdavidcl Dec 24, 2025
df9a29d
[gh-action] trigger CI with empty commit
github-actions[bot] Dec 24, 2025
67c05c2
update from stack diff
tdavidcl Dec 24, 2025
d1f7b3d
implement more of ti
tdavidcl Dec 24, 2025
bda7f5e
noice
tdavidcl Dec 24, 2025
97dc885
it works
tdavidcl Dec 25, 2025
1fddeb5
swap comm in the code
tdavidcl Dec 25, 2025
cedccc8
use an alloc cache in exchange
tdavidcl Dec 25, 2025
5f0c757
enable persistance
tdavidcl Dec 26, 2025
6dad87c
even less allocs
tdavidcl Dec 27, 2025
e874faa
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Dec 27, 2025
229ac8b
fix precommit
tdavidcl Dec 27, 2025
520658e
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Dec 27, 2025
eda394a
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Dec 29, 2025
3c8c2d3
fix compile and improve setup perf
tdavidcl Dec 29, 2025
006aad8
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Dec 30, 2025
0f431e2
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Jan 1, 2026
33a933c
Update src/shamrock/include/shamrock/patch/PatchDataField.hpp
tdavidcl Jan 1, 2026
9dc1f05
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Jan 13, 2026
f806918
[autofix.ci] automatic fix: pre-commit hooks
autofix-ci[bot] Jan 13, 2026
2ec4282
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Jan 13, 2026
12a6ba5
small fix
tdavidcl Jan 14, 2026
95f5290
[autofix.ci] automatic fix: pre-commit hooks
autofix-ci[bot] Jan 14, 2026
8a60e50
Merge branch 'main' into patch-2025-12-24-11-25
tdavidcl Jan 18, 2026
c04fabd
Update src/shamalgs/include/shamalgs/collective/RequestList.hpp
tdavidcl Jan 18, 2026
4617356
[autofix.ci] automatic fix: pre-commit hooks
autofix-ci[bot] Jan 18, 2026
67c58c0
tmp
tdavidcl Jan 19, 2026
80ad01c
merge working changes
tdavidcl Jan 19, 2026
e503c0e
merge working changes
tdavidcl Jan 19, 2026
e65c34d
it compiles
tdavidcl Jan 19, 2026
f822afc
it compiles
tdavidcl Jan 19, 2026
dfaf17e
fixed ?
tdavidcl Jan 19, 2026
99282cf
fixed ?
tdavidcl Jan 19, 2026
f88783d
fixed ?
tdavidcl Jan 19, 2026
9bd9181
fixed ?
tdavidcl Jan 19, 2026
a96a1d6
Merge branch 'main' into comm-bypass-large-alloc
tdavidcl Jan 19, 2026
4b9fd8e
fixed ?
tdavidcl Jan 19, 2026
9f938ba
fixed ?
tdavidcl Jan 19, 2026
7598143
better
tdavidcl Jan 19, 2026
6d7f1b2
try a fix
tdavidcl Jan 20, 2026
2031bc8
Merge branch 'main' into comm-bypass-large-alloc
tdavidcl Jan 20, 2026
1d370ad
fixed ?
tdavidcl Jan 21, 2026
55a875d
fixed ?
tdavidcl Jan 21, 2026
24b3e47
fixed ?
tdavidcl Jan 21, 2026
634900a
avoid copy in cache resize
tdavidcl Jan 21, 2026
245b0b9
better
tdavidcl Jan 21, 2026
a4d18ea
better
tdavidcl Jan 21, 2026
981eb4d
better
tdavidcl Jan 21, 2026
cb101fc
better
tdavidcl Jan 21, 2026
07d73af
better
tdavidcl Jan 21, 2026
12f7449
better
tdavidcl Jan 21, 2026
d29c84d
Merge branch 'main' into comm-bypass-large-alloc
tdavidcl Jan 21, 2026
46a5b5c
[Pylib] provide a phantom simulation load utility
tdavidcl Jan 22, 2026
f1ce2ed
use it in tests
tdavidcl Jan 22, 2026
f3114ac
better
tdavidcl Jan 22, 2026
ad0e27a
[gh-action] trigger CI with empty commit
github-actions[bot] Jan 22, 2026
2423291
Merge branch 'main' into patch-2026-01-22-16-16
tdavidcl Jan 22, 2026
f64b3f8
cleaner logs
tdavidcl Jan 22, 2026
b1a0d58
Merge branch 'comm-bypass-large-alloc' into fair-dinkum-its-actually-…
tdavidcl Jan 22, 2026
b6b972f
Adjust phantom dump initialization parameter
tdavidcl Jan 22, 2026
0dc5c01
its a start
tdavidcl Jan 22, 2026
80223ee
better
tdavidcl Jan 22, 2026
594d65d
better
tdavidcl Jan 22, 2026
f006575
better
tdavidcl Jan 22, 2026
6d826ec
better
tdavidcl Jan 22, 2026
d187a23
better
tdavidcl Jan 23, 2026
bb40be9
Merge branch 'main' into fair-dinkum-its-actually-running
tdavidcl Jan 23, 2026
b5220b7
[SPH] Add extended Farris et al 2014 EOS (Ragussa et al 2016)
tdavidcl Jan 23, 2026
73b8ae9
Merge branch 'patch-2026-01-23-18-28' into fair-dinkum-its-actually-r…
tdavidcl Jan 23, 2026
37ae136
Merge branch 'main' into fair-dinkum-its-actually-running
tdavidcl Jan 24, 2026
41ebc03
Merge branch 'main' into fair-dinkum-its-actually-running
tdavidcl Jan 27, 2026
3a81a4d
Merge branch 'main' into fair-dinkum-its-actually-running
tdavidcl Jan 28, 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
47 changes: 46 additions & 1 deletion doc/sphinx/examples/sph/run_phantom_run_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,49 @@
shamrock.utils.url.download_file(input_file_url, input_file_path)
shamrock.utils.url.download_file(dump_file_url, dump_file_path)

shamrock.utils.phantom.run_phantom_simulation(dump_folder, "disc")

def plot_that_rippa(ctx, model, dump_number):
pixel_x = 1920
pixel_y = 1080
radius = 5
center = (0.0, 0.0, 0.0)

aspect = pixel_x / pixel_y
pic_range = [-radius * aspect, radius * aspect, -radius, radius]
delta_x = (radius * 2 * aspect, 0.0, 0.0)
delta_y = (0.0, radius * 2, 0.0)

arr_rho = model.render_cartesian_column_integ(
"rho",
"f64",
center=(0.0, 0.0, 0.0),
delta_x=delta_x,
delta_y=delta_y,
nx=pixel_x,
ny=pixel_y,
)

import copy

import matplotlib
import matplotlib.pyplot as plt

my_cmap = copy.copy(matplotlib.colormaps.get_cmap("gist_heat")) # copy the default cmap
my_cmap.set_bad(color="black")

plt.figure(figsize=(16 / 2, 9 / 2))
res = plt.imshow(arr_rho, cmap=my_cmap, origin="lower", extent=pic_range, norm="log", vmin=1e-9)

cbar = plt.colorbar(res, extend="both")
cbar.set_label(r"$\int \rho \, \mathrm{d} z$ [code unit]")
# or r"$\rho$ [code unit]" for slices

plt.title("t = {:0.3f} [code unit]".format(model.get_time()))
plt.xlabel("x")
plt.ylabel("z")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The y-axis of the plot is labeled "z", but the view seems to be in the x-y plane, as indicated by delta_y = (0.0, radius * 2, 0.0). For a face-on view of a disc integrated along the z-axis, the y-axis label should be "y".

Suggested change
plt.ylabel("z")
plt.ylabel("y")

plt.show()


ctx, model, in_params = shamrock.utils.phantom.run_phantom_simulation(
dump_folder, "disc", callback=plot_that_rippa
)
10 changes: 8 additions & 2 deletions src/pylib/shamrock/utils/phantom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def load_simulation(simulation_path, dump_file_name=None, in_file_name=None, do_
return ctx, model, in_params


def run_phantom_simulation(simulation_folder, sim_name):
def run_phantom_simulation(simulation_folder, sim_name, callback=None):
"""
Run a Phantom simulation in Shamrock.
"""
Expand Down Expand Up @@ -191,6 +191,12 @@ def do_dump(dump_number):
):
os.remove(os.path.join(simulation_folder, f"{sim_name}_00000.tmp"))

if callback is not None:
callback(ctx, model, dump_number)

model.set_next_dt(0)
model.timestep()

do_dump(dump_number)

dump_number += 1
Expand All @@ -204,7 +210,7 @@ def do_dump(dump_number):
next_time = tmax
last_step = True

last_step = model.evolve_until(next_time)
model.evolve_until(next_time)

do_dump(dump_number)
dump_number += 1
Expand Down
26 changes: 26 additions & 0 deletions src/shambackends/include/shambackends/DeviceBufferRef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// -------------------------------------------------------//
//
// 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 DeviceBufferRef.hpp
* @author Timothée David--Cléris (tim.shamrock@proton.me)
* @brief
*
*/

#include "shambackends/DeviceBuffer.hpp"

namespace sham {

template<class T, USMKindTarget target = device>
using DeviceBufferRef = std::reference_wrapper<DeviceBuffer<T, target>>;

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ namespace shammodels::gsph {

using RTree = shamtree::CompressedLeafBVH<Tmorton, Tvec, 3>;

std::shared_ptr<shamrock::solvergraph::ExchangeGhostLayer> exchange_gz_node;
std::shared_ptr<shamrock::solvergraph::ExchangeGhostLayer> exchange_gz_positions;

/// Particle counts per patch
std::shared_ptr<shamrock::solvergraph::Indexes<u32>> part_counts;
std::shared_ptr<shamrock::solvergraph::Indexes<u32>> part_counts_with_ghost;
Expand Down
12 changes: 11 additions & 1 deletion src/shammodels/gsph/src/Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void shammodels::gsph::Solver<Tvec, Kern>::init_solver_graph() {
storage.soundspeed
= std::make_shared<shamrock::solvergraph::Field<Tscal>>(1, "soundspeed", "c_s");

storage.exchange_gz_node
= std::make_shared<shamrock::solvergraph::ExchangeGhostLayer>(storage.ghost_layout);
storage.exchange_gz_positions
= std::make_shared<shamrock::solvergraph::ExchangeGhostLayer>(storage.xyzh_ghost_layout);
// Initialize gradient fields for MUSCL reconstruction
// These are only used when reconstruct_config.is_muscl() == true
storage.grad_density
Expand Down Expand Up @@ -190,6 +194,9 @@ template<class Tvec, template<class> class Kern>
void shammodels::gsph::Solver<Tvec, Kern>::merge_position_ghost() {
StackEntry stack_loc{};

std::shared_ptr<shamrock::solvergraph::ExchangeGhostLayer> exchange_gz_node
= std::make_shared<shamrock::solvergraph::ExchangeGhostLayer>(storage.xyzh_ghost_layout);

storage.merged_xyzh.set(
storage.ghost_handler.get().build_comm_merge_positions(storage.ghost_patch_cache.get()));

Expand Down Expand Up @@ -618,7 +625,7 @@ void shammodels::gsph::Solver<Tvec, Kern>::init_ghost_layout() {
storage.ghost_layout = std::make_shared<shamrock::patch::PatchDataLayerLayout>();

shamrock::patch::PatchDataLayerLayout &ghost_layout
= shambase::get_check_ref(storage.ghost_layout.get());
= shambase::get_check_ref(storage.ghost_layout);

solver_config.set_ghost_layout(ghost_layout);
}
Expand Down Expand Up @@ -746,6 +753,9 @@ void shammodels::gsph::Solver<Tvec, Kern>::communicate_merge_ghosts_fields() {
}
});

std::shared_ptr<shamrock::solvergraph::ExchangeGhostLayer> exchange_gz_node
= std::make_shared<shamrock::solvergraph::ExchangeGhostLayer>(storage.ghost_layout);

// Communicate ghost data across MPI ranks
shambase::DistributedDataShared<PatchDataLayer> interf_pdat
= ghost_handle.communicate_pdat(ghost_layout_ptr, std::move(pdat_interf));
Expand Down
19 changes: 17 additions & 2 deletions src/shammodels/sph/src/io/Phantom2Shamrock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ namespace shammodels::sph {
f64 utime = phdump.read_header_float<f64>("utime");
f64 umagfd = phdump.read_header_float<f64>("umagfd");

if (udist == 1.0 || umass == 1.0 || utime == 1.0 || umagfd == 3.54491) {
logger::warn_ln("SPH", "phantom dump units are not set, defaulting to SI");
logger::warn_ln("SPH", "udist =", udist);
logger::warn_ln("SPH", "umass =", umass);
logger::warn_ln("SPH", "utime =", utime);
logger::warn_ln("SPH", "umagfd =", umagfd);

return shamunits::UnitSystem<Tscal>();
}

// convert from CGS to SI
udist /= 100.0;
umass /= 1000.0;

return shamunits::UnitSystem<Tscal>(
utime, udist, umass
// unit_current = 1 ,
Expand All @@ -169,9 +183,10 @@ namespace shammodels::sph {
dump.table_header_f64.add("umass", units->kg_inv);
dump.table_header_f64.add("utime", units->s_inv);

f64 umass = units->template to<shamunits::units::kg>();
// Back to freakin CGS (worst units system ever, well no ... there is imperial)
f64 umass = units->template to<shamunits::units::kg>() / 1000.0;
f64 utime = units->template to<shamunits::units::s>();
f64 udist = units->template to<shamunits::units::m>();
f64 udist = units->template to<shamunits::units::m>() / 100.0;

shamunits::Constants<Tscal> ctes{*units};
f64 ccst = ctes.c();
Expand Down
3 changes: 3 additions & 0 deletions src/shammodels/sph/src/modules/SPHSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ void shammodels::sph::modules::SPHSetup<Tvec, SPHKernel>::apply_setup_new(
has_been_limited = false;
using namespace shamrock::patch;

auto dev_sched = shamsys::instance::get_compute_scheduler_ptr();
sham::DeviceBuffer<u32> mask_get_ids_where(0, dev_sched);

// inject in local domains first
PatchCoordTransform<Tvec> ptransf = sched.get_sim_box().get_patch_transform<Tvec>();
sched.for_each_local_patchdata([&](const Patch p, PatchDataLayer &pdat) {
Expand Down