16 #ifndef dealii_fe_series_H 17 #define dealii_fe_series_H 21 #include <deal.II/base/config.h> 23 #include <deal.II/base/exceptions.h> 24 #include <deal.II/base/subscriptor.h> 25 #include <deal.II/base/table.h> 26 #include <deal.II/base/table_indices.h> 27 #include <deal.II/base/tensor.h> 29 #include <deal.II/hp/fe_collection.h> 30 #include <deal.II/hp/q_collection.h> 32 #include <deal.II/lac/full_matrix.h> 33 #include <deal.II/lac/vector.h> 35 #include <deal.II/numerics/vector_tools.h> 42 DEAL_II_NAMESPACE_OPEN
90 template <
int dim,
int spacedim = dim>
94 using CoefficientType =
typename std::complex<double>;
103 Fourier(
const unsigned int size_in_each_direction,
112 template <
typename Number>
114 calculate(const ::Vector<Number> &local_dof_values,
115 const unsigned int cell_active_fe_index,
188 template <
int dim,
int spacedim = dim>
192 using CoefficientType = double;
201 Legendre(
const unsigned int size_in_each_direction,
210 template <
typename Number>
212 calculate(const ::Vector<Number> &local_dof_values,
213 const unsigned int cell_active_fe_index,
220 const unsigned int N;
258 template <
int dim,
typename CoefficientType>
259 std::pair<std::vector<unsigned int>, std::vector<double>>
261 const std::function<std::pair<bool, unsigned int>(
272 std::pair<double, double>
285 namespace FESeriesImplementation
287 template <
int dim,
typename CoefficientType>
294 std::map<
unsigned int, std::vector<CoefficientType>> &pred_to_values)
296 const std::pair<bool, unsigned int> pred_pair = predicate(ind);
298 if (pred_pair.first ==
false)
301 const unsigned int pred_value = pred_pair.second;
302 const CoefficientType &coeff_value = coefficients(ind);
305 pred_to_values[pred_value].push_back(coeff_value);
308 template <
typename CoefficientType>
314 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
316 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
319 fill_map_index(coefficients, ind, predicate, pred_to_values);
323 template <
typename CoefficientType>
329 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
331 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
332 for (
unsigned int j = 0; j < coefficients.
size(1); j++)
335 fill_map_index(coefficients, ind, predicate, pred_to_values);
339 template <
typename CoefficientType>
345 std::map<
unsigned int, std::vector<CoefficientType>> & pred_to_values)
347 for (
unsigned int i = 0; i < coefficients.
size(0); i++)
348 for (
unsigned int j = 0; j < coefficients.
size(1); j++)
349 for (
unsigned int k = 0; k < coefficients.
size(2); k++)
352 fill_map_index(coefficients, ind, predicate, pred_to_values);
357 template <
typename Number>
359 complex_mean_value(
const Number &value)
364 template <
typename Number>
366 complex_mean_value(
const std::complex<Number> &value)
370 "FESeries::process_coefficients() can not be used with" 371 "complex-valued coefficients and VectorTools::mean norm."));
372 return std::abs(value);
378 template <
int dim,
typename CoefficientType>
379 std::pair<std::vector<unsigned int>, std::vector<double>>
386 std::vector<unsigned int> predicate_values;
387 std::vector<double> norm_values;
392 std::map<unsigned int, std::vector<CoefficientType>> pred_to_values;
393 internal::FESeriesImplementation::fill_map(coefficients,
398 for (
const auto &pred_to_value : pred_to_values)
400 predicate_values.push_back(pred_to_value.first);
401 Vector<CoefficientType> values(pred_to_value.second.cbegin(),
402 pred_to_value.second.cend());
408 norm_values.push_back(values.l2_norm());
413 norm_values.push_back(values.l1_norm());
418 norm_values.push_back(values.linfty_norm());
423 norm_values.push_back(
424 internal::FESeriesImplementation::complex_mean_value(
425 values.mean_value()));
434 return std::make_pair(predicate_values, norm_values);
440 DEAL_II_NAMESPACE_CLOSE
442 #endif // dealii_fe_series_H
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)
std::vector< CoefficientType > unrolled_coefficients
SmartPointer< const hp::QCollection< dim > > q_collection
Legendre(const unsigned int size_in_each_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
#define AssertThrow(cond, exc)
SmartPointer< const hp::QCollection< dim > > q_collection
std::vector< FullMatrix< CoefficientType > > legendre_transform_matrices
static ::ExceptionBase & ExcMessage(std::string arg1)
Fourier(const unsigned int size_in_each_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
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 > &legendre_coefficients)
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)
size_type size(const unsigned int i) const
std::vector< FullMatrix< CoefficientType > > fourier_transform_matrices
std::vector< CoefficientType > unrolled_coefficients
static ::ExceptionBase & ExcNotImplemented()