include/meltpooldg/utilities/amr_indicators.hpp Source File

Developer Documentation: include/meltpooldg/utilities/amr_indicators.hpp Source File
Developer Documentation
amr_indicators.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/exceptions.h>
4#include <deal.II/base/vectorization.h>
5
6#include <deal.II/grid/tria.h>
7
8#include <deal.II/lac/la_parallel_vector.h>
9#include <deal.II/lac/vector.h>
10
11#include <deal.II/matrix_free/matrix_free.h>
12
15
16#include <memory>
17#include <utility>
18#include <vector>
19
20namespace MeltPoolDG::AMR
21{
28 template <int dim, typename number>
30 {
31 public:
40 virtual dealii::Vector<number>
41 compute_indicator(const dealii::Triangulation<dim> &tria) = 0;
42
43 virtual ~AMRIndicatorBase() = default;
44 };
45
51 template <int dim, typename number, template <typename> class BinaryOp = std::plus>
52 class BinaryOpIndicatorComposite : public AMRIndicatorBase<dim, number>
53 {
54 using VectorType = dealii::Vector<number>;
55
56 public:
63 void
64 add_indicator(std::unique_ptr<AMRIndicatorBase<dim, number>> &&indicator, number weight = 1.);
65
74 compute_indicator(const dealii::Triangulation<dim> &tria) override;
75
79 bool
80 empty() const;
81
82 private:
84 {
86 std::unique_ptr<AMRIndicatorBase<dim, number>> indicator;
87
89 number weight;
90 };
91
93 std::vector<IndicatorAndWeight> indicators_and_weights;
94 };
95
117 template <int dim, typename number, int n_dof_components, int n_indicator_components>
118 class SSEDIndicator : public AMRIndicatorBase<dim, number>
119 {
120 using VectorizedArrayType = dealii::VectorizedArray<number>;
121
122 using VectorType = dealii::LinearAlgebra::distributed::Vector<number>;
123
125 std::function<dealii::Tensor<1, n_indicator_components, VectorizedArrayType>(
126 const dealii::Tensor<1, n_dof_components, VectorizedArrayType> &)>;
127
128 public:
148 const VectorType &solution,
150 const unsigned fe_index,
151 const unsigned fe_degree);
152
158 dealii::Vector<number>
159 compute_indicator(const dealii::Triangulation<dim> &tria) override;
160
161 protected:
168 void
169 local_apply_cell(const dealii::MatrixFree<dim, number> &,
170 dealii::AlignedVector<VectorizedArrayType> &dst,
171 const VectorType &src,
172 const std::pair<unsigned, unsigned> &cell_range);
173
174 private:
177
180
184
186 const unsigned fe_index;
187
188 dealii::AlignedVector<VectorizedArrayType> linearized_matrix;
189 };
190
212 template <int dim, typename number, int n_mf_components = dim, int n_relevant_components = dim>
213 class JumpIndicator : public AMRIndicatorBase<dim, number>
214 {
215 public:
216 using VectorizedArrayType = dealii::VectorizedArray<number>;
217
218 using VectorType = dealii::LinearAlgebra::distributed::Vector<number>;
220 std::function<dealii::Tensor<1, n_relevant_components, VectorizedArrayType>(
221 const dealii::Tensor<1, n_mf_components, VectorizedArrayType> &)>;
222
239 const VectorType &solution,
241 const unsigned fe_index = 0);
242
248 dealii::Vector<number>
249 compute_indicator(const dealii::Triangulation<dim> &tria) override;
250
251 protected:
258 void
259 local_apply_face(const dealii::MatrixFree<dim, number> &,
260 dealii::AlignedVector<VectorizedArrayType> &dst,
261 const VectorType &src,
262 const std::pair<unsigned, unsigned> &face_range) const;
263
264 private:
267
270
274
276 const unsigned fe_index;
277 };
278} // namespace MeltPoolDG::AMR
Definition amr_indicators.hpp:30
virtual dealii::Vector< number > compute_indicator(const dealii::Triangulation< dim > &tria)=0
virtual ~AMRIndicatorBase()=default
Definition amr_indicators.hpp:53
VectorType compute_indicator(const dealii::Triangulation< dim > &tria) override
Definition amr_indicators.templates.hpp:25
bool empty() const
Definition amr_indicators.templates.hpp:56
dealii::Vector< number > VectorType
Definition amr_indicators.hpp:54
std::vector< IndicatorAndWeight > indicators_and_weights
Vector storing the combination of refinement indicator and weights.
Definition amr_indicators.hpp:93
void add_indicator(std::unique_ptr< AMRIndicatorBase< dim, number > > &&indicator, number weight=1.)
Definition amr_indicators.templates.hpp:16
Definition amr_indicators.hpp:214
dealii::Vector< number > compute_indicator(const dealii::Triangulation< dim > &tria) override
Definition amr_indicators.templates.hpp:205
const MatrixFreeContext< dim, number > matrix_free_context
Matrix free object used to compute the solution.
Definition amr_indicators.hpp:266
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition amr_indicators.hpp:218
ExtractIndicatorDofValuesFunction extract_indicator_dof_values
Definition amr_indicators.hpp:273
void local_apply_face(const dealii::MatrixFree< dim, number > &, dealii::AlignedVector< VectorizedArrayType > &dst, const VectorType &src, const std::pair< unsigned, unsigned > &face_range) const
Definition amr_indicators.templates.hpp:239
const unsigned fe_index
Relevant fe index for the fe object of the dof handler in the matrix free object.
Definition amr_indicators.hpp:276
dealii::VectorizedArray< number > VectorizedArrayType
Definition amr_indicators.hpp:216
std::function< dealii::Tensor< 1, n_relevant_components, VectorizedArrayType >(const dealii::Tensor< 1, n_mf_components, VectorizedArrayType > &)> ExtractIndicatorDofValuesFunction
Definition amr_indicators.hpp:221
const VectorType & solution
Reference to the solution of the field of interest.
Definition amr_indicators.hpp:269
Definition amr_indicators.hpp:119
const MatrixFreeContext< dim, number > matrix_free_context
Matrix free context used to compute the solution.
Definition amr_indicators.hpp:176
dealii::Vector< number > compute_indicator(const dealii::Triangulation< dim > &tria) override
Definition amr_indicators.templates.hpp:88
ExtractIndicatorDofValuesFunction extract_indicator_dof_values
Definition amr_indicators.hpp:183
dealii::VectorizedArray< number > VectorizedArrayType
Definition amr_indicators.hpp:120
dealii::LinearAlgebra::distributed::Vector< number > VectorType
Definition amr_indicators.hpp:122
const VectorType & solution
Reference to the solution of the field of interest.
Definition amr_indicators.hpp:179
void local_apply_cell(const dealii::MatrixFree< dim, number > &, dealii::AlignedVector< VectorizedArrayType > &dst, const VectorType &src, const std::pair< unsigned, unsigned > &cell_range)
Definition amr_indicators.templates.hpp:119
const unsigned fe_index
Relevant fe index for the fe object of the dof handler in the matrix free object.
Definition amr_indicators.hpp:186
std::function< dealii::Tensor< 1, n_indicator_components, VectorizedArrayType >(const dealii::Tensor< 1, n_dof_components, VectorizedArrayType > &)> ExtractIndicatorDofValuesFunction
Definition amr_indicators.hpp:126
dealii::AlignedVector< VectorizedArrayType > linearized_matrix
Definition amr_indicators.hpp:188
Definition amr.hpp:15
number weight
Scaling weight.
Definition amr_indicators.hpp:89
std::unique_ptr< AMRIndicatorBase< dim, number > > indicator
Refinement indicator.
Definition amr_indicators.hpp:86
Definition matrix_free_util.hpp:21