ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
Loading...
Searching...
No Matches
parabolic_module.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <ryujin/base/compile_time_options.h>
16
17#include <deal.II/base/parameter_acceptor.h>
18#include <deal.II/lac/la_parallel_block_vector.h>
19#include <deal.II/lac/precondition.h>
20#include <deal.II/matrix_free/matrix_free.h>
21
22#include <limits>
23#include <memory>
24#include <vector>
25
26namespace ryujin
27{
28 namespace EulerPoisson
29 {
105
106 } // namespace EulerPoisson
107} // namespace ryujin
108
109#ifndef DOXYGEN
110DECLARE_ENUM(
113 "no restart"},
115 "full restart"},
117 "correction"},
119 "static no restart"},
121 "static full restart"}));
122#endif
123
124namespace ryujin
125{
126 namespace EulerPoisson
127 {
134 template <typename HyperbolicDescription, int dim, typename Number>
135 class ParabolicModule final : public Interface::ParabolicModule<dim, Number>
136 {
137 public:
142
144 typename Interface::ParabolicModule<dim, Number>::StageVectors;
145
147 typename Interface::ParabolicModule<dim, Number>::StageWeights;
148
149 using HyperbolicSystem = typename HyperbolicDescription::HyperbolicSystem;
150
151 using View = typename HyperbolicSystem::template View<dim, Number>;
152
154
156 dealii::LinearAlgebra::distributed::BlockVector<Number>;
157
158 using ScalarNumber = typename View::ScalarNumber;
159
160 static constexpr auto problem_dimension = View::problem_dimension;
161
162 using state_type = typename View::state_type;
163
165
169
173 ParabolicModule(const MPIEnsemble &mpi_ensemle,
174 const OfflineData<dim, Number> &offline_data,
175 const HyperbolicSystem &hyperbolic_system,
176 const ParabolicSystem &parabolic_system,
178 &initial_values,
179 const std::string &subsection = "/ParabolicModule");
180
186 void prepare() override;
187
189
193
201 void
202 reinit_state_vector(StateVector<Number> &state_vector) const override;
203
211 void prepare_state_vector(StateVector<Number> &state_vector,
212 Number t) const override;
213
224 Number backward_euler_step(
225 const StateVector<Number> &old_state_vector,
226 StageVectors stage_state_vectors,
227 StageWeights stage_weights,
228 StateVector<Number> &new_state_vector,
229 Number t,
230 Number tau,
231 Number tau_max = std::numeric_limits<Number>::max()) const override;
232
241 Number crank_nicolson_step(
242 const StateVector<Number> &old_state_vector,
243 StateVector<Number> &new_state_vector,
244 Number t,
245 Number tau,
246 Number tau_max = std::numeric_limits<Number>::max()) const override;
247
249
253
259 void print_solver_statistics(std::ostream &output) const override;
260
261 private:
263
267
268 GaussLawRestartStrategy gauss_law_restart_strategy_;
269
270 unsigned int gmg_max_iter_;
271 double gmg_smoother_range_;
272 double gmg_smoother_max_eig_;
273 unsigned int gmg_smoother_degree_;
274 unsigned int gmg_smoother_n_cg_iter_;
275 unsigned int gmg_min_level_;
276
277 Number tolerance_;
278 bool tolerance_linfty_norm_;
279
281
285
286 // FIXME: refactor
287 static constexpr unsigned int order_fe = 1;
288 static constexpr unsigned int order_quad = 2;
289
290 const MPIEnsemble &mpi_ensemble_;
291
292 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
293 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
294 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
295 offline_data_;
296 dealii::ObserverPointer<
298 initial_values_;
299
300 std::vector<std::unique_ptr<ElectrostaticConfiguration<dim, Number>>>
301 electrostatic_configuration_list_;
302
304 *selected_electrostatic_configuration_ = nullptr;
305
306 mutable unsigned int cycle_;
307 mutable double n_iterations_gauss_;
308 mutable double n_iterations_step_;
309
310 dealii::MatrixFree<dim, Number> matrix_free_;
311 dealii::AffineConstraints<Number> affine_constraints_potential_;
312
313 LaplaceOperator<dim, Number> laplace_operator_;
314 dealii::DiagonalMatrix<ScalarHostVector<Number>> diagonal_preconditioner_;
315 MGSmoother<dim, Number> multigrid_preconditioner_;
316 UpdateOperator<dim, Number> update_operator_;
317
318 mutable ScalarHostVector<Number> potential_rhs_;
319 mutable ScalarHostVector<Number> density_;
320 mutable ScalarHostVector<Number> background_density_;
321 mutable BlockHostVector magnetic_field_;
322 mutable BlockHostVector velocity_rhs_;
323
324 mutable bool potential_initialized_;
325 mutable Number t_background_density_;
326 mutable Number t_magnetic_field_;
328
332
339 template <int stages>
340 void backward_euler_step(const StateVector<Number> &old_state_vector,
341 StageVectors stage_state_vectors,
342 StageWeights stage_weights,
343 StateVector<Number> &new_state_vector,
344 Number t,
345 Number tau) const;
346
350 void create_constraints();
351
358 void update_background_density(const Number t) const;
359
366 void update_magnetic_field(const Number t) const;
367
372 void compute_potential(const Number t,
373 StateVector<Number> &state_vector) const;
374
379 void
380 enforce_magnetic_drift_velocity(StateVector<Number> &state_vector) const;
381
391 void step(const StateVector<Number> &old_state_vector,
392 StateVector<Number> &new_state_vector,
393 Number t,
394 Number tau,
395 const bool crank_nicolson_extrapolation) const;
396
398 };
399 } // namespace EulerPoisson
400} // namespace ryujin
typename Interface::ParabolicModule< dim, Number >::StageVectors StageVectors
typename Interface::ParabolicModule< dim, Number >::StageWeights StageWeights
typename HyperbolicSystem::template View< dim, Number > View
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
typename View::ScalarNumber ScalarNumber
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
void print_solver_statistics(std::ostream &output) const override
Number crank_nicolson_step(const StateVector< Number > &old_state_vector, StateVector< Number > &new_state_vector, Number t, Number tau, Number tau_max=std::numeric_limits< Number >::max()) const override
void prepare_state_vector(StateVector< Number > &state_vector, Number t) const override
Number backward_euler_step(const StateVector< Number > &old_state_vector, StageVectors stage_state_vectors, StageWeights stage_weights, StateVector< Number > &new_state_vector, Number t, Number tau, Number tau_max=std::numeric_limits< Number >::max()) const override
void reinit_state_vector(StateVector< Number > &state_vector) const override
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector