33 for (
unsigned int i = 0; i < N; ++i)
41 for (
unsigned int i = 0; i < N; ++i)
42 for (
unsigned int j = 0; j < N; ++j)
53 for (
unsigned int i = 0; i < N; ++i)
54 for (
unsigned int j = 0; j < N; ++j)
55 for (
unsigned int k = 0; k < N; ++k)
65 template <
int dim,
int spacedim>
71 const unsigned int component)
73 std::complex<double>
sum = 0;
74 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
77 sum +=
std::exp(std::complex<double>(0, 1) * (k_vector * x_q)) *
90 template <
int spacedim>
93 const std::vector<unsigned int> &n_coefficients_per_direction,
97 const unsigned int fe,
98 const unsigned int component,
99 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
103 if (fourier_transform_matrices[fe].m() == 0)
105 fourier_transform_matrices[fe].reinit(
106 n_coefficients_per_direction[fe],
107 fe_collection[fe].n_dofs_per_cell());
109 for (
unsigned int k = 0; k < n_coefficients_per_direction[fe]; ++k)
110 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell(); ++j)
111 fourier_transform_matrices[fe](k, j) = integrate(
112 fe_collection[fe], q_collection[fe], k_vectors(k), j, component);
116 template <
int spacedim>
119 const std::vector<unsigned int> &n_coefficients_per_direction,
123 const unsigned int fe,
124 const unsigned int component,
125 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
129 if (fourier_transform_matrices[fe].m() == 0)
131 fourier_transform_matrices[fe].reinit(
133 fe_collection[fe].n_dofs_per_cell());
136 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
137 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe];
139 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell();
141 fourier_transform_matrices[fe](k, j) =
142 integrate(fe_collection[fe],
150 template <
int spacedim>
153 const std::vector<unsigned int> &n_coefficients_per_direction,
157 const unsigned int fe,
158 const unsigned int component,
159 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
163 if (fourier_transform_matrices[fe].m() == 0)
165 fourier_transform_matrices[fe].reinit(
167 fe_collection[fe].n_dofs_per_cell());
170 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
171 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe]; ++k2)
172 for (
unsigned int k3 = 0; k3 < n_coefficients_per_direction[fe];
174 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell();
176 fourier_transform_matrices[fe](k, j) =
177 integrate(fe_collection[fe],
179 k_vectors(k1, k2, k3),
190 template <
int dim,
int spacedim>
192 const std::vector<unsigned int> &n_coefficients_per_direction,
195 const unsigned int component_)
196 : n_coefficients_per_direction(n_coefficients_per_direction)
197 , fe_collection(&fe_collection)
198 , q_collection(q_collection)
199 , fourier_transform_matrices(fe_collection.size())
200 , component(component_ !=
numbers::invalid_unsigned_int ? component_ : 0)
204 ExcMessage(
"All parameters are supposed to have the same size."));
210 "For vector-valued problems, you need to explicitly specify for "
211 "which vector component you will want to do a Fourier decomposition "
212 "by setting the 'component' argument of this constructor."));
216 const unsigned int max_n_coefficients_per_direction =
219 set_k_vectors(
k_vectors, max_n_coefficients_per_direction);
227 template <
int dim,
int spacedim>
243 template <
int dim,
int spacedim>
248 for (
unsigned int fe = 0; fe < fe_collection->
size(); ++fe)
250 ensure_existence(n_coefficients_per_direction,
256 fourier_transform_matrices);
264 template <
int dim,
int spacedim>
267 const unsigned int index)
const
269 return n_coefficients_per_direction[index];
274 template <
int dim,
int spacedim>
275 template <
typename Number>
279 const unsigned int cell_active_fe_index,
282 for (
unsigned int d = 0; d < dim; ++d)
284 n_coefficients_per_direction[cell_active_fe_index]);
286 ensure_existence(n_coefficients_per_direction,
290 cell_active_fe_index,
292 fourier_transform_matrices);
295 fourier_transform_matrices[cell_active_fe_index];
298 n_coefficients_per_direction[cell_active_fe_index]));
299 std::fill(unrolled_coefficients.begin(),
300 unrolled_coefficients.end(),
308 for (
unsigned int i = 0; i < unrolled_coefficients.size(); ++i)
309 for (
unsigned int j = 0; j < local_dof_values.
size(); ++j)
310 unrolled_coefficients[i] += matrix[i][j] * local_dof_values[j];
312 fourier_coefficients.fill(unrolled_coefficients.begin());
318#include "fe_series_fourier.inst"
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()
virtual double shape_value_component(const unsigned int i, const Point< dim > &p, const unsigned int component) const
const Point< dim > & point(const unsigned int i) const
double weight(const unsigned int i) const
unsigned int size() const
virtual size_type size() const override
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
Task< RT > new_task(const std::function< RT()> &function)
T sum(const T &t, const MPI_Comm mpi_communicator)
constexpr T fixed_power(const T t)
static constexpr double PI
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > exp(const ::VectorizedArray< Number, width > &)