56 template <
int dim,
typename CoefficientType>
61 for (
unsigned int d = 0;
d < dim; ++
d)
88 std::pair<bool, unsigned int>
92 for (
unsigned int i = 0; i < dim; ++i)
95 return std::make_pair((v < N), v);
101 template <
int dim,
int spacedim,
typename VectorType>
105 const VectorType & solution,
111 using number =
typename VectorType::value_type;
116 dof_handler.get_triangulation().n_active_cells());
123 std::pair<std::vector<unsigned int>, std::vector<double>>
res;
124 for (
const auto &cell : dof_handler.active_cell_iterators() |
128 cell->coarsen_flag_set())
131 cell->active_fe_index());
134 local_dof_values.
reinit(cell->get_fe().n_dofs_per_cell());
135 cell->get_dof_values(solution, local_dof_values);
138 cell->active_fe_index(),
145 res = FESeries::process_coefficients<dim>(
156 float regularity = std::numeric_limits<float>::infinity();
166 const std::pair<double, double>
fit =
168 regularity =
static_cast<float>(-
fit.first);
175 numbers::signaling_nan<float>();
181 template <
int dim,
int spacedim,
typename VectorType>
186 const VectorType & solution,
193 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
195 using number =
typename VectorType::value_type;
200 dof_handler.get_triangulation().n_active_cells());
207 const unsigned int max_degree =
208 dof_handler.get_fe_collection().max_degree();
210 std::vector<double>
x,
y;
211 x.reserve(max_degree);
212 y.reserve(max_degree);
214 for (
const auto &cell : dof_handler.active_cell_iterators() |
218 cell->coarsen_flag_set())
221 cell->active_fe_index());
224 const unsigned int pe = cell->get_fe().degree;
232 local_dof_values.
reinit(cell->get_fe().n_dofs_per_cell());
233 cell->get_dof_values(solution, local_dof_values);
236 cell->active_fe_index(),
241 double k_v = std::numeric_limits<double>::infinity();
242 for (
unsigned int d = 0; d < dim; ++d)
249 for (
unsigned int i = 0; i <=
pe; ++i)
269 const std::pair<double, double>
fit =
278 static_cast<float>(
k_v);
282 numbers::signaling_nan<float>();
288 template <
int dim,
int spacedim>
291 const unsigned int component)
298 std::vector<unsigned int> n_coefficients_per_direction;
299 for (
unsigned int i = 0; i < fe_collection.
size(); ++i)
300 n_coefficients_per_direction.push_back(fe_collection[i].degree + 2);
318 for (
unsigned int i = 0; i < fe_collection.
size(); ++i)
320 const QGauss<dim> quadrature(n_coefficients_per_direction[i]);
353 std::pair<bool, unsigned int>
356 const unsigned int N)
359 for (
unsigned int i = 0; i < dim; ++i)
362 return std::make_pair((v > 0 && v < N * N), v);
368 template <
int dim,
int spacedim,
typename VectorType>
372 const VectorType & solution,
378 using number =
typename VectorType::value_type;
383 dof_handler.get_triangulation().n_active_cells());
389 std::vector<double>
ln_k;
390 std::pair<std::vector<unsigned int>, std::vector<double>>
res;
391 for (
const auto &cell : dof_handler.active_cell_iterators() |
395 cell->coarsen_flag_set())
398 cell->active_fe_index());
405 local_dof_values.
reinit(cell->get_fe().n_dofs_per_cell());
406 cell->get_dof_values(solution, local_dof_values);
409 cell->active_fe_index(),
416 res = FESeries::process_coefficients<dim>(
428 float regularity = std::numeric_limits<float>::infinity();
441 for (
unsigned int f = 0; f <
res.first.
size(); ++f)
448 const std::pair<double, double>
fit =
451 regularity =
static_cast<float>(-
fit.first) -
452 ((dim > 1) ? (.5 * dim) : 0);
460 numbers::signaling_nan<float>();
466 template <
int dim,
int spacedim,
typename VectorType>
471 const VectorType & solution,
478 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
480 using number =
typename VectorType::value_type;
485 dof_handler.get_triangulation().n_active_cells());
492 const unsigned int max_degree =
493 dof_handler.get_fe_collection().max_degree();
495 std::vector<double>
x,
y;
496 x.reserve(max_degree);
497 y.reserve(max_degree);
499 for (
const auto &cell : dof_handler.active_cell_iterators() |
503 cell->coarsen_flag_set())
506 cell->active_fe_index());
509 const unsigned int pe = cell->get_fe().degree;
517 local_dof_values.
reinit(cell->get_fe().n_dofs_per_cell());
518 cell->get_dof_values(solution, local_dof_values);
521 cell->active_fe_index(),
526 double k_v = std::numeric_limits<double>::infinity();
527 for (
unsigned int d = 0; d < dim; ++d)
536 for (
unsigned int i = 1; i <=
pe; ++i)
556 const std::pair<double, double>
fit =
565 static_cast<float>(
k_v);
569 numbers::signaling_nan<float>();
575 template <
int dim,
int spacedim>
578 const unsigned int component)
587 std::vector<unsigned int> n_coefficients_per_direction;
588 for (
unsigned int i = 0; i < fe_collection.
size(); ++i)
589 n_coefficients_per_direction.push_back(fe_collection[i].degree + 2);
607 for (
unsigned int i = 0; i < fe_collection.
size(); ++i)
610 n_coefficients_per_direction[i] - 1);
625#include "smoothness_estimator.inst"
void reinit(value_type *starting_element, const std::size_t n_elements)
typename std::complex< double > CoefficientType
unsigned int size() const
void push_back(const Quadrature< dim_in > &new_quadrature)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void coefficient_decay_per_direction(FESeries::Fourier< dim, spacedim > &fe_fourier, const DoFHandler< dim, spacedim > &dof_handler, const VectorType &solution, Vector< float > &smoothness_indicators, const ComponentMask &coefficients_predicate=ComponentMask(), const double smallest_abs_coefficient=1e-10, const bool only_flagged_cells=false)
FESeries::Fourier< dim, spacedim > default_fe_series(const hp::FECollection< dim, spacedim > &fe_collection, const unsigned int component=numbers::invalid_unsigned_int)
void coefficient_decay(FESeries::Fourier< dim, spacedim > &fe_fourier, const DoFHandler< dim, spacedim > &dof_handler, const VectorType &solution, Vector< float > &smoothness_indicators, const VectorTools::NormType regression_strategy=VectorTools::Linfty_norm, const double smallest_abs_coefficient=1e-10, const bool only_flagged_cells=false)
void coefficient_decay_per_direction(FESeries::Legendre< dim, spacedim > &fe_legendre, const DoFHandler< dim, spacedim > &dof_handler, const VectorType &solution, Vector< float > &smoothness_indicators, const ComponentMask &coefficients_predicate=ComponentMask(), const double smallest_abs_coefficient=1e-10, const bool only_flagged_cells=false)
FESeries::Legendre< dim, spacedim > default_fe_series(const hp::FECollection< dim, spacedim > &fe_collection, const unsigned int component=numbers::invalid_unsigned_int)
void coefficient_decay(FESeries::Legendre< dim, spacedim > &fe_legendre, const DoFHandler< dim, spacedim > &dof_handler, const VectorType &solution, Vector< float > &smoothness_indicators, const VectorTools::NormType regression_strategy=VectorTools::Linfty_norm, const double smallest_abs_coefficient=1e-10, const bool only_flagged_cells=false)
::VectorizedArray< Number, width > log(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)