ryujin 2.5.0 revision 3a6c8d57210175dea14d8116e1fe878f349f8c1c
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 <ryujin/base/compile_time_options.h>
14
15#include <deal.II/base/parameter_acceptor.h>
16
17#include <random>
18
19namespace ryujin
20{
44
52 enum class MarkingStrategy {
59 };
60
77} // namespace ryujin
78
79#ifndef DOXYGEN
80DECLARE_ENUM(
82 LIST({ryujin::AdaptationStrategy::global_refinement, "global refinement"},
85 "smoothness indicators"}, ));
86
87DECLARE_ENUM(ryujin::MarkingStrategy,
89 "fixed threshold"}));
90
93 "fixed time points"},
95 "simulation cycle"}, ));
96#endif
97
98namespace ryujin
99{
106 template <int dim, typename Number = double>
107 class MeshAdaptor final : public Interface::MeshAdaptor<dim, Number>
108 {
109 public:
114
118 MeshAdaptor(const MPIEnsemble &mpi_ensemble,
119 const Interface::OfflineData<dim, Number> &offline_data,
120 const Interface::Postprocessor<dim, Number> &postprocessor,
121 const std::string &subsection = "/MeshAdaptor");
122
127 void prepare(const Number t) override;
128
130
134
140 void analyze(const StateVector<Number> &state_vector,
141 const Number t,
142 unsigned int cycle) override;
143
149 dealii::Triangulation<dim> &triangulation) const override;
150
156 & /*transformation*/) const override
157 {
158 }
159
161
162 private:
167
168 AdaptationStrategy adaptation_strategy_;
169 std::uint_fast64_t random_adaptation_mersenne_twister_seed_;
170
171 MarkingStrategy marking_strategy_;
172 double coarsening_threshold_;
173 double refinement_threshold_;
174 bool absolute_threshold_;
175 unsigned int min_refinement_level_;
176 unsigned int max_refinement_level_;
177
178 TimePointSelectionStrategy time_point_selection_strategy_;
179 std::vector<Number> adaptation_time_points_;
180 unsigned int adaptation_cycle_interval_;
181
182 std::vector<std::string> smoothness_selected_quantities_;
183 Number smoothness_local_global_ratio_;
184 Number smoothness_min_cutoff_;
185 Number smoothness_max_cutoff_;
186 unsigned int smoothness_widen_stencil_;
187
189
193
194 const MPIEnsemble &mpi_ensemble_;
195
196 dealii::ObserverPointer<const Interface::OfflineData<dim, Number>>
197 offline_data_;
198
199 const Interface::Postprocessor<dim, Number> &postprocessor_;
200
202
203 /* The computed cell indicators. */
204 mutable dealii::Vector<float> indicators_;
205
206 /* random adaptation: */
207 mutable std::mt19937_64 mersenne_twister_;
208
209 /*
210 * smoothness indicators: only valid if the "smoothness indicator"
211 * refinement strategy has been selected.
212 */
213 mutable ScalarVector<Number> smoothness_indicators_;
214
216
220
221 /* random adaptation: */
222 void populate_cell_indicators_with_random_values() const;
223
224 /* smoothness indicators: */
225 void populate_cell_indicators_from_smoothness_indicators() const;
226
227 /*
228 * Compute smoothness indicators. This function reinitializes and
229 * populates the smoothness_indicators_ vector.
230 */
231 void compute_smoothness_indicators(
232 const StateVector<Number> &state_vector) const;
233
235 };
236
237} // namespace ryujin
typename Discretization< dim >::Transformation Transformation
void prepare(const Number t) override
void update_transformation(typename Interface::MeshAdaptor< dim, Number >::Transformation &) const override
void mark_cells_for_coarsening_and_refinement(dealii::Triangulation< dim > &triangulation) const override
MeshAdaptor(const MPIEnsemble &mpi_ensemble, const Interface::OfflineData< dim, Number > &offline_data, const Interface::Postprocessor< dim, Number > &postprocessor, const std::string &subsection="/MeshAdaptor")
void analyze(const StateVector< Number > &state_vector, const Number t, unsigned int cycle) override
TimePointSelectionStrategy
AdaptationStrategy