ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
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 <compile_time_options.h>
9
11#include "laplace_operator.h"
12
13#include <hyperbolic_module.h>
14#include <initial_values.h>
15#include <mpi_ensemble.h>
16#include <offline_data.h>
17
18#include <deal.II/base/parameter_acceptor.h>
19#include <deal.II/lac/precondition.h>
20#include <deal.II/matrix_free/matrix_free.h>
21
22namespace ryujin
23{
24 namespace EulerPoisson
25 {
101
102 } // namespace EulerPoisson
103} // namespace ryujin
104
105#ifndef DOXYGEN
106DECLARE_ENUM(
109 "no restart"},
111 "full restart"},
113 "correction"},
115 "static no restart"},
117 "static full restart"}));
118#endif
119
120namespace ryujin
121{
122 namespace EulerPoisson
123 {
130 template <typename Description, int dim, typename Number>
131 class ParabolicModule final : public dealii::ParameterAcceptor
132 {
133 public:
138
140
141 using View = typename HyperbolicSystem::template View<dim, Number>;
142
144
145 using StateVector = typename View::StateVector;
146
148
150
151 using ScalarNumber = typename View::ScalarNumber;
152
153 static constexpr auto problem_dimension = View::problem_dimension;
154
155 using state_type = typename View::state_type;
156
158
162
167 const MPIEnsemble &mpi_ensemle,
168 const OfflineData<dim, Number> &offline_data,
169 const HyperbolicSystem &hyperbolic_system,
170 const ParabolicSystem &parabolic_system,
171 const InitialValues<Description, dim, Number> &initial_values,
172 const std::string &subsection = "/ParabolicModule");
173
179 void prepare();
180
182
186
194 void reinit_state_vector(StateVector &state_vector) const;
195
203 void prepare_state_vector(StateVector &state_vector, Number t) const;
204
214 template <int stages>
215 void
216 backward_euler_step(const StateVector &old_state_vector,
217 const Number old_t,
218 std::array<std::reference_wrapper<const StateVector>,
219 stages> stage_state_vectors,
220 const std::array<Number, stages> stage_weights,
221 StateVector &new_state_vector,
222 Number tau) const;
223
232 void crank_nicolson_step(const StateVector &old_state_vector,
233 const Number old_t,
234 StateVector &new_state_vector,
235 Number tau) const;
236
241 {
242 id_violation_strategy_ = strategy;
243 }
244
246
250
256 void print_solver_statistics(std::ostream &output) const;
257
261 ACCESSOR_READ_ONLY(n_restarts)
262
263
268 ACCESSOR_READ_ONLY(n_corrections)
269
270
274 ACCESSOR_READ_ONLY(n_warnings)
275
276 private:
278
282
283 GaussLawRestartStrategy gauss_law_restart_strategy_;
284
285 unsigned int gmg_max_iter_;
286 double gmg_smoother_range_;
287 double gmg_smoother_max_eig_;
288 unsigned int gmg_smoother_degree_;
289 unsigned int gmg_smoother_n_cg_iter_;
290 unsigned int gmg_min_level_;
291
292 Number tolerance_;
293 bool tolerance_linfty_norm_;
294
296
300
301 // FIXME: refactor
302 static constexpr unsigned int order_fe = 1;
303 static constexpr unsigned int order_quad = 2;
304
305 const MPIEnsemble &mpi_ensemble_;
306
307 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
308 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
309 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
310 offline_data_;
311 dealii::ObserverPointer<
313 initial_values_;
314
315 ElectrostaticConfigurationLibrary::
316 electrostatic_configuration_list_type<dim, Number>
317 electrostatic_configuration_list_;
318
319 std::shared_ptr<ElectrostaticConfigurationLibrary::
320 ElectrostaticConfiguration<dim, Number>>
321 selected_electrostatic_configuration_;
322
323 mutable IDViolationStrategy id_violation_strategy_;
324
325 mutable unsigned int cycle_;
326 mutable double n_iterations_gauss_;
327 mutable double n_iterations_step_;
328
329 mutable unsigned int n_restarts_;
330 mutable unsigned int n_corrections_;
331 mutable unsigned int n_warnings_;
332
333 dealii::MatrixFree<dim, Number> matrix_free_;
334 dealii::AffineConstraints<Number> affine_constraints_potential_;
335
336 LaplaceOperator<dim, Number> laplace_operator_;
337 dealii::DiagonalMatrix<ScalarHostVector> diagonal_preconditioner_;
338 MGSmoother<dim, Number> multigrid_preconditioner_;
339 UpdateOperator<dim, Number> update_operator_;
340
341 mutable ScalarHostVector potential_rhs_;
342 mutable ScalarHostVector density_;
343 mutable ScalarHostVector background_density_;
344 mutable BlockHostVector magnetic_field_;
345 mutable BlockHostVector velocity_rhs_;
346
347 mutable bool potential_initialized_;
348 mutable Number t_background_density_;
349 mutable Number t_magnetic_field_;
351
355
359 void create_constraints();
360
367 void update_background_density(const Number t) const;
368
375 void update_magnetic_field(const Number t) const;
376
381 void compute_potential(const Number t, StateVector &state_vector) const;
382
387 void enforce_magnetic_drift_velocity(StateVector &state_vector) const;
388
398 void step(const StateVector &old_state_vector,
399 const Number old_t,
400 StateVector &new_state_vector,
401 Number tau,
402 const bool crank_nicolson_extrapolation) const;
403
405 };
406 } // namespace EulerPoisson
407} /* namespace ryujin */
Vectors::BlockHostVector< Number > BlockHostVector
typename Description::HyperbolicSystem HyperbolicSystem
void crank_nicolson_step(const StateVector &old_state_vector, const Number old_t, StateVector &new_state_vector, Number tau) const
typename View::ScalarNumber ScalarNumber
typename Description::ParabolicSystem ParabolicSystem
Vectors::ScalarHostVector< Number > ScalarHostVector
void print_solver_statistics(std::ostream &output) const
void backward_euler_step(const StateVector &old_state_vector, const Number old_t, std::array< std::reference_wrapper< const StateVector >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector &new_state_vector, Number tau) const
typename HyperbolicSystem::template View< dim, Number > View
typename View::StateVector StateVector
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
void prepare_state_vector(StateVector &state_vector, Number t) const
void reinit_state_vector(StateVector &state_vector) const
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34
ryujin::StubParabolicSystem ParabolicSystem
Definition description.h:36