Skip to content

Commit a14b876

Browse files
UCaromelnicolasaunai
authored andcommitted
integrator quickfix
1 parent 62bbc5e commit a14b876

File tree

10 files changed

+603
-288
lines changed

10 files changed

+603
-288
lines changed

pyphare/pyphare/mock_mhd_simulator/__init__.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,35 @@ def add_double(path, val):
9090
add_double("to_conservative/heat_capacity_ratio", simulation.gamma)
9191
add_string("integrator", simulation.integrator)
9292

93+
add_string("state/name", "state")
94+
add_string("state1/name", "state1")
95+
add_string("state2/name", "state2")
96+
9397
d = simulation.model.model_dict
9498

95-
addInitFunction("density/initializer", fn_wrapper(d["density"]))
96-
addInitFunction("velocity/initializer/x_component", fn_wrapper(d["vx"]))
97-
addInitFunction("velocity/initializer/y_component", fn_wrapper(d["vy"]))
98-
addInitFunction("velocity/initializer/z_component", fn_wrapper(d["vz"]))
99-
addInitFunction("magnetic/initializer/x_component", fn_wrapper(d["bx"]))
100-
addInitFunction("magnetic/initializer/y_component", fn_wrapper(d["by"]))
101-
addInitFunction("magnetic/initializer/z_component", fn_wrapper(d["bz"]))
102-
addInitFunction("pressure/initializer", fn_wrapper(d["p"]))
99+
addInitFunction("state/density/initializer", fn_wrapper(d["density"]))
100+
addInitFunction("state/velocity/initializer/x_component", fn_wrapper(d["vx"]))
101+
addInitFunction("state/velocity/initializer/y_component", fn_wrapper(d["vy"]))
102+
addInitFunction("state/velocity/initializer/z_component", fn_wrapper(d["vz"]))
103+
addInitFunction("state/magnetic/initializer/x_component", fn_wrapper(d["bx"]))
104+
addInitFunction("state/magnetic/initializer/y_component", fn_wrapper(d["by"]))
105+
addInitFunction("state/magnetic/initializer/z_component", fn_wrapper(d["bz"]))
106+
addInitFunction("state/pressure/initializer", fn_wrapper(d["p"]))
107+
108+
addInitFunction("state1/density/initializer", fn_wrapper(d["density"]))
109+
addInitFunction("state1/velocity/initializer/x_component", fn_wrapper(d["vx"]))
110+
addInitFunction("state1/velocity/initializer/y_component", fn_wrapper(d["vy"]))
111+
addInitFunction("state1/velocity/initializer/z_component", fn_wrapper(d["vz"]))
112+
addInitFunction("state1/magnetic/initializer/x_component", fn_wrapper(d["bx"]))
113+
addInitFunction("state1/magnetic/initializer/y_component", fn_wrapper(d["by"]))
114+
addInitFunction("state1/magnetic/initializer/z_component", fn_wrapper(d["bz"]))
115+
addInitFunction("state1/pressure/initializer", fn_wrapper(d["p"]))
116+
117+
addInitFunction("state2/density/initializer", fn_wrapper(d["density"]))
118+
addInitFunction("state2/velocity/initializer/x_component", fn_wrapper(d["vx"]))
119+
addInitFunction("state2/velocity/initializer/y_component", fn_wrapper(d["vy"]))
120+
addInitFunction("state2/velocity/initializer/z_component", fn_wrapper(d["vz"]))
121+
addInitFunction("state2/magnetic/initializer/x_component", fn_wrapper(d["bx"]))
122+
addInitFunction("state2/magnetic/initializer/y_component", fn_wrapper(d["by"]))
123+
addInitFunction("state2/magnetic/initializer/z_component", fn_wrapper(d["bz"]))
124+
addInitFunction("state2/pressure/initializer", fn_wrapper(d["p"]))

src/amr/solvers/solver_mhd.hpp

Lines changed: 366 additions & 63 deletions
Large diffs are not rendered by default.

src/amr/solvers/solver_mhd_model_view.hpp

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,44 +126,58 @@ class TimeIntegratorTransformer
126126

