15#ifndef dealii_fe_series_h
16#define dealii_fe_series_h
88 template <
int dim,
int spacedim = dim>
122 template <
typename Number>
125 const unsigned int cell_active_fe_index,
157 template <
class Archive>
165 template <
class Archive>
258 template <
int dim,
int spacedim = dim>
292 template <
typename Number>
294 calculate(const ::Vector<Number> &local_dof_values,
295 const unsigned int cell_active_fe_index,
327 template <
class Archive>
335 template <
class Archive>
398 template <
int dim,
typename CoefficientType>
399 std::pair<std::vector<unsigned int>, std::vector<double>>
401 const std::function<std::pair<bool, unsigned int>(
404 const double smallest_abs_coefficient = 1e-10);
411 std::pair<double, double>
426 namespace FESeriesImplementation
428 template <
int dim,
typename CoefficientType>
435 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
437 const std::pair<bool, unsigned int> pred_pair = predicate(ind);
439 if (pred_pair.first ==
false)
442 const unsigned int pred_value = pred_pair.second;
443 const CoefficientType &coeff_value = coefficients(ind);
446 pred_to_values[pred_value].push_back(coeff_value);
451 template <
typename CoefficientType>
457 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
459 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
462 fill_map_index(coefficients, ind, predicate, pred_to_values);
468 template <
typename CoefficientType>
474 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
476 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
477 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
480 fill_map_index(coefficients, ind, predicate, pred_to_values);
486 template <
typename CoefficientType>
492 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
494 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
495 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
496 for (
unsigned int k = 0; k < coefficients.size(2); ++k)
499 fill_map_index(coefficients, ind, predicate, pred_to_values);
505 template <
typename Number>
507 complex_mean_value(
const Number &value)
514 template <
typename Number>
516 complex_mean_value(
const std::complex<Number> &value)
520 "FESeries::process_coefficients() can not be used with "
521 "complex-valued coefficients and VectorTools::mean norm."));
529template <
int dim,
typename CoefficientType>
530std::pair<std::vector<unsigned int>, std::vector<double>>
536 const double smallest_abs_coefficient)
538 Assert(smallest_abs_coefficient >= 0.,
539 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
541 std::vector<unsigned int> predicate_values;
542 std::vector<double> norm_values;
547 std::map<unsigned int, std::vector<CoefficientType>> pred_to_values;
548 internal::FESeriesImplementation::fill_map(coefficients,
553 for (
const auto &pred_to_value : pred_to_values)
556 pred_to_value.second.cend());
558 double norm_value = 0;
563 norm_value =
values.l2_norm();
568 norm_value =
values.l1_norm();
573 norm_value =
values.linfty_norm();
578 norm_value = internal::FESeriesImplementation::complex_mean_value(
588 if (
std::abs(norm_value) > smallest_abs_coefficient)
590 predicate_values.push_back(pred_to_value.first);
591 norm_values.push_back(norm_value);
595 return std::make_pair(predicate_values, norm_values);
600template <
int dim,
int spacedim>
601template <
class Archive>
610 ar &n_coefficients_per_direction;
613 unsigned int size = fe_collection->size();
615 for (
unsigned int i = 0; i < size; ++i)
616 ar &(*fe_collection)[i].get_name();
619 size = q_collection.size();
621 for (
unsigned int i = 0; i < size; ++i)
625 ar &fourier_transform_matrices;
630template <
int dim,
int spacedim>
631template <
class Archive>
640 std::vector<unsigned int> compare_coefficients;
641 ar &compare_coefficients;
642 Assert(compare_coefficients == n_coefficients_per_direction,
643 ExcMessage(
"A different number of coefficients vector has been used "
644 "to generate the transformation matrices you are about "
652 for (
unsigned int i = 0; i < size; ++i)
655 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
656 ExcMessage(
"A different FECollection has been used to generate "
657 "the transformation matrices you are about to load!"));
664 for (
unsigned int i = 0; i < size; ++i)
667 Assert(quadrature == q_collection[i],
668 ExcMessage(
"A different QCollection has been used to generate "
669 "the transformation matrices you are about to load!"));
673 ar &fourier_transform_matrices;
678template <
int dim,
int spacedim>
679template <
class Archive>
688 ar &n_coefficients_per_direction;
691 unsigned int size = fe_collection->size();
693 for (
unsigned int i = 0; i < size; ++i)
694 ar &(*fe_collection)[i].get_name();
697 size = q_collection.size();
699 for (
unsigned int i = 0; i < size; ++i)
703 ar &legendre_transform_matrices;
708template <
int dim,
int spacedim>
709template <
class Archive>
718 std::vector<unsigned int> compare_coefficients;
719 ar &compare_coefficients;
720 Assert(compare_coefficients == n_coefficients_per_direction,
721 ExcMessage(
"A different number of coefficients vector has been used "
722 "to generate the transformation matrices you are about "
730 for (
unsigned int i = 0; i < size; ++i)
733 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
734 ExcMessage(
"A different FECollection has been used to generate "
735 "the transformation matrices you are about to load!"));
742 for (
unsigned int i = 0; i < size; ++i)
745 Assert(quadrature == q_collection[i],
746 ExcMessage(
"A different QCollection has been used to generate "
747 "the transformation matrices you are about to load!"));
751 ar &legendre_transform_matrices;
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &fourier_coefficients)
Table< dim, Tensor< 1, dim > > k_vectors
std::vector< CoefficientType > unrolled_coefficients
const unsigned int component
typename std::complex< double > CoefficientType
unsigned int get_n_coefficients_per_direction(const unsigned int index) const
const std::vector< unsigned int > n_coefficients_per_direction
ObserverPointer< const hp::FECollection< dim, spacedim > > fe_collection
bool operator==(const Fourier< dim, spacedim > &fourier) const
std::vector< FullMatrix< CoefficientType > > fourier_transform_matrices
const hp::QCollection< dim > q_collection
void precalculate_all_transformation_matrices()
void load_transformation_matrices(Archive &ar, const unsigned int version)
void save_transformation_matrices(Archive &ar, const unsigned int version)
const std::vector< unsigned int > n_coefficients_per_direction
ObserverPointer< const hp::FECollection< dim, spacedim > > fe_collection
void save_transformation_matrices(Archive &ar, const unsigned int version)
bool operator==(const Legendre< dim, spacedim > &legendre) const
const unsigned int component
std::vector< FullMatrix< CoefficientType > > legendre_transform_matrices
const hp::QCollection< dim > q_collection
void precalculate_all_transformation_matrices()
unsigned int get_n_coefficients_per_direction(const unsigned int index) const
std::vector< CoefficientType > unrolled_coefficients
void load_transformation_matrices(Archive &ar, const unsigned int version)
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &legendre_coefficients)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::pair< std::vector< unsigned int >, std::vector< double > > process_coefficients(const Table< dim, CoefficientType > &coefficients, const std::function< std::pair< bool, unsigned int >(const TableIndices< dim > &)> &predicate, const VectorTools::NormType norm_type, const double smallest_abs_coefficient=1e-10)
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)