Skip to content
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5b5fc0a
add NIMHD terms
y-lapeyre Mar 17, 2026
5f4c2ea
enable NIMHD
y-lapeyre Mar 18, 2026
a7ede8d
typos + correct dimentionality
y-lapeyre Mar 26, 2026
547a81d
B -> Bhat
y-lapeyre Mar 26, 2026
015819b
Merge branch 'main' into MHD/nonideal
y-lapeyre Apr 20, 2026
32aec9b
correct summation for J
y-lapeyre May 4, 2026
54d00cf
Merge branch 'MHD/nonideal' of github.com:y-lapeyre/Shamrock into MHD…
y-lapeyre May 4, 2026
42428b4
Merge branch 'main' into MHD/nonideal
y-lapeyre Jun 3, 2026
70586aa
fix potential division by 0
y-lapeyre Jun 4, 2026
23b20f0
fix pre-commit
y-lapeyre Jun 4, 2026
6636ce8
correctly communicate J in ghosts
y-lapeyre Jun 4, 2026
071924a
fix ghost com fields
y-lapeyre Jun 4, 2026
8b64f74
clean up rogue J's
y-lapeyre Jun 4, 2026
06c57c9
remove logs
y-lapeyre Jun 7, 2026
347fa18
test1
y-lapeyre Jun 15, 2026
36ae82e
move computeJ to solvergraph
y-lapeyre Jun 15, 2026
452bbcf
correct ghost communication
y-lapeyre Jun 15, 2026
b231638
why is everything a nan
y-lapeyre Jun 15, 2026
2aec96b
mismatch in obj_cnt in communicate_merge_ghost_fields
y-lapeyre Jun 16, 2026
30f5b05
fixed communication, now empty (?) field problem
y-lapeyre Jun 17, 2026
a9bd332
remove logs
y-lapeyre Jun 18, 2026
140d56f
fix J handling (independant com)
y-lapeyre Jun 18, 2026
4ef2daf
fix subfact
y-lapeyre Jun 18, 2026
b01a705
fix dt_AD and J comm
y-lapeyre Jun 18, 2026
bf3c101
fixed memory issue
y-lapeyre Jun 19, 2026
09caf22
Merge branch 'main' into MHD/nonideal
y-lapeyre Jun 21, 2026
1d693f6
[autofix.ci] automatic fix: pre-commit hooks
autofix-ci[bot] Jun 21, 2026
8ff7743
Merge branch 'MHD/nonideal' of github.com:y-lapeyre/Shamrock into MHD…
y-lapeyre Jun 21, 2026
2f1bb96
Merge branch 'MHD/nonideal' of github.com:y-lapeyre/Shamrock into MHD…
y-lapeyre Jun 21, 2026
02c1b44
clean up
y-lapeyre Jun 22, 2026
ffa662f
clean up + add warning
y-lapeyre Jun 22, 2026
c956764
edit out typo
y-lapeyre Jun 22, 2026
4fa54e6
remove log
y-lapeyre Jun 22, 2026
db3c168
Merge branch 'main' into MHD/nonideal
y-lapeyre Jun 22, 2026
b2456f5
correct wrongful merge deletion
y-lapeyre Jun 22, 2026
3dbec73
remove prints
y-lapeyre Jun 26, 2026
60e828a
add wave damping test runscript
y-lapeyre Jun 26, 2026
34f60c1
Put NIMHD in experimental mode
y-lapeyre Jun 26, 2026
d12fbe0
Merge branch 'main' into MHD/nonideal
y-lapeyre Jun 26, 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
1 change: 1 addition & 0 deletions src/shammodels/sph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(Sources
src/modules/UpdateDerivs.cpp
src/modules/ComputeLoadBalanceValue.cpp
src/modules/ComputeOmega.cpp
src/modules/ComputeJ.cpp
src/modules/ComputeLuminosity.cpp
src/modules/NeighbourCache.cpp
src/modules/ParticleReordering.cpp
Expand Down
6 changes: 5 additions & 1 deletion src/shammodels/sph/include/shammodels/sph/Solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @file Solver.hpp
* @author Timothée David--Cléris (tim.shamrock@proton.me)
* @author Yona Lapeyre (yona.lapeyre@ens-lyon.fr) --no git blame--
* @author Yona Lapeyre (yona.lapeyre@ens-lyon.fr)
* @brief
*/

Expand Down Expand Up @@ -186,6 +186,9 @@ namespace shammodels::sph {
/// @brief Updates artificial viscosity coefficients for shock capturing
void update_artificial_viscosity(Tscal dt);

/// @brief Updates the magnetic current field (for NIMHD)
void update_J();

/// @brief Initializes data layout for ghost particle fields
void init_ghost_layout();

Expand All @@ -204,6 +207,7 @@ namespace shammodels::sph {
void prepare_corrector();
/// @brief Updates time derivatives and applies external forces
void update_derivs(Tscal dt_hydro);

/**
* @brief
*
Expand Down
19 changes: 18 additions & 1 deletion src/shammodels/sph/include/shammodels/sph/SolverConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,21 @@ struct shammodels::sph::SolverConfig {
mhd_config.set(v);
}

inline void set_NonIdealMHD(typename MHDConfig::NonIdealMHD v) { mhd_config.set(v); }
inline void set_NonIdealMHD(typename MHDConfig::NonIdealMHD v) {
logger::raw_ln("$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$");
logger::raw_ln(" ______ _______ __ _ _______ _______ ______ ");
logger::raw_ln("| | | _ || | | || || || _ | ");
logger::raw_ln("| _ || |_| || |_| || ___|| ___|| | ||");
logger::raw_ln("| | | || || || | __ | |___ | |_||_");
logger::raw_ln("| |_| || || _ || || || ___|| __ |");
logger::raw_ln("| || _ || | | || |_| || |___ | | | |");
logger::raw_ln("|______| |__| |__||_| |__||_______||_______||___| |_|");
logger::raw_ln("$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$");
logger::raw_ln("The Non-ideal MHD solver is UNDER DEVELOPMENT.");
logger::raw_ln("It is. NOT. FULLY. TESTED. YET.");
logger::raw_ln("Use at your own risk.");
Comment on lines +544 to +555

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
logger::raw_ln("$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$");
logger::raw_ln(" ______ _______ __ _ _______ _______ ______ ");
logger::raw_ln("| | | _ || | | || || || _ | ");
logger::raw_ln("| _ || |_| || |_| || ___|| ___|| | ||");
logger::raw_ln("| | | || || || | __ | |___ | |_||_");
logger::raw_ln("| |_| || || _ || || || ___|| __ |");
logger::raw_ln("| || _ || | | || |_| || |___ | | | |");
logger::raw_ln("|______| |__| |__||_| |__||_______||_______||___| |_|");
logger::raw_ln("$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$DANGER$");
logger::raw_ln("The Non-ideal MHD solver is UNDER DEVELOPMENT.");
logger::raw_ln("It is. NOT. FULLY. TESTED. YET.");
logger::raw_ln("Use at your own risk.");
shamrock::experimental_feature_check(
"Non-ideal MHD is experimental, please enable experimental features to use it");

I low key want to change the expermental prompt with one similar to this though

mhd_config.set(v);
}

//////////////////////////////////////////////////////////////////////////////////////////////
// MHD Config (END)
Expand Down Expand Up @@ -973,6 +987,9 @@ struct shammodels::sph::SolverConfig {
return artif_viscosity.has_field_soundspeed() || is_eos_locally_isothermal();
}

/// @brief Whether the solver is set for non ideal MHD
inline bool do_NIMHD() { return mhd_config.do_NIMHD(); }

/// @brief Whether the solver has a field for B_on_rho
inline bool has_field_B_on_rho() { return mhd_config.has_B_field() && (dim == 3); }

Expand Down
48 changes: 28 additions & 20 deletions src/shammodels/sph/include/shammodels/sph/config/MHDConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ struct shammodels::sph::MHDConfig {
struct NonIdealMHD {
Tscal sigma_mhd = 0.1;
Tscal alpha_u = 1.;
Tscal etaO = 1.;
Tscal etaH = 1.;
Tscal etaAD = 1.;
};

// how to set a new state of a variant as a dummy:
Expand All @@ -52,55 +55,60 @@ struct shammodels::sph::MHDConfig {
//-> question your life choices
using Variant = std::variant<None, IdealMHD_constrained_hyper_para, NonIdealMHD>;

Variant config = None{};
Variant configMHD = None{};

void set(Variant v) { config = v; }
void set(Variant v) { configMHD = v; }

inline bool do_NIMHD() {
bool is_NIMHD = bool(std::get_if<NonIdealMHD>(&configMHD));
return is_NIMHD;
}

inline bool has_B_field() {
bool is_B = bool(std::get_if<IdealMHD_constrained_hyper_para>(&config))
|| bool(std::get_if<NonIdealMHD>(&config));
bool is_B = bool(std::get_if<IdealMHD_constrained_hyper_para>(&configMHD))
|| bool(std::get_if<NonIdealMHD>(&configMHD));
return is_B;
}

inline bool has_psi_field() {
bool is_psi = bool(std::get_if<IdealMHD_constrained_hyper_para>(&config))
|| bool(std::get_if<NonIdealMHD>(&config));
bool is_psi = bool(std::get_if<IdealMHD_constrained_hyper_para>(&configMHD))
|| bool(std::get_if<NonIdealMHD>(&configMHD));
return is_psi;
}

inline bool has_divB_field() {
bool is_divB = bool(std::get_if<IdealMHD_constrained_hyper_para>(&config));
bool is_divB = bool(std::get_if<IdealMHD_constrained_hyper_para>(&configMHD));
return is_divB;
}

inline bool has_curlB_field() {
bool is_curlB = bool(std::get_if<NonIdealMHD>(&config));
bool is_curlB = bool(std::get_if<NonIdealMHD>(&configMHD));
return is_curlB;
}

inline bool has_dtdivB_field() {
bool is_dtdivB = bool(std::get_if<NonIdealMHD>(&config));
bool is_dtdivB = bool(std::get_if<NonIdealMHD>(&configMHD));
return is_dtdivB;
}

inline void print_status() {
logger::raw_ln("--- MHD config");
logger::raw_ln("--- MHD configMHD");

if (None *v = std::get_if<None>(&config)) {
if (None *v = std::get_if<None>(&configMHD)) {
logger::raw_ln(" Config MHD Type : None (No MHD)");
} else if (
IdealMHD_constrained_hyper_para *v
= std::get_if<IdealMHD_constrained_hyper_para>(&config)) {
= std::get_if<IdealMHD_constrained_hyper_para>(&configMHD)) {
logger::raw_ln(" Config MHD : Ideal MHD, constrained hyperbolic/parabolic treatment");
logger::raw_ln(" sigma_mhd =", v->sigma_mhd);
} else if (NonIdealMHD *v = std::get_if<NonIdealMHD>(&config)) {
} else if (NonIdealMHD *v = std::get_if<NonIdealMHD>(&configMHD)) {
logger::raw_ln(" Config MHD Type : Non Ideal MHD");
logger::raw_ln(" sigma_mhd =", v->sigma_mhd);
} else {
shambase::throw_unimplemented();
}

logger::raw_ln("--- MHD config (deduced)");
logger::raw_ln("--- MHD configMHD (deduced)");

logger::raw_ln("-------------");
}
Expand All @@ -122,18 +130,18 @@ namespace shammodels::sph {
using IMHD = typename T::IdealMHD_constrained_hyper_para;
using NonIdealMHD = typename T::NonIdealMHD;

// Write the config type into the JSON object
if (const None *v = std::get_if<None>(&p.config)) {
// Write the configMHD type into the JSON object
if (const None *v = std::get_if<None>(&p.configMHD)) {
j = {
{"mhd_type", "none"},
};
} else if (const IMHD *v = std::get_if<IMHD>(&p.config)) {
} else if (const IMHD *v = std::get_if<IMHD>(&p.configMHD)) {
j = {
{"mhd_type", "ideal_mhd_constrained_hyper_para"},
{"sigma_mhd", v->sigma_mhd},
{"alpha_u", v->alpha_u},
};
} else if (const NonIdealMHD *v = std::get_if<NonIdealMHD>(&p.config)) {
} else if (const NonIdealMHD *v = std::get_if<NonIdealMHD>(&p.configMHD)) {
// Write the shear base, direction, and speed into the JSON object
j = {
{"mhd_type", "non_ideal_mhd"},
Expand Down Expand Up @@ -162,15 +170,15 @@ namespace shammodels::sph {
shambase::throw_with_loc<std::runtime_error>("no field mhd_type is found in this json");
}

// Read the config type from the JSON object
// Read the configMHD type from the JSON object
std::string mhd_type;
j.at("mhd_type").get_to(mhd_type);

using None = typename T::None;
using IMHD = typename T::IdealMHD_constrained_hyper_para;
using NonIdealMHD = typename T::NonIdealMHD;

// Set the BCConfig based on the config type
// Set the BCConfig based on the configMHD type
if (mhd_type == "none") {
p.set(None{});
} else if (mhd_type == "ideal_mhd_constrained_hyper_para") {
Expand Down
Loading
Loading