11#ifndef PHARE_CORE_NUMERICS_EULER_INTEGRATOR_HPP
22#define PHARE_CORE_NUMERICS_EULER_INTEGRATOR_HPP
33
4- #include " core/numerics/constrained_transport/constrained_transport.hpp"
5- #include " core/numerics/godunov_fluxes/godunov_utils.hpp"
64#include " initializer/data_provider.hpp"
5+ #include " amr/solvers/time_integrator/base_mhd_timestepper.hpp"
76#include " amr/solvers/time_integrator/euler.hpp"
87
98namespace PHARE ::solver
109{
1110template <template <typename > typename FVMethodStrategy, typename MHDModel>
12- class EulerIntegrator
11+ class EulerIntegrator : public BaseMHDTimestepper <MHDModel>
1312{
14- using FieldT = typename MHDModel::field_type;
15- using VecFieldT = typename MHDModel::vecfield_type;
16- using GridLayoutT = typename MHDModel::gridlayout_type;
13+ using Super = BaseMHDTimestepper<MHDModel>;
1714
1815public:
1916 EulerIntegrator (PHARE::initializer::PHAREDict const & dict)
20- : euler_{dict}
21- , butcherFluxes_{{" timeRho_fx" , core::MHDQuantity::Scalar::ScalarFlux_x},
22- {" timeRhoV_fx" , core::MHDQuantity::Vector::VecFlux_x},
23- {" timeB_fx" , core::MHDQuantity::Vector::VecFlux_x},
24- {" timeEtot_fx" , core::MHDQuantity::Scalar::ScalarFlux_x},
25-
26- {" timeRho_fy" , core::MHDQuantity::Scalar::ScalarFlux_y},
27- {" timeRhoV_fy" , core::MHDQuantity::Vector::VecFlux_y},
28- {" timeB_fy" , core::MHDQuantity::Vector::VecFlux_y},
29- {" timeEtot_fy" , core::MHDQuantity::Scalar::ScalarFlux_y},
30-
31- {" timeRho_fz" , core::MHDQuantity::Scalar::ScalarFlux_z},
32- {" timeRhoV_fz" , core::MHDQuantity::Vector::VecFlux_z},
33- {" timeB_fz" , core::MHDQuantity::Vector::VecFlux_z},
34- {" timeEtot_fz" , core::MHDQuantity::Scalar::ScalarFlux_z}}
35- , butcherE_{" timeE" , core::MHDQuantity::Vector::E}
17+ : Super{dict}
18+ , euler_{dict}
3619 {
3720 }
3821
@@ -42,103 +25,21 @@ class EulerIntegrator
4225 void operator ()(MHDModel& model, auto & state, auto & fluxes, auto & bc, auto & level,
4326 double const currentTime, double const newTime)
4427 {
45- resetButcherFluxes_ (model, level);
28+ this -> resetButcherFluxes_ (model, level);
4629
4730 euler_ (model, state, state, fluxes, bc, level, currentTime, newTime);
4831
49- accumulateButcherFluxes_ (model, fluxes, level);
50- }
51-
52- void registerResources (MHDModel& model)
53- {
54- model.resourcesManager ->registerResources (butcherFluxes_);
55- model.resourcesManager ->registerResources (butcherE_);
56- }
57-
58- void allocate (MHDModel& model, auto & patch, double const allocateTime) const
59- {
60- model.resourcesManager ->allocate (butcherFluxes_, patch, allocateTime);
61- model.resourcesManager ->allocate (butcherE_, patch, allocateTime);
62- }
63-
64- void fillMessengerInfo (auto & info) const {}
65-
66- NO_DISCARD auto getCompileTimeResourcesViewList ()
67- {
68- return std::forward_as_tuple (butcherFluxes_, butcherE_);
69- }
70-
71- NO_DISCARD auto getCompileTimeResourcesViewList () const
72- {
73- return std::forward_as_tuple (butcherFluxes_, butcherE_);
32+ this ->accumulateButcherFluxes_ (model, fluxes, level);
7433 }
7534
76- auto exposeFluxes () { return std::forward_as_tuple (butcherFluxes_, butcherE_); }
77-
78- auto exposeFluxes () const { return std::forward_as_tuple (butcherFluxes_, butcherE_); }
35+ using Super::allocate;
36+ using Super::exposeFluxes;
37+ using Super::fillMessengerInfo;
38+ using Super::getCompileTimeResourcesViewList;
39+ using Super::registerResources;
7940
8041private:
81- void resetButcherFluxes_ (MHDModel& model, auto & level)
82- {
83- for (auto & patch : level)
84- {
85- auto const & layout = amr::layoutFromPatch<GridLayoutT>(*patch);
86- auto _ = model.resourcesManager ->setOnPatch (*patch, butcherFluxes_, butcherE_);
87-
88- evalFluxesOnGhostBox (
89- layout, [&](auto & left, auto const &... args) mutable { left (args...) = 0.0 ; },
90- butcherFluxes_);
91-
92- layout.evalOnGhostBox (butcherE_ (core::Component::X), [&](auto const &... args) mutable {
93- butcherE_ (core::Component::X)(args...) = 0.0 ;
94- });
95-
96- layout.evalOnGhostBox (butcherE_ (core::Component::Y), [&](auto const &... args) mutable {
97- butcherE_ (core::Component::Y)(args...) = 0.0 ;
98- });
99-
100- layout.evalOnGhostBox (butcherE_ (core::Component::Z), [&](auto const &... args) mutable {
101- butcherE_ (core::Component::Z)(args...) = 0.0 ;
102- });
103- }
104- }
105-
106- void accumulateButcherFluxes_ (MHDModel& model, auto & fluxes, auto & level)
107- {
108- for (auto & patch : level)
109- {
110- auto const & layout = amr::layoutFromPatch<GridLayoutT>(*patch);
111- auto _ = model.resourcesManager ->setOnPatch (*patch, butcherFluxes_, butcherE_, fluxes,
112- model.state .E );
113-
114- evalFluxesOnGhostBox (
115- layout,
116- [&](auto & left, auto const & right, auto const &... args) mutable {
117- left (args...) += right (args...);
118- },
119- butcherFluxes_, fluxes);
120-
121-
122- layout.evalOnGhostBox (butcherE_ (core::Component::X), [&](auto const &... args) mutable {
123- butcherE_ (core::Component::X)(args...)
124- += model.state .E (core::Component::X)(args...);
125- });
126-
127- layout.evalOnGhostBox (butcherE_ (core::Component::Y), [&](auto const &... args) mutable {
128- butcherE_ (core::Component::Y)(args...)
129- += model.state .E (core::Component::Y)(args...);
130- });
131-
132- layout.evalOnGhostBox (butcherE_ (core::Component::Z), [&](auto const &... args) mutable {
133- butcherE_ (core::Component::Z)(args...)
134- += model.state .E (core::Component::Z)(args...);
135- });
136- }
137- }
138-
13942 Euler<FVMethodStrategy, MHDModel> euler_;
140- core::AllFluxes<FieldT, VecFieldT> butcherFluxes_;
141- VecFieldT butcherE_;
14243};
14344} // namespace PHARE::solver
14445
0 commit comments