ryujin 2.5.0 revision c64172211cf21344cb9b9b0f3a1266aa6400d392
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>
17
18#include <deal.II/base/parameter_acceptor.h>
19
20#include <random>
21
22namespace ryujin
23{
47
55 enum class MarkingStrategy {
62 };
63} // namespace ryujin
64
65#ifndef DOXYGEN
66DECLARE_ENUM(
68 LIST({ryujin::AdaptationStrategy::global_refinement, "global refinement"},
71 "smoothness indicators"}, ));
72
73DECLARE_ENUM(ryujin::MarkingStrategy,
75 "fixed threshold"}));
76#endif
77
78namespace ryujin
79{
93 template <int dim, typename Number = double>
94 class MeshAdaptor final : public dealii::ParameterAcceptor,
95 public Interface::Task<Number>
96 {
97 public:
102
107 const std::string &subsection = "/MeshAdaptor");
108
110
114
119 void prepare(TaskContext<Number> &context) override;
120
124 void execute(TaskContext<Number> &context) override;
125
127
128 private:
133
134 AdaptationStrategy adaptation_strategy_;
135 std::uint_fast64_t random_adaptation_mersenne_twister_seed_;
136
137 MarkingStrategy marking_strategy_;
138 double coarsening_threshold_;
139 double refinement_threshold_;
140 bool absolute_threshold_;
141 unsigned int min_refinement_level_;
142 unsigned int max_refinement_level_;
143
144 std::vector<std::string> smoothness_selected_quantities_;
145 Number smoothness_local_global_ratio_;
146 Number smoothness_min_cutoff_;
147 Number smoothness_max_cutoff_;
148 unsigned int smoothness_widen_stencil_;
149
151
155
156 Trigger<Number> trigger_;
157
159 const MPIEnsemble &mpi_ensemble_;
160
161 dealii::ObserverPointer<const OfflineData<dim, Number>> offline_data_;
162
163 const Interface::Postprocessor<dim, Number> &postprocessor_;
164
166
167 /* The computed cell indicators. */
168 dealii::Vector<float> indicators_;
169
170 /* random adaptation: */
171 std::mt19937_64 mersenne_twister_;
172
173 /*
174 * smoothness indicators: only valid if the "smoothness indicator"
175 * refinement strategy has been selected.
176 */
177 ScalarVector<Number> smoothness_indicators_;
178
180
184
189 void analyze(const StateVector<Number> &state_vector);
190
195 void mark_cells_for_coarsening_and_refinement();
196
197 /* random adaptation: */
198 void populate_cell_indicators_with_random_values();
199
200 /* smoothness indicators: */
201 void populate_cell_indicators_from_smoothness_indicators();
202
203 /*
204 * Compute smoothness indicators. This function reinitializes and
205 * populates the smoothness_indicators_ vector.
206 */
207 void compute_smoothness_indicators(const StateVector<Number> &state_vector);
208
210 };
211
212} // namespace ryujin
MeshAdaptor(Interface::Simulation< dim, Number > &simulation, const std::string &subsection="/MeshAdaptor")
void execute(TaskContext< Number > &context) override
void prepare(TaskContext< Number > &context) override
AdaptationStrategy