18 #include <deal.II/base/config.h> 20 #include <deal.II/base/numbers.h> 22 #include <deal.II/fe/fe_series.h> 26 #ifdef DEAL_II_WITH_GSL 27 # include <gsl/gsl_sf_legendre.h> 31 DEAL_II_NAMESPACE_OPEN
40 for (
unsigned int i = 0; i < N; ++i)
47 for (
unsigned int i = 0; i < N; ++i)
48 for (
unsigned int j = 0; j < N; ++j)
58 for (
unsigned int i = 0; i < N; ++i)
59 for (
unsigned int j = 0; j < N; ++j)
60 for (
unsigned int k = 0; k < N; ++k)
73 : fe_collection(&fe_collection)
74 , q_collection(&q_collection)
75 , fourier_transform_matrices(fe_collection.size())
85 const unsigned int cell_active_fe_index,
86 Table<dim, std::complex<double>> &fourier_coefficients)
94 std::complex<double>(0.));
102 for (
unsigned int j = 0; j < local_dof_values.
size(); j++)
113 const unsigned int j)
115 std::complex<double> sum = 0;
116 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
119 sum += std::exp(std::complex<double>(0, 1) * (k_vector * x_q)) *
130 Assert(fe < fe_collection->size(),
136 (*fe_collection)[fe].dofs_per_cell);
141 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell; ++j)
151 Assert(fe < fe_collection->size(),
157 (*fe_collection)[fe].dofs_per_cell);
163 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell;
177 Assert(fe < fe_collection->size(),
183 (*fe_collection)[fe].dofs_per_cell);
186 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell; ++j)
199 <<
"x[" << arg1 <<
"] = " << arg2 <<
" is not in [0,1]");
208 #ifdef DEAL_II_WITH_GSL 210 for (
unsigned int d = 0; d < dim; d++)
212 const double x = 2.0 * (x_q[d] - 0.5);
214 const int ind = indices[d];
215 res *= sqrt(2.0) * gsl_sf_legendre_Pl(ind, x);
224 ExcMessage(
"deal.II has to be configured with GSL" 225 "in order to use Legendre transformation."));
238 for (
unsigned int d = 0; d < dim; d++)
239 res *= (0.5 + indices[d]);
249 : N(size_in_each_direction)
250 , fe_collection(&fe_collection)
251 , q_collection(&q_collection)
252 , legendre_transform_matrices(fe_collection.size())
259 const unsigned int cell_active_fe_index,
270 Assert(local_dof_values.size() == matrix.
n(),
274 for (
unsigned int j = 0; j < local_dof_values.size(); j++)
286 const unsigned int dof)
289 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
295 return sum * multiplier(indices);
302 Assert(fe < fe_collection->size(),
312 for (
unsigned int k = 0; k <
N; ++k)
313 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell; ++j)
325 Assert(fe < fe_collection->size(),
334 for (
unsigned int k1 = 0; k1 <
N; ++k1)
335 for (
unsigned int k2 = 0; k2 <
N; ++k2, k++)
336 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell; ++j)
349 Assert(fe < fe_collection->size(),
358 for (
unsigned int k1 = 0; k1 <
N; ++k1)
359 for (
unsigned int k2 = 0; k2 <
N; ++k2)
360 for (
unsigned int k3 = 0; k3 <
N; ++k3, k++)
361 for (
unsigned int j = 0; j < (*fe_collection)[fe].dofs_per_cell;
372 std::pair<double, double>
378 Assert(x.size() == y.size(),
379 ExcMessage(
"x and y are expected to have the same size"));
383 "at least two points are required for linear regression fit"));
385 double sum_1 = 0.0, sum_x = 0.0, sum_x2 = 0.0, sum_y = 0.0, sum_xy = 0.0;
387 for (
unsigned int i = 0; i < x.size(); i++)
391 sum_x2 += x[i] * x[i];
393 sum_xy += x[i] * y[i];
405 invK.
vmult(X, B,
false);
407 return std::make_pair(X(1), X(0));
425 DEAL_II_NAMESPACE_CLOSE
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
static::ExceptionBase & ExcLegendre(int arg1, double arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
void ensure_existence(const unsigned int fe_index)
Table< dim, Tensor< 1, dim > > k_vectors
void calculate(const ::Vector< double > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, std::complex< double >> &fourier_coefficients)
SmartPointer< const hp::FECollection< dim > > fe_collection
Legendre(const unsigned int size_in_each_direction, const hp::FECollection< dim > &fe_collection, const hp::QCollection< dim > &q_collection)
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
SmartPointer< const hp::QCollection< dim > > q_collection
unsigned int size() const
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
#define AssertThrow(cond, exc)
void calculate(const ::Vector< double > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, double > &legendre_coefficients)
Fourier(const unsigned int size_in_each_direction, const hp::FECollection< dim > &fe_collection, const hp::QCollection< dim > &q_collection)
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
const Point< dim > & point(const unsigned int i) const
std::vector< std::complex< double > > unrolled_coefficients
SmartPointer< const hp::QCollection< dim > > q_collection
unsigned int size() const
static::ExceptionBase & ExcMessage(std::string arg1)
void invert(const FullMatrix< number2 > &M)
size_type size(const unsigned int i) const
#define Assert(cond, exc)
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
double weight(const unsigned int i) const
SmartPointer< const hp::FECollection< dim > > fe_collection
void ensure_existence(const unsigned int fe_index)
size_type n_elements() const
std::vector< double > unrolled_coefficients
std::vector< FullMatrix< std::complex< double > > > fourier_transform_matrices
void fill(InputIterator entries, const bool C_style_indexing=true)
std::vector< FullMatrix< double > > legendre_transform_matrices
static::ExceptionBase & ExcInternalError()