16#ifndef dealii_fe_series_h
17#define dealii_fe_series_h
87 template <
int dim,
int spacedim = dim>
121 template <
typename Number>
124 const unsigned int cell_active_fe_index,
156 template <
class Archive>
164 template <
class Archive>
257 template <
int dim,
int spacedim = dim>
291 template <
typename Number>
293 calculate(const ::Vector<Number> &local_dof_values,
294 const unsigned int cell_active_fe_index,
326 template <
class Archive>
334 template <
class Archive>
397 template <
int dim,
typename CoefficientType>
398 std::pair<std::vector<unsigned int>, std::vector<double>>
400 const std::function<std::pair<bool, unsigned int>(
403 const double smallest_abs_coefficient = 1e-10);
410 std::pair<double, double>
425 namespace FESeriesImplementation
427 template <
int dim,
typename CoefficientType>
434 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
436 const std::pair<bool, unsigned int> pred_pair = predicate(ind);
438 if (pred_pair.first ==
false)
441 const unsigned int pred_value = pred_pair.second;
442 const CoefficientType &coeff_value = coefficients(ind);
445 pred_to_values[pred_value].push_back(coeff_value);
450 template <
typename CoefficientType>
456 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
458 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
461 fill_map_index(coefficients, ind, predicate, pred_to_values);
467 template <
typename CoefficientType>
473 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
475 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
476 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
479 fill_map_index(coefficients, ind, predicate, pred_to_values);
485 template <
typename CoefficientType>
491 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
493 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
494 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
495 for (
unsigned int k = 0; k < coefficients.size(2); ++k)
498 fill_map_index(coefficients, ind, predicate, pred_to_values);
504 template <
typename Number>
506 complex_mean_value(
const Number &value)
513 template <
typename Number>
515 complex_mean_value(
const std::complex<Number> &value)
519 "FESeries::process_coefficients() can not be used with "
520 "complex-valued coefficients and VectorTools::mean norm."));
528template <
int dim,
typename CoefficientType>
529std::pair<std::vector<unsigned int>, std::vector<double>>
535 const double smallest_abs_coefficient)
537 Assert(smallest_abs_coefficient >= 0.,
538 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
540 std::vector<unsigned int> predicate_values;
541 std::vector<double> norm_values;
546 std::map<unsigned int, std::vector<CoefficientType>> pred_to_values;
547 internal::FESeriesImplementation::fill_map(coefficients,
552 for (
const auto &pred_to_value : pred_to_values)
555 pred_to_value.second.cend());
557 double norm_value = 0;
562 norm_value =
values.l2_norm();
567 norm_value =
values.l1_norm();
572 norm_value =
values.linfty_norm();
577 norm_value = internal::FESeriesImplementation::complex_mean_value(
587 if (
std::abs(norm_value) > smallest_abs_coefficient)
589 predicate_values.push_back(pred_to_value.first);
590 norm_values.push_back(norm_value);
594 return std::make_pair(predicate_values, norm_values);
599template <
int dim,
int spacedim>
600template <
class Archive>
609 ar &n_coefficients_per_direction;
612 unsigned int size = fe_collection->size();
614 for (
unsigned int i = 0; i < size; ++i)
615 ar &(*fe_collection)[i].get_name();
618 size = q_collection.size();
620 for (
unsigned int i = 0; i < size; ++i)
624 ar &fourier_transform_matrices;
629template <
int dim,
int spacedim>
630template <
class Archive>
639 std::vector<unsigned int> compare_coefficients;
640 ar & compare_coefficients;
641 Assert(compare_coefficients == n_coefficients_per_direction,
642 ExcMessage(
"A different number of coefficients vector has been used "
643 "to generate the transformation matrices you are about "
651 for (
unsigned int i = 0; i < size; ++i)
654 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
655 ExcMessage(
"A different FECollection has been used to generate "
656 "the transformation matrices you are about to load!"));
663 for (
unsigned int i = 0; i < size; ++i)
666 Assert(quadrature == q_collection[i],
667 ExcMessage(
"A different QCollection has been used to generate "
668 "the transformation matrices you are about to load!"));
672 ar &fourier_transform_matrices;
677template <
int dim,
int spacedim>
678template <
class Archive>
687 ar &n_coefficients_per_direction;
690 unsigned int size = fe_collection->size();
692 for (
unsigned int i = 0; i < size; ++i)
693 ar &(*fe_collection)[i].get_name();
696 size = q_collection.size();
698 for (
unsigned int i = 0; i < size; ++i)
702 ar &legendre_transform_matrices;
707template <
int dim,
int spacedim>
708template <
class Archive>
717 std::vector<unsigned int> compare_coefficients;
718 ar & compare_coefficients;
719 Assert(compare_coefficients == n_coefficients_per_direction,
720 ExcMessage(
"A different number of coefficients vector has been used "
721 "to generate the transformation matrices you are about "
729 for (
unsigned int i = 0; i < size; ++i)
732 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
733 ExcMessage(
"A different FECollection has been used to generate "
734 "the transformation matrices you are about to load!"));
741 for (
unsigned int i = 0; i < size; ++i)
744 Assert(quadrature == q_collection[i],
745 ExcMessage(
"A different QCollection has been used to generate "
746 "the transformation matrices you are about to load!"));
750 ar &legendre_transform_matrices;
SmartPointer< const hp::FECollection< dim, spacedim > > fe_collection
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
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
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
SmartPointer< const hp::FECollection< dim, spacedim > > fe_collection
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 > &)