@@ -47,9 +47,7 @@ class SolverMHD : public ISolver<AMR_Types>
47
47
using GodunovFluxes_t = typename MHDModelView<MHDModel>::GodunovFluxes_t;
48
48
using ToPrimitiveConverter_t = typename MHDModelView<MHDModel>::ToPrimitiveConverter_t;
49
49
using ToConservativeConverter_t = typename MHDModelView<MHDModel>::ToConservativeConverter_t;
50
- using FiniteVolumeEuler_t = typename MHDModelView<MHDModel>::FiniteVolumeEuler_t;
51
- using ConstrainedTransport_t = typename MHDModelView<MHDModel>::ConstrainedTransport_t;
52
- using Faraday_t = typename MHDModelView<MHDModel>::Faraday_t;
50
+ using TimeIntegrator_t = typename MHDModelView<MHDModel>::TimeIntegrator_t;
53
51
54
52
55
53
// Flux calculations
@@ -72,20 +70,18 @@ class SolverMHD : public ISolver<AMR_Types>
72
70
FieldT rho1{" rho1" , MHDQuantity::Scalar::rho};
73
71
VecFieldT rhoV1{" rhoV1" , MHDQuantity::Vector::rhoV};
74
72
VecFieldT B1{" B1" , MHDQuantity::Vector::B};
75
- FieldT Etot1{" rho1 " , MHDQuantity::Scalar::Etot};
73
+ FieldT Etot1{" Etot1 " , MHDQuantity::Scalar::Etot};
76
74
77
75
FieldT rho2{" rho2" , MHDQuantity::Scalar::rho};
78
76
VecFieldT rhoV2{" rhoV2" , MHDQuantity::Vector::rhoV};
79
77
VecFieldT B2{" B2" , MHDQuantity::Vector::B};
80
- FieldT Etot2{" rho2 " , MHDQuantity::Scalar::Etot};
78
+ FieldT Etot2{" Etot2 " , MHDQuantity::Scalar::Etot};
81
79
82
80
Ampere_t ampere_;
83
81
GodunovFluxes_t godunov_;
84
82
ToPrimitiveConverter_t to_primitive_;
85
83
ToConservativeConverter_t to_conservative_;
86
- FiniteVolumeEuler_t finite_volume_euler_;
87
- ConstrainedTransport_t constrained_transport_;
88
- Faraday_t faraday_;
84
+ TimeIntegrator_t time_integrator_;
89
85
90
86
std::string const integrator_;
91
87
@@ -129,48 +125,14 @@ class SolverMHD : public ISolver<AMR_Types>
129
125
void godunov_fluxes_ (level_t & level, ModelViews_t& views, Messenger& fromCoarser,
130
126
double const currentTime, double const newTime);
131
127
132
- void time_integrator_ (level_t & level, ModelViews_t& views, Messenger& fromCoarser,
133
- double const currentTime, double const newTime);
128
+ void time_integration_ (level_t & level, ModelViews_t& views, Messenger& fromCoarser,
129
+ double const currentTime, double const newTime);
134
130
135
131
template <typename Layout, typename View, typename VecField, typename Qs, typename ... Fluxes>
136
132
void euler_ (Messenger& fromCoarser, level_t & level, double const newTime, Layout& layouts,
137
133
Qs quantities, View E, VecField Emodel, Qs quantities_new, double const dt,
138
134
Fluxes... fluxes);
139
135
140
- template <typename Field, typename VecField>
141
- struct Q
142
- {
143
- template <auto direction>
144
- auto static rhoV (VecField const & rhoVvec)
145
- {
146
- Field rhoV_comp;
147
- for (size_t i = 0 ; i < rhoVvec.size (); ++i)
148
- rhoV_comp.push_back (&((*rhoVvec[i])(direction)));
149
- return rhoV_comp;
150
- }
151
-
152
- Q (Field& rho_, VecField& rhoV_, VecField& B_, Field& Etot_)
153
- : rho(rho_)
154
- , B(B_)
155
- , Etot(Etot_)
156
- , rhoVx{rhoV<core::Component::X>(rhoV_)}
157
- , rhoVy{rhoV<core::Component::Y>(rhoV_)}
158
- , rhoVz{rhoV<core::Component::Z>(rhoV_)}
159
- {
160
- }
161
-
162
- Field& rho;
163
- VecField& B;
164
- Field& Etot;
165
- Field rhoVx, rhoVy, rhoVz;
166
- };
167
-
168
- template <typename Field, typename VecField>
169
- auto static make_q (Field& rho, VecField& rhoV, VecField& B, Field& Etot)
170
- {
171
- return Q<Field, VecField>{rho, rhoV, B, Etot};
172
- }
173
-
174
136
struct TimeSetter
175
137
{
176
138
/* template <typename QuantityAccessor>*/
@@ -199,7 +161,7 @@ void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::advanceLevel(
199
161
200
162
godunov_fluxes_ (*level, modelView, fromCoarser, currentTime, newTime);
201
163
202
- time_integrator_ (*level, modelView, fromCoarser, currentTime, newTime);
164
+ time_integration_ (*level, modelView, fromCoarser, currentTime, newTime);
203
165
}
204
166
205
167
@@ -243,7 +205,7 @@ void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::godunov_fluxes_(
243
205
244
206
245
207
template <typename MHDModel, typename AMR_Types, typename Messenger, typename ModelViews_t>
246
- void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::time_integrator_ (
208
+ void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::time_integration_ (
247
209
level_t & level, ModelViews_t& views, Messenger& fromCoarser, double const currentTime,
248
210
double const newTime)
249
211
{
@@ -253,118 +215,74 @@ void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::time_integrator_(
253
215
254
216
to_conservative_ (views.layouts , views.rho , views.V , views.B , views.P , views.rhoV , views.Etot );
255
217
256
- Q Un = make_q (views.rho , views.rhoV , views.B , views.Etot );
257
-
258
- Q F_x = make_q (views.rho_x , views.rhoV_x , views.B_x , views.Etot_x );
218
+ fromCoarser.fillMagneticFluxGhosts (views.B_x , level, newTime);
259
219
260
220
if constexpr (dimension == 1 )
261
221
{
262
222
if (integrator_ == " euler" )
263
- euler_ (fromCoarser, level, newTime, views.layouts , Un, views.E , views.model ().state .E ,
264
- Un, dt, F_x);
265
- /* else if (integrator_ == "TVDRK2")*/
266
- /* {*/
267
- /* Q U1(views.rho1, views.rhoV1, views.B1, views.Etot1);*/
268
- /* euler_(fromCoarser, level, newTime, views.layouts, Un, views.E,
269
- * views.model().state.E,*/
270
- /* U1, dt, F_x);*/
271
- /* }*/
223
+ time_integrator_.euler (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
224
+ views.E , dt, views.rho_x , views.rhoV_x , views.B_x , views.Etot_x );
225
+ else if (integrator_ == " tvdrk2" )
226
+ time_integrator_.tvdrk2 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
227
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.E , dt,
228
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x );
229
+ else if (integrator_ == " tvdrk3" )
230
+ time_integrator_.tvdrk3 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
231
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.rho2 ,
232
+ views.rhoV2 , views.B2 , views.Etot2 , views.E , dt, views.rho_x ,
233
+ views.rhoV_x , views.B_x , views.Etot_x );
272
234
}
273
235
if constexpr (dimension >= 2 )
274
236
{
275
- Q F_y = make_q (views.rho_y , views. rhoV_y , views. B_y , views. Etot_y );
237
+ fromCoarser. fillMagneticFluxGhosts (views.B_y , level, newTime );
276
238
277
239
if constexpr (dimension == 2 )
278
240
{
279
- euler_ (fromCoarser, level, newTime, views.layouts , Un, views.E , views.model ().state .E ,
280
- Un, dt, F_x, F_y);
241
+ if (integrator_ == " euler" )
242
+ time_integrator_.euler (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
243
+ views.E , dt, views.rho_x , views.rhoV_x , views.B_x ,
244
+ views.Etot_x , views.rho_y , views.rhoV_y , views.B_y ,
245
+ views.Etot_y );
246
+ else if (integrator_ == " tvdrk2" )
247
+ time_integrator_.tvdrk2 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
248
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.E , dt,
249
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x ,
250
+ views.rho_y , views.rhoV_y , views.B_y , views.Etot_y );
251
+ else if (integrator_ == " tvdrk3" )
252
+ time_integrator_.tvdrk3 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
253
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.rho2 ,
254
+ views.rhoV2 , views.B2 , views.Etot2 , views.E , dt,
255
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x ,
256
+ views.rho_y , views.rhoV_y , views.B_y , views.Etot_y );
281
257
}
282
258
if constexpr (dimension == 3 )
283
259
{
284
- Q F_z = make_q (views.rho_z , views.rhoV_z , views.B_z , views.Etot_z );
285
-
286
- euler_ (fromCoarser, level, newTime, views.layouts , Un, views.E , views.model ().state .E ,
287
- Un, dt, F_x, F_y, F_z);
260
+ fromCoarser.fillMagneticFluxGhosts (views.B_z , level, newTime);
261
+
262
+ if (integrator_ == " euler" )
263
+ time_integrator_.euler (
264
+ views.layouts , views.rho , views.rhoV , views.B , views.Etot , views.E , dt,
265
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x , views.rho_y , views.rhoV_y ,
266
+ views.B_y , views.Etot_y , views.rho_z , views.rhoV_z , views.B_z , views.Etot_z );
267
+ else if (integrator_ == " tvdrk2" )
268
+ time_integrator_.tvdrk2 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
269
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.E , dt,
270
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x ,
271
+ views.rho_y , views.rhoV_y , views.B_y , views.Etot_y ,
272
+ views.rho_z , views.rhoV_z , views.B_z , views.Etot_z );
273
+ else if (integrator_ == " tvdrk3" )
274
+ time_integrator_.tvdrk3 (views.layouts , views.rho , views.rhoV , views.B , views.Etot ,
275
+ views.rho1 , views.rhoV1 , views.B1 , views.Etot1 , views.rho2 ,
276
+ views.rhoV2 , views.B2 , views.Etot2 , views.E , dt,
277
+ views.rho_x , views.rhoV_x , views.B_x , views.Etot_x ,
278
+ views.rho_y , views.rhoV_y , views.B_y , views.Etot_y ,
279
+ views.rho_z , views.rhoV_z , views.B_z , views.Etot_z );
288
280
}
289
281
}
290
282
291
283
to_primitive_ (views.layouts , views.rho , views.rhoV , views.B , views.Etot , views.V , views.P );
292
284
}
293
285
294
- template <typename MHDModel, typename AMR_Types, typename Messenger, typename ModelViews_t>
295
- template <typename Layout, typename View, typename VecField, typename Qs, typename ... Fluxes>
296
- void SolverMHD<MHDModel, AMR_Types, Messenger, ModelViews_t>::euler_(
297
- Messenger& fromCoarser, level_t & level, double const newTime, Layout& layouts, Qs quantities,
298
- View E, VecField Emodel, Qs quantities_new, double const dt, Fluxes... fluxes)
299
- {
300
- auto && flux_tuple = std::forward_as_tuple (fluxes...);
301
-
302
- if constexpr (dimension == 1 )
303
- {
304
- auto && fluxes_x = std::get<0 >(flux_tuple);
305
-
306
- finite_volume_euler_ (layouts, quantities.rho , quantities_new.rho , dt, fluxes_x.rho );
307
- finite_volume_euler_ (layouts, quantities.rhoVx , quantities_new.rhoVx , dt, fluxes_x.rhoVx );
308
- finite_volume_euler_ (layouts, quantities.rhoVy , quantities_new.rhoVy , dt, fluxes_x.rhoVy );
309
- finite_volume_euler_ (layouts, quantities.rhoVz , quantities_new.rhoVz , dt, fluxes_x.rhoVz );
310
- finite_volume_euler_ (layouts, quantities.Etot , quantities_new.Etot , dt, fluxes_x.Etot );
311
-
312
- fromCoarser.fillMagneticFluxGhosts (fluxes_x.B , level, newTime);
313
- constrained_transport_ (layouts, E, fluxes_x.B );
314
- fromCoarser.fillElectricGhosts (Emodel, level, newTime);
315
-
316
- faraday_ (layouts, quantities.B , E, quantities_new.B , dt);
317
- }
318
- if constexpr (dimension == 2 )
319
- {
320
- auto && fluxes_x = std::get<0 >(flux_tuple);
321
- auto && fluxes_y = std::get<1 >(flux_tuple);
322
-
323
- finite_volume_euler_ (layouts, quantities.rho , quantities_new.rho , dt, fluxes_x.rho ,
324
- fluxes_y.rho );
325
- finite_volume_euler_ (layouts, quantities.rhoVx , quantities_new.rhoVx , dt, fluxes_x.rhoVx ,
326
- fluxes_y.rhoVx );
327
- finite_volume_euler_ (layouts, quantities.rhoVy , quantities_new.rhoVy , dt, fluxes_x.rhoVy ,
328
- fluxes_y.rhoVy );
329
- finite_volume_euler_ (layouts, quantities.rhoVz , quantities_new.rhoVz , dt, fluxes_x.rhoVz ,
330
- fluxes_y.rhoVz );
331
- finite_volume_euler_ (layouts, quantities.Etot , quantities_new.Etot , dt, fluxes_x.Etot ,
332
- fluxes_y.Etot );
333
-
334
- fromCoarser.fillMagneticFluxGhosts (fluxes_x.B , level, newTime);
335
- fromCoarser.fillMagneticFluxGhosts (fluxes_y.B , level, newTime);
336
- constrained_transport_ (layouts, E, fluxes_x.B , fluxes_y.B );
337
- fromCoarser.fillElectricGhosts (Emodel, level, newTime);
338
-
339
- faraday_ (layouts, quantities.B , E, quantities_new.B , dt);
340
- }
341
- if constexpr (dimension == 3 )
342
- {
343
- auto && fluxes_x = std::get<0 >(flux_tuple);
344
- auto && fluxes_y = std::get<1 >(flux_tuple);
345
- auto && fluxes_z = std::get<2 >(flux_tuple);
346
-
347
- finite_volume_euler_ (layouts, quantities.rho , quantities_new.rho , dt, fluxes_x.rho ,
348
- fluxes_y.rho , fluxes_z.rho );
349
- finite_volume_euler_ (layouts, quantities.rhoVx , quantities_new.rhoVx , dt, fluxes_x.rhoVx ,
350
- fluxes_y.rhoVx , fluxes_z.rhoVx );
351
- finite_volume_euler_ (layouts, quantities.rhoVy , quantities_new.rhoVy , dt, fluxes_x.rhoVy ,
352
- fluxes_y.rhoVy , fluxes_z.rhoVy );
353
- finite_volume_euler_ (layouts, quantities.rhoVz , quantities_new.rhoVz , dt, fluxes_x.rhoVz ,
354
- fluxes_y.rhoVz , fluxes_z.rhoVz );
355
- finite_volume_euler_ (layouts, quantities.Etot , quantities_new.Etot , dt, fluxes_x.Etot ,
356
- fluxes_y.Etot , fluxes_z.Etot );
357
-
358
- fromCoarser.fillMagneticFluxGhosts (fluxes_x.B , level, newTime);
359
- fromCoarser.fillMagneticFluxGhosts (fluxes_y.B , level, newTime);
360
- fromCoarser.fillMagneticFluxGhosts (fluxes_z.B , level, newTime);
361
- constrained_transport_ (layouts, E, fluxes_x.B , fluxes_y.B , fluxes_z.B );
362
- fromCoarser.fillElectricGhosts (Emodel, level, newTime);
363
-
364
- faraday_ (layouts, quantities.B , E, quantities_new.B , dt);
365
- }
366
- }
367
-
368
286
} // namespace PHARE::solver
369
287
370
288
#endif
0 commit comments