ryujin 2.1.1 revision b04fb4aba7bd97ddfa5994a6b4b6e8586eb15db2
Loading...
Searching...
No Matches
mesh_adaptor.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2024 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include <ryujin/interface/parabolic_system.h>
11
12#include "mpi_ensemble.h"
13#include "observer_pointer.h"
14#include "offline_data.h"
16
17#include <deal.II/base/parameter_acceptor.h>
18
19#include <random>
20
21namespace ryujin
22{
46
54 enum class MarkingStrategy {
61 };
62
79} // namespace ryujin
80
81#ifndef DOXYGEN
82DECLARE_ENUM(
84 LIST({ryujin::AdaptationStrategy::global_refinement, "global refinement"},
87 "smoothness indicators"}, ));
88
89DECLARE_ENUM(ryujin::MarkingStrategy,
91 "fixed threshold"}));
92
95 "fixed time points"},
97 "simulation cycle"}, ));
98#endif
99
100namespace ryujin
101{
108 template <typename HyperbolicDescription, int dim, typename Number = double>
109 class MeshAdaptor final : public dealii::ParameterAcceptor
110 {
111 public:
116
118
119 using View = typename HyperbolicSystem::template View<dim, Number>;
120
121 static constexpr auto problem_dimension = View::problem_dimension;
122
124
128
132 MeshAdaptor(const MPIEnsemble &mpi_ensemble,
133 const OfflineData<dim, Number> &offline_data,
134 const HyperbolicSystem &hyperbolic_system,
135 const Interface::ParabolicSystem &parabolic_system,
136 const MultiComponentVector<Number> &initial_precomputed,
137 const ScalarVector<Number> &alpha,
138 const std::string &subsection = "/MeshAdaptor");
139
144 void prepare(const Number t);
145
147
151
157 void analyze(const StateVector<Number> &state_vector,
158 const Number t,
159 unsigned int cycle);
160
166 dealii::Triangulation<dim> &triangulation) const;
167
173 const StateVector<Number> &state_vector) const;
174
176
180
188
189
193
199
200 private:
202
206
207 AdaptationStrategy adaptation_strategy_;
208 std::uint_fast64_t random_adaptation_mersenne_twister_seed_;
209
210 MarkingStrategy marking_strategy_;
211 double coarsening_threshold_;
212 double refinement_threshold_;
213 bool absolute_threshold_;
214 unsigned int min_refinement_level_;
215 unsigned int max_refinement_level_;
216
217 TimePointSelectionStrategy time_point_selection_strategy_;
218 std::vector<Number> adaptation_time_points_;
219 unsigned int adaptation_cycle_interval_;
220
221 std::vector<std::string> smoothness_selected_quantities_;
222 Number smoothness_local_global_ratio_;
223 Number smoothness_min_cutoff_;
224 Number smoothness_max_cutoff_;
225 unsigned int smoothness_widen_stencil_;
226
228
232
233 const MPIEnsemble &mpi_ensemble_;
234
235 dealii::ObserverPointer<const OfflineData<dim, Number>> offline_data_;
236
238 selected_components_extractor_;
239
240 bool need_mesh_adaptation_;
241
242 mutable dealii::Vector<float> indicators_;
243
244 /* random adaptation: */
245 mutable std::mt19937_64 mersenne_twister_;
246
247 /* smoothness indicators: */
248 mutable ScalarVector<Number> smoothness_indicators_;
249
251
255
256 /* random adaptation: */
257 void populate_cell_indicators_with_random_values() const;
258
259 /* smoothness indicators: */
260 void populate_cell_indicators_from_smoothness_indicators() const;
261
263 };
264
265} // namespace ryujin
static constexpr auto problem_dimension
const auto & indicators() const
void mark_cells_for_coarsening_and_refinement(dealii::Triangulation< dim > &triangulation) const
void compute_smoothness_indicators(const StateVector< Number > &state_vector) const
void analyze(const StateVector< Number > &state_vector, const Number t, unsigned int cycle)
const auto & smoothness_indicators() const
typename HyperbolicDescription::HyperbolicSystem HyperbolicSystem
const auto & need_mesh_adaptation() const
typename HyperbolicSystem::template View< dim, Number > View
void prepare(const Number t)
TimePointSelectionStrategy
AdaptationStrategy
#define ACCESSOR_READ_ONLY(member)
SmartPointer< T, P > ObserverPointer