16 #ifndef dealii_fe_series_h
17 #define dealii_fe_series_h
89 template <
int dim,
int spacedim = dim>
123 template <
typename Number>
126 const unsigned int cell_active_fe_index,
158 template <
class Archive>
166 template <
class Archive>
259 template <
int dim,
int spacedim = dim>
293 template <
typename Number>
295 calculate(const ::Vector<Number> &local_dof_values,
296 const unsigned int cell_active_fe_index,
328 template <
class Archive>
336 template <
class Archive>
399 template <
int dim,
typename CoefficientType>
400 std::pair<std::vector<unsigned int>, std::vector<double>>
402 const std::function<std::pair<bool, unsigned int>(
405 const double smallest_abs_coefficient = 1
e-10);
412 std::pair<double, double>
427 namespace FESeriesImplementation
429 template <
int dim,
typename CoefficientType>
436 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
438 const std::pair<bool, unsigned int> pred_pair = predicate(ind);
440 if (pred_pair.first ==
false)
443 const unsigned int pred_value = pred_pair.second;
444 const CoefficientType &coeff_value = coefficients(ind);
447 pred_to_values[pred_value].push_back(coeff_value);
452 template <
typename CoefficientType>
458 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
460 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
463 fill_map_index(coefficients, ind, predicate, pred_to_values);
469 template <
typename CoefficientType>
475 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
477 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
478 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
481 fill_map_index(coefficients, ind, predicate, pred_to_values);
487 template <
typename CoefficientType>
493 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
495 for (
unsigned int i = 0; i < coefficients.size(0); ++i)
496 for (
unsigned int j = 0; j < coefficients.size(1); ++j)
497 for (
unsigned int k = 0; k < coefficients.size(2); ++k)
500 fill_map_index(coefficients, ind, predicate, pred_to_values);
506 template <
typename Number>
508 complex_mean_value(
const Number &value)
515 template <
typename Number>
517 complex_mean_value(
const std::complex<Number> &value)
521 "FESeries::process_coefficients() can not be used with "
522 "complex-valued coefficients and VectorTools::mean norm."));
530 template <
int dim,
typename CoefficientType>
531 std::pair<std::vector<unsigned int>, std::vector<double>>
537 const double smallest_abs_coefficient)
539 Assert(smallest_abs_coefficient >= 0.,
540 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
542 std::vector<unsigned int> predicate_values;
543 std::vector<double> norm_values;
548 std::map<unsigned int, std::vector<CoefficientType>> pred_to_values;
549 internal::FESeriesImplementation::fill_map(coefficients,
554 for (
const auto &pred_to_value : pred_to_values)
557 pred_to_value.second.cend());
559 double norm_value = 0;
564 norm_value =
values.l2_norm();
569 norm_value =
values.l1_norm();
574 norm_value =
values.linfty_norm();
579 norm_value = internal::FESeriesImplementation::complex_mean_value(
589 if (std::abs(norm_value) > smallest_abs_coefficient)
591 predicate_values.push_back(pred_to_value.first);
592 norm_values.push_back(norm_value);
596 return std::make_pair(predicate_values, norm_values);
601 template <
int dim,
int spacedim>
602 template <
class Archive>
611 ar &n_coefficients_per_direction;
614 unsigned int size = fe_collection->size();
616 for (
unsigned int i = 0; i < size; ++i)
617 ar &(*fe_collection)[i].get_name();
620 size = q_collection.size();
622 for (
unsigned int i = 0; i < size; ++i)
626 ar &fourier_transform_matrices;
631 template <
int dim,
int spacedim>
632 template <
class Archive>
641 std::vector<unsigned int> compare_coefficients;
642 ar & compare_coefficients;
643 Assert(compare_coefficients == n_coefficients_per_direction,
644 ExcMessage(
"A different number of coefficients vector has been used "
645 "to generate the transformation matrices you are about "
653 for (
unsigned int i = 0; i < size; ++i)
656 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
657 ExcMessage(
"A different FECollection has been used to generate "
658 "the transformation matrices you are about to load!"));
665 for (
unsigned int i = 0; i < size; ++i)
668 Assert(quadrature == q_collection[i],
669 ExcMessage(
"A different QCollection has been used to generate "
670 "the transformation matrices you are about to load!"));
674 ar &fourier_transform_matrices;
679 template <
int dim,
int spacedim>
680 template <
class Archive>
689 ar &n_coefficients_per_direction;
692 unsigned int size = fe_collection->size();
694 for (
unsigned int i = 0; i < size; ++i)
695 ar &(*fe_collection)[i].get_name();
698 size = q_collection.size();
700 for (
unsigned int i = 0; i < size; ++i)
704 ar &legendre_transform_matrices;
709 template <
int dim,
int spacedim>
710 template <
class Archive>
719 std::vector<unsigned int> compare_coefficients;
720 ar & compare_coefficients;
721 Assert(compare_coefficients == n_coefficients_per_direction,
722 ExcMessage(
"A different number of coefficients vector has been used "
723 "to generate the transformation matrices you are about "
731 for (
unsigned int i = 0; i < size; ++i)
734 Assert(name.compare((*fe_collection)[i].get_name()) == 0,
735 ExcMessage(
"A different FECollection has been used to generate "
736 "the transformation matrices you are about to load!"));
743 for (
unsigned int i = 0; i < size; ++i)
746 Assert(quadrature == q_collection[i],
747 ExcMessage(
"A different QCollection has been used to generate "
748 "the transformation matrices you are about to load!"));
752 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
Fourier(const std::vector< unsigned int > &n_coefficients_per_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection, const unsigned int component=numbers::invalid_unsigned_int)
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
Legendre(const std::vector< unsigned int > &n_coefficients_per_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection, const unsigned int component=numbers::invalid_unsigned_int)
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
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#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)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
static const unsigned int invalid_unsigned_int
double legendre(unsigned int l, double x)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)