18 #include <deal.II/base/config.h> 20 #include <deal.II/base/numbers.h> 22 #include <deal.II/fe/fe_series.h> 27 DEAL_II_NAMESPACE_OPEN
34 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)
52 for (
unsigned int i = 0; i < N; ++i)
53 for (
unsigned int j = 0; j < N; ++j)
54 for (
unsigned int k = 0; k < N; ++k)
64 template <
int dim,
int spacedim>
71 std::complex<double>
sum = 0;
72 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
75 sum += std::exp(std::complex<double>(0, 1) * (k_vector * x_q)) *
87 template <
int spacedim>
93 const unsigned int fe,
94 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
98 if (fourier_transform_matrices[fe].m() == 0)
100 fourier_transform_matrices[fe].reinit(k_vectors.n_elements(),
101 fe_collection[fe].dofs_per_cell);
103 for (
unsigned int k = 0; k < k_vectors.size(0); ++k)
104 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
105 fourier_transform_matrices[fe](k, j) =
106 integrate(fe_collection[fe], q_collection[fe], k_vectors(k), j);
110 template <
int spacedim>
116 const unsigned int fe,
117 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
121 if (fourier_transform_matrices[fe].m() == 0)
123 fourier_transform_matrices[fe].reinit(k_vectors.n_elements(),
124 fe_collection[fe].dofs_per_cell);
127 for (
unsigned int k1 = 0; k1 < k_vectors.size(0); ++k1)
128 for (
unsigned int k2 = 0; k2 < k_vectors.size(1); ++k2, k++)
129 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
130 fourier_transform_matrices[fe](k, j) = integrate(
131 fe_collection[fe], q_collection[fe], k_vectors(k1, k2), j);
135 template <
int spacedim>
141 const unsigned int fe,
142 std::vector<
FullMatrix<std::complex<double>>> &fourier_transform_matrices)
146 if (fourier_transform_matrices[fe].m() == 0)
148 fourier_transform_matrices[fe].reinit(k_vectors.n_elements(),
149 fe_collection[fe].dofs_per_cell);
152 for (
unsigned int k1 = 0; k1 < k_vectors.size(0); ++k1)
153 for (
unsigned int k2 = 0; k2 < k_vectors.size(1); ++k2)
154 for (
unsigned int k3 = 0; k3 < k_vectors.size(2); ++k3, k++)
155 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
156 fourier_transform_matrices[fe](k, j) =
157 integrate(fe_collection[fe],
159 k_vectors(k1, k2, k3),
169 template <
int dim,
int spacedim>
171 const unsigned int N,
174 : fe_collection(&fe_collection)
175 , q_collection(&q_collection)
176 , fourier_transform_matrices(fe_collection.size())
184 template <
int dim,
int spacedim>
185 template <
typename Number>
188 const Vector<Number> & local_dof_values,
189 const unsigned int cell_active_fe_index,
192 ensure_existence(*fe_collection,
195 cell_active_fe_index,
196 fourier_transform_matrices);
199 fourier_transform_matrices[cell_active_fe_index];
201 std::fill(unrolled_coefficients.begin(),
202 unrolled_coefficients.end(),
203 CoefficientType(0.));
207 Assert(local_dof_values.size() == matrix.n(),
210 for (
unsigned int i = 0; i < unrolled_coefficients.size(); i++)
211 for (
unsigned int j = 0; j < local_dof_values.size(); j++)
212 unrolled_coefficients[i] += matrix[i][j] * local_dof_values[j];
214 fourier_coefficients.
fill(unrolled_coefficients.begin());
220 #include "fe_series_fourier.inst" 222 DEAL_II_NAMESPACE_CLOSE
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &fourier_coefficients)
#define AssertIndexRange(index, range)
const Point< dim > & point(const unsigned int i) const
unsigned int size() const
size_type n_elements() const
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
Fourier(const unsigned int size_in_each_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)
Table< dim, Tensor< 1, dim > > k_vectors
unsigned int size() const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
static constexpr double PI
std::vector< CoefficientType > unrolled_coefficients
void fill(InputIterator entries, const bool C_style_indexing=true)
double weight(const unsigned int i) const
static ::ExceptionBase & ExcInternalError()