ryujin 2.1.1 revision b04fb4aba7bd97ddfa5994a6b4b6e8586eb15db2
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#include "parabolic_system.h"
13
14#include <hyperbolic_module.h>
15#include <initial_values.h>
16#include <mpi_ensemble.h>
17#include <offline_data.h>
18
19#include <deal.II/base/parameter_acceptor.h>
20#include <deal.II/lac/la_parallel_block_vector.h>
21#include <deal.II/lac/precondition.h>
22#include <deal.II/matrix_free/matrix_free.h>
23
24namespace ryujin
25{
26 namespace EulerPoisson
27 {
103
104 } // namespace EulerPoisson
105} // namespace ryujin
106
107#ifndef DOXYGEN
108DECLARE_ENUM(
111 "no restart"},
113 "full restart"},
115 "correction"},
117 "static no restart"},
119 "static full restart"}));
120#endif
121
122namespace ryujin
123{
124 namespace EulerPoisson
125 {
132 template <typename HyperbolicDescription, int dim, typename Number>
133 class ParabolicModule final : public dealii::ParameterAcceptor
134 {
135 public:
140
142
143 using View = typename HyperbolicSystem::template View<dim, Number>;
144
146
148 dealii::LinearAlgebra::distributed::BlockVector<Number>;
149
150 using ScalarNumber = typename View::ScalarNumber;
151
152 static constexpr auto problem_dimension = View::problem_dimension;
153
154 using state_type = typename View::state_type;
155
157
161
165 ParabolicModule(const MPIEnsemble &mpi_ensemle,
166 const OfflineData<dim, Number> &offline_data,
167 const HyperbolicSystem &hyperbolic_system,
168 const ParabolicSystem &parabolic_system,
170 &initial_values,
171 const std::string &subsection = "/ParabolicModule");
172
178 void prepare();
179
181
185
193 void reinit_state_vector(StateVector<Number> &state_vector) const;
194
202 void prepare_state_vector(StateVector<Number> &state_vector,
203 Number t) const;
204
214 template <int stages>
216 const StateVector<Number> &old_state_vector,
217 const Number old_t,
218 std::array<std::reference_wrapper<const StateVector<Number>>, stages>
219 stage_state_vectors,
220 const std::array<Number, stages> stage_weights,
221 StateVector<Number> &new_state_vector,
222 Number tau) const;
223
232 void crank_nicolson_step(const StateVector<Number> &old_state_vector,
233 const Number old_t,
234 StateVector<Number> &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<Number>> diagonal_preconditioner_;
338 MGSmoother<dim, Number> multigrid_preconditioner_;
339 UpdateOperator<dim, Number> update_operator_;
340
341 mutable ScalarHostVector<Number> potential_rhs_;
342 mutable ScalarHostVector<Number> density_;
343 mutable ScalarHostVector<Number> 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,
382 StateVector<Number> &state_vector) const;
383
388 void
389 enforce_magnetic_drift_velocity(StateVector<Number> &state_vector) const;
390
400 void step(const StateVector<Number> &old_state_vector,
401 const Number old_t,
402 StateVector<Number> &new_state_vector,
403 Number tau,
404 const bool crank_nicolson_extrapolation) const;
405
407 };
408 } // namespace EulerPoisson
409} /* namespace ryujin */
typename HyperbolicSystem::template View< dim, Number > View
void crank_nicolson_step(const StateVector< Number > &old_state_vector, const Number old_t, StateVector< Number > &new_state_vector, Number tau) const
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
typename View::ScalarNumber ScalarNumber
void print_solver_statistics(std::ostream &output) const
void backward_euler_step(const StateVector< Number > &old_state_vector, const Number old_t, std::array< std::reference_wrapper< const StateVector< Number > >, stages > stage_state_vectors, const std::array< Number, stages > stage_weights, StateVector< Number > &new_state_vector, Number tau) const
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
void set_id_violation_strategy(const IDViolationStrategy &strategy) const
void prepare_state_vector(StateVector< Number > &state_vector, Number t) const
void reinit_state_vector(StateVector< Number > &state_vector) const
#define ACCESSOR_READ_ONLY(member)
dealii::LinearAlgebra::distributed::Vector< Number > ScalarHostVector