18 #include <deal.II/base/config.h> 20 #include <deal.II/fe/fe_series.h> 23 #ifdef DEAL_II_WITH_GSL 24 # include <gsl/gsl_sf_legendre.h> 28 DEAL_II_NAMESPACE_OPEN
35 <<
"x[" << arg1 <<
"] = " << arg2 <<
" is not in [0,1]");
45 #ifdef DEAL_II_WITH_GSL 47 for (
unsigned int d = 0;
d < dim;
d++)
49 const double x = 2.0 * (x_q[
d] - 0.5);
50 Assert((x_q[d] <= 1.0) && (x_q[d] >= 0.), ExcLegendre(d, x_q[d]));
51 const int ind = indices[
d];
52 res *= std::sqrt(2.0) * gsl_sf_legendre_Pl(ind, x);
61 ExcMessage(
"deal.II has to be configured with GSL" 62 "in order to use Legendre transformation."));
77 for (
unsigned int d = 0;
d < dim;
d++)
78 res *= (0.5 + indices[d]);
85 template <
int dim,
int spacedim>
90 const unsigned int dof)
93 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
99 return sum * multiplier(indices);
108 template <
int spacedim>
112 const unsigned int N,
113 const unsigned int fe,
118 if (legendre_transform_matrices[fe].m() == 0)
120 legendre_transform_matrices[fe].reinit(N,
121 fe_collection[fe].dofs_per_cell);
123 for (
unsigned int k = 0; k < N; ++k)
124 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
125 legendre_transform_matrices[fe](k, j) = integrate(
130 template <
int spacedim>
134 const unsigned int N,
135 const unsigned int fe,
140 if (legendre_transform_matrices[fe].m() == 0)
142 legendre_transform_matrices[fe].reinit(N * N,
143 fe_collection[fe].dofs_per_cell);
146 for (
unsigned int k1 = 0; k1 < N; ++k1)
147 for (
unsigned int k2 = 0; k2 < N; ++k2, k++)
148 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
149 legendre_transform_matrices[fe](k, j) =
150 integrate(fe_collection[fe],
157 template <
int spacedim>
161 const unsigned int N,
162 const unsigned int fe,
167 if (legendre_transform_matrices[fe].m() == 0)
169 legendre_transform_matrices[fe].reinit(N * N * N,
170 fe_collection[fe].dofs_per_cell);
173 for (
unsigned int k1 = 0; k1 < N; ++k1)
174 for (
unsigned int k2 = 0; k2 < N; ++k2)
175 for (
unsigned int k3 = 0; k3 < N; ++k3, k++)
176 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
177 legendre_transform_matrices[fe](k, j) =
178 integrate(fe_collection[fe],
190 template <
int dim,
int spacedim>
192 const unsigned int size_in_each_direction,
195 : N(size_in_each_direction)
196 , fe_collection(&fe_collection)
197 , q_collection(&q_collection)
198 , legendre_transform_matrices(fe_collection.size())
199 , unrolled_coefficients(
Utilities::fixed_power<dim>(N), 0.)
204 template <
int dim,
int spacedim>
205 template <
typename Number>
208 const ::Vector<Number> &local_dof_values,
209 const unsigned int cell_active_fe_index,
212 ensure_existence(*fe_collection,
215 cell_active_fe_index,
216 legendre_transform_matrices);
219 legendre_transform_matrices[cell_active_fe_index];
221 std::fill(unrolled_coefficients.begin(),
222 unrolled_coefficients.end(),
223 CoefficientType(0.));
227 Assert(local_dof_values.size() == matrix.n(),
230 for (
unsigned int i = 0; i < unrolled_coefficients.size(); i++)
231 for (
unsigned int j = 0; j < local_dof_values.size(); j++)
232 unrolled_coefficients[i] += matrix[i][j] * local_dof_values[j];
234 legendre_coefficients.
fill(unrolled_coefficients.begin());
240 #include "fe_series_legendre.inst" 242 DEAL_II_NAMESPACE_CLOSE
#define DeclException2(Exception2, type1, type2, outsequence)
Legendre(const unsigned int size_in_each_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
#define AssertIndexRange(index, range)
const Point< dim > & point(const unsigned int i) const
unsigned int size() const
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &legendre_coefficients)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)
unsigned int size() const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
void fill(InputIterator entries, const bool C_style_indexing=true)
double weight(const unsigned int i) const
static ::ExceptionBase & ExcInternalError()