ryujin 2.1.1 revision 71cdc42292164f8095c0bd62c4ea75ebcfac58fa
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/la_parallel_block_vector.h>
20#include <deal.II/lac/precondition.h>
21#include <deal.II/matrix_free/matrix_free.h>
22
23namespace ryujin
24{
25 namespace EulerPoisson
26 {
102
103 } // namespace EulerPoisson
104} // namespace ryujin
105
106#ifndef DOXYGEN
107DECLARE_ENUM(
110 "no restart"},
112 "full restart"},
114 "correction"},
116 "static no restart"},
118 "static full restart"}));
119#endif
120
121namespace ryujin
122{
123 namespace EulerPoisson
124 {
131 template <typename Description, int dim, typename Number>
132 class ParabolicModule final : public dealii::ParameterAcceptor
133 {
134 public:
139
141
142 using View = typename HyperbolicSystem::template View<dim, Number>;
143
145
146 using StateVector = typename View::StateVector;
147
149
151 dealii::LinearAlgebra::distributed::BlockVector<Number>;
152
153 using ScalarNumber = typename View::ScalarNumber;
154
155 static constexpr auto problem_dimension = View::problem_dimension;
156
157 using state_type = typename View::state_type;
158
160
164
169 const MPIEnsemble &mpi_ensemle,
170 const OfflineData<dim, Number> &offline_data,
171 const HyperbolicSystem &hyperbolic_system,
172 const ParabolicSystem &parabolic_system,
173 const InitialValues<Description, dim, Number> &initial_values,
174 const std::string &subsection = "/ParabolicModule");
175
181 void prepare();
182
184
188
196 void reinit_state_vector(StateVector &state_vector) const;
197
205 void prepare_state_vector(StateVector &state_vector, Number t) const;
206
216 template <int stages>
217 void
218 backward_euler_step(const StateVector &old_state_vector,
219 const Number old_t,
220 std::array<std::reference_wrapper<const StateVector>,
221 stages> stage_state_vectors,
222 const std::array<Number, stages> stage_weights,
223 StateVector &new_state_vector,
224 Number tau) const;
225
234 void crank_nicolson_step(const StateVector &old_state_vector,
235 const Number old_t,
236 StateVector &new_state_vector,
237 Number tau) const;
238
243 {
244 id_violation_strategy_ = strategy;
245 }
246
248
252
258 void print_solver_statistics(std::ostream &output) const;
259
263 ACCESSOR_READ_ONLY(n_restarts)
264
265
270 ACCESSOR_READ_ONLY(n_corrections)
271
272
276 ACCESSOR_READ_ONLY(n_warnings)
277
278 private:
280
284
285 GaussLawRestartStrategy gauss_law_restart_strategy_;
286
287 unsigned int gmg_max_iter_;
288 double gmg_smoother_range_;
289 double gmg_smoother_max_eig_;
290 unsigned int gmg_smoother_degree_;
291 unsigned int gmg_smoother_n_cg_iter_;
292 unsigned int gmg_min_level_;
293
294 Number tolerance_;
295 bool tolerance_linfty_norm_;
296
298
302
303 // FIXME: refactor
304 static constexpr unsigned int order_fe = 1;
305 static constexpr unsigned int order_quad = 2;
306
307 const MPIEnsemble &mpi_ensemble_;
308
309 dealii::ObserverPointer<const HyperbolicSystem> hyperbolic_system_;
310 dealii::ObserverPointer<const ParabolicSystem> parabolic_system_;
311 dealii::ObserverPointer<const ryujin::OfflineData<dim, Number>>
312 offline_data_;
313 dealii::ObserverPointer<
315 initial_values_;
316
317 ElectrostaticConfigurationLibrary::
318 electrostatic_configuration_list_type<dim, Number>
319 electrostatic_configuration_list_;
320
321 std::shared_ptr<ElectrostaticConfigurationLibrary::
322 ElectrostaticConfiguration<dim, Number>>
323 selected_electrostatic_configuration_;
324
325 mutable IDViolationStrategy id_violation_strategy_;
326
327 mutable unsigned int cycle_;
328 mutable double n_iterations_gauss_;
329 mutable double n_iterations_step_;
330
331 mutable unsigned int n_restarts_;
332 mutable unsigned int n_corrections_;
333 mutable unsigned int n_warnings_;
334
335 dealii::MatrixFree<dim, Number> matrix_free_;
336 dealii::AffineConstraints<Number> affine_constraints_potential_;
337
338 LaplaceOperator<dim, Number> laplace_operator_;
339 dealii::DiagonalMatrix<ScalarHostVector> diagonal_preconditioner_;
340 MGSmoother<dim, Number> multigrid_preconditioner_;
341 UpdateOperator<dim, Number> update_operator_;
342
343 mutable ScalarHostVector potential_rhs_;
344 mutable ScalarHostVector density_;
345 mutable ScalarHostVector background_density_;
346 mutable BlockHostVector magnetic_field_;
347 mutable BlockHostVector velocity_rhs_;
348
349 mutable bool potential_initialized_;
350 mutable Number t_background_density_;
351 mutable Number t_magnetic_field_;
353
357
361 void create_constraints();
362
369 void update_background_density(const Number t) const;
370
377 void update_magnetic_field(const Number t) const;
378
383 void compute_potential(const Number t, StateVector &state_vector) const;
384
389 void enforce_magnetic_drift_velocity(StateVector &state_vector) const;
390
400 void step(const StateVector &old_state_vector,
401 const Number old_t,
402 StateVector &new_state_vector,
403 Number tau,
404 const bool crank_nicolson_extrapolation) const;
405
407 };
408 } // namespace EulerPoisson
409} /* namespace ryujin */
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
dealii::LinearAlgebra::distributed::BlockVector< Number > BlockHostVector
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::Vector< Number > ScalarHostVector
Euler::HyperbolicSystem HyperbolicSystem
Definition description.h:34
ryujin::StubParabolicSystem ParabolicSystem
Definition description.h:36