16 #ifndef dealii_fe_series_h 17 #define dealii_fe_series_h 90 template <
int dim,
int spacedim = dim>
127 template <
typename Number>
129 calculate(const ::Vector<Number> &local_dof_values,
130 const unsigned int cell_active_fe_index,
162 template <
class Archive>
170 template <
class Archive>
258 template <
int dim,
int spacedim = dim>
294 template <
typename Number>
296 calculate(const ::Vector<Number> &local_dof_values,
297 const unsigned int cell_active_fe_index,
329 template <
class Archive>
337 template <
class Archive>
394 template <
int dim,
typename CoefficientType>
395 std::pair<std::vector<unsigned int>, std::vector<double>>
397 const std::function<std::pair<bool, unsigned int>(
400 const double smallest_abs_coefficient = 1
e-10);
407 std::pair<double, double>
422 namespace FESeriesImplementation
424 template <
int dim,
typename CoefficientType>
431 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
433 const std::pair<bool, unsigned int> pred_pair = predicate(ind);
435 if (pred_pair.first ==
false)
438 const unsigned int pred_value = pred_pair.second;
442 pred_to_values[pred_value].push_back(coeff_value);
447 template <
typename CoefficientType>
453 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
455 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
458 fill_map_index(coefficients, ind, predicate, pred_to_values);
464 template <
typename CoefficientType>
470 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
472 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
473 for (
unsigned int j = 0; j < coefficients.
size(1); j++)
476 fill_map_index(coefficients, ind, predicate, pred_to_values);
482 template <
typename CoefficientType>
488 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
490 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
491 for (
unsigned int j = 0; j < coefficients.
size(1); j++)
492 for (
unsigned int k = 0; k < coefficients.
size(2); k++)
495 fill_map_index(coefficients, ind, predicate, pred_to_values);
501 template <
typename Number>
503 complex_mean_value(
const Number &
value)
510 template <
typename Number>
512 complex_mean_value(
const std::complex<Number> &
value)
516 "FESeries::process_coefficients() can not be used with " 517 "complex-valued coefficients and VectorTools::mean norm."));
518 return std::abs(value);
525 template <
int dim,
typename CoefficientType>
526 std::pair<std::vector<unsigned int>, std::vector<double>>
532 const double smallest_abs_coefficient)
534 Assert(smallest_abs_coefficient >= 0.,
535 ExcMessage(
"smallest_abs_coefficient should be non-negative."));
537 std::vector<unsigned int> predicate_values;
538 std::vector<double> norm_values;
543 std::map<unsigned int, std::vector<CoefficientType>> pred_to_values;
544 internal::FESeriesImplementation::fill_map(coefficients,
549 for (
const auto &pred_to_value : pred_to_values)
551 Vector<CoefficientType> values(pred_to_value.second.cbegin(),
552 pred_to_value.second.cend());
554 double norm_value = 0;
559 norm_value = values.l2_norm();
564 norm_value = values.l1_norm();
569 norm_value = values.linfty_norm();
574 norm_value = internal::FESeriesImplementation::complex_mean_value(
575 values.mean_value());
584 if (std::abs(norm_value) > smallest_abs_coefficient)
586 predicate_values.push_back(pred_to_value.first);
587 norm_values.push_back(norm_value);
591 return std::make_pair(predicate_values, norm_values);
596 template <
int dim,
int spacedim>
597 template <
class Archive>
611 for (
unsigned int i = 0; i < size; ++i)
617 for (
unsigned int i = 0; i < size; ++i)
626 template <
int dim,
int spacedim>
627 template <
class Archive>
636 std::vector<unsigned int> compare_coefficients;
637 ar & compare_coefficients;
638 Assert(compare_coefficients == n_coefficients_per_direction,
639 ExcMessage(
"A different number of coefficients vector has been used " 640 "to generate the transformation matrices you are about " 648 for (
unsigned int i = 0; i < size; ++i)
652 ExcMessage(
"A different FECollection has been used to generate " 653 "the transformation matrices you are about to load!"));
660 for (
unsigned int i = 0; i < size; ++i)
664 ExcMessage(
"A different QCollection has been used to generate " 665 "the transformation matrices you are about to load!"));
674 template <
int dim,
int spacedim>
675 template <
class Archive>
689 for (
unsigned int i = 0; i < size; ++i)
695 for (
unsigned int i = 0; i < size; ++i)
699 ar &legendre_transform_matrices;
704 template <
int dim,
int spacedim>
705 template <
class Archive>
714 std::vector<unsigned int> compare_coefficients;
715 ar & compare_coefficients;
716 Assert(compare_coefficients == n_coefficients_per_direction,
717 ExcMessage(
"A different number of coefficients vector has been used " 718 "to generate the transformation matrices you are about " 726 for (
unsigned int i = 0; i < size; ++i)
730 ExcMessage(
"A different FECollection has been used to generate " 731 "the transformation matrices you are about to load!"));
738 for (
unsigned int i = 0; i < size; ++i)
742 ExcMessage(
"A different QCollection has been used to generate " 743 "the transformation matrices you are about to load!"));
747 ar &legendre_transform_matrices;
755 #endif // dealii_fe_series_h
SmartPointer< const hp::FECollection< dim, spacedim > > fe_collection
#define AssertDimension(dim1, dim2)
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &fourier_coefficients)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
const hp::QCollection< dim > q_collection
std::vector< CoefficientType > unrolled_coefficients
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
void save_transformation_matrices(Archive &ar, const unsigned int version)
Fourier(const std::vector< unsigned int > &n_coefficients_per_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
#define AssertThrow(cond, exc)
std::vector< FullMatrix< CoefficientType > > legendre_transform_matrices
const std::vector< unsigned int > n_coefficients_per_direction
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
#define DEAL_II_NAMESPACE_CLOSE
SmartPointer< const hp::FECollection< dim, spacedim > > fe_collection
void precalculate_all_transformation_matrices()
typename std::complex< double > CoefficientType
void load_transformation_matrices(Archive &ar, const unsigned int version)
const std::vector< unsigned int > n_coefficients_per_direction
Table< dim, Tensor< 1, dim > > k_vectors
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)
unsigned int get_n_coefficients_per_direction(const unsigned int index) const
size_type size(const unsigned int i) const
std::vector< FullMatrix< CoefficientType > > fourier_transform_matrices
#define DEAL_II_NAMESPACE_OPEN
std::vector< CoefficientType > unrolled_coefficients
bool operator==(const Fourier< dim, spacedim > &fourier) const
static ::ExceptionBase & ExcNotImplemented()
void save_transformation_matrices(Archive &ar, const unsigned int version)
const hp::QCollection< dim > q_collection
#define DEAL_II_DEPRECATED
void load_transformation_matrices(Archive &ar, const unsigned int version)