127127
public:
128128
template<typename Layout, typename Field, typename VecField, typename... Fluxes>
129-
void euler(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
129+
void euler(Layout const& layouts, Field const& rho, VecField const& rhoV, VecField const& B,
130+
Field const& Etot, Field& rhonew, VecField& rhoVnew, VecField& Bnew, Field& Etotnew,
130131
VecField& E, double const dt, Fluxes&... fluxes)
131132
{
132-
assert_equal_sizes(rho, rhoV, B, Etot, E, fluxes...);
133+
assert_equal_sizes(rho, rhoV, B, Etot, rhonew, rhoVnew, Bnew, Etotnew, E, fluxes...);
133134
for (std::size_t i = 0; i < layouts.size(); ++i)
134135
{
135136
auto _ = core::SetLayout(layouts[i], time_integrator_);
136-
time_integrator_.euler(*rho[i], *rhoV[i], *B[i], *Etot[i], *E[i], dt, *fluxes[i]...);
137+
time_integrator_.euler_step_(*rho[i], *rhoV[i], *B[i], *Etot[i], *rhonew[i],
138+
*rhoVnew[i], *Bnew[i], *Etotnew[i], *E[i], dt,
139+
*fluxes[i]...);
137140
}
138141
}
139142

140-
template<typename Layout, typename Field, typename VecField, typename... Fluxes>
141-
void tvdrk2(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
142-
Field& rho1, VecField& rhoV1, VecField& B1, Field& Etot1, VecField& E,
143-
double const dt, Fluxes&... fluxes)
143+
template<typename Layout, typename Field, typename VecField>
144+
void tvdrk2_step2(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
145+
Field& rho1, VecField& rhoV1, VecField& B1, Field& Etot1)
144146
{
145-
assert_equal_sizes(rho, rhoV, B, Etot, E, fluxes...);
147+
assert_equal_sizes(rho, rhoV, B, Etot, rho1, rhoV1, B1, Etot1);
146148
for (std::size_t i = 0; i < layouts.size(); ++i)
147149
{
148150
auto _ = core::SetLayout(layouts[i], time_integrator_);
149-
time_integrator_.tvdrk2(*rho[i], *rhoV[i], *B[i], *Etot[i], *rho1[i], *rhoV1[i], *B1[i],
150-
*Etot1[i], *E[i], dt, *fluxes[i]...);
151+
time_integrator_.tvdrk2_step2(*rho[i], *rhoV[i], *B[i], *Etot[i], *rho1[i], *rhoV1[i],
152+
*B1[i], *Etot1[i]);
151153
}
152154
}
153155

154-
template<typename Layout, typename Field, typename VecField, typename... Fluxes>
155-
void tvdrk3(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
156-
Field& rho1, VecField& rhoV1, VecField& B1, Field& Etot1, Field& rho2,
157-
VecField& rhoV2, VecField& B2, Field& Etot2, VecField& E, double const dt,
158-
Fluxes&... fluxes)
156+
template<typename Layout, typename Field, typename VecField>
157+
void tvdrk3_step2(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
158+
Field& rho1, VecField& rhoV1, VecField& B1, Field& Etot1, Field& rho2,
159+
VecField& rhoV2, VecField& B2, Field& Etot2)
160+
{
161+
assert_equal_sizes(rho, rhoV, B, Etot, rho1, rhoV1, B1, Etot1, rho2, rhoV2, B2, Etot2);
162+
for (std::size_t i = 0; i < layouts.size(); ++i)
163+
{
164+
auto _ = core::SetLayout(layouts[i], time_integrator_);
165+
time_integrator_.tvdrk3_step2(*rho[i], *rhoV[i], *B[i], *Etot[i], *rho1[i], *rhoV1[i],
166+
*B1[i], *Etot1[i], *rho2[i], *rhoV2[i], *B2[i],
167+
*Etot2[i]);
168+
}
169+
}
170+
171+
template<typename Layout, typename Field, typename VecField>
172+
void tvdrk3_step3(Layout const& layouts, Field& rho, VecField& rhoV, VecField& B, Field& Etot,
173+
Field& rho2, VecField& rhoV2, VecField& B2, Field& Etot2)
159174
{
160-
assert_equal_sizes(rho, rhoV, B, Etot, E, fluxes...);
175+
assert_equal_sizes(rho, rhoV, B, Etot, rho2, rhoV2, B2, Etot2);
161176
for (std::size_t i = 0; i < layouts.size(); ++i)
162177
{
163178
auto _ = core::SetLayout(layouts[i], time_integrator_);
164-
time_integrator_.tvdrk3(*rho[i], *rhoV[i], *B[i], *Etot[i], *rho1[i], *rhoV1[i], *B1[i],
165-
*Etot1[i], *rho2[i], *rhoV2[i], *B2[i], *Etot2[i], *E[i], dt,
166-
*fluxes[i]...);
179+
time_integrator_.tvdrk3_step3(*rho[i], *rhoV[i], *B[i], *Etot[i], *rho2[i], *rhoV2[i],
180+
*B2[i], *Etot2[i]);
167181
}
168182
}
169183

src/core/models/mhd_state.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,20 @@ namespace core
5353
//-------------------------------------------------------------------------
5454

5555
MHDState(PHARE::initializer::PHAREDict const& dict)
56-
: rho{"rho", MHDQuantity::Scalar::rho}
57-
, V{"V", MHDQuantity::Vector::V}
58-
, B{"B", MHDQuantity::Vector::B}
59-
, P{"P", MHDQuantity::Scalar::P}
56+
: rho{dict["name"].template to<std::string>() + "_" + "rho", MHDQuantity::Scalar::rho}
57+
, V{dict["name"].template to<std::string>() + "_" + "V", MHDQuantity::Vector::V}
58+
, B{dict["name"].template to<std::string>() + "_" + "B", MHDQuantity::Vector::B}
59+
, P{dict["name"].template to<std::string>() + "_" + "P", MHDQuantity::Scalar::P}
6060

6161

62-
, rhoV{"rhoV", MHDQuantity::Vector::rhoV}
63-
, Etot{"Etot", MHDQuantity::Scalar::Etot}
62+
, rhoV{dict["name"].template to<std::string>() + "_" + "rhoV",
63+
MHDQuantity::Vector::rhoV}
64+
, Etot{dict["name"].template to<std::string>() + "_" + "Etot",
65+
MHDQuantity::Scalar::Etot}
6466

6567

66-
, E{"E", MHDQuantity::Vector::E}
67-
, J{"J", MHDQuantity::Vector::J}
68+
, E{dict["name"].template to<std::string>() + "_" + "E", MHDQuantity::Vector::E}
69+
, J{dict["name"].template to<std::string>() + "_" + "J", MHDQuantity::Vector::J}
6870

6971

7072
, rhoinit_{dict["density"]["initializer"]

0 commit comments

Comments
 (0)