23 #ifdef DEAL_II_WITH_GSL 24 # include <gsl/gsl_sf_legendre.h> 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>
111 const std::vector<unsigned int> & n_coefficients_per_direction,
114 const unsigned int fe,
119 if (legendre_transform_matrices[fe].m() == 0)
121 legendre_transform_matrices[fe].reinit(n_coefficients_per_direction[fe],
122 fe_collection[fe].dofs_per_cell);
124 for (
unsigned int k = 0; k < n_coefficients_per_direction[fe]; ++k)
125 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
126 legendre_transform_matrices[fe](k, j) = integrate(
131 template <
int spacedim>
134 const std::vector<unsigned int> & n_coefficients_per_direction,
137 const unsigned int fe,
142 if (legendre_transform_matrices[fe].m() == 0)
144 legendre_transform_matrices[fe].reinit(
145 Utilities::fixed_power<2>(n_coefficients_per_direction[fe]),
146 fe_collection[fe].dofs_per_cell);
149 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
150 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe];
152 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
153 legendre_transform_matrices[fe](k, j) =
154 integrate(fe_collection[fe],
161 template <
int spacedim>
164 const std::vector<unsigned int> & n_coefficients_per_direction,
167 const unsigned int fe,
172 if (legendre_transform_matrices[fe].m() == 0)
174 legendre_transform_matrices[fe].reinit(
175 Utilities::fixed_power<3>(n_coefficients_per_direction[fe]),
176 fe_collection[fe].dofs_per_cell);
179 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
180 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe]; ++k2)
181 for (
unsigned int k3 = 0; k3 < n_coefficients_per_direction[fe];
183 for (
unsigned int j = 0; j < fe_collection[fe].dofs_per_cell; ++j)
184 legendre_transform_matrices[fe](k, j) =
185 integrate(fe_collection[fe],
197 template <
int dim,
int spacedim>
199 const std::vector<unsigned int> & n_coefficients_per_direction,
202 : n_coefficients_per_direction(n_coefficients_per_direction)
203 , fe_collection(&fe_collection)
204 , q_collection(q_collection)
205 , legendre_transform_matrices(fe_collection.size())
207 Assert(n_coefficients_per_direction.size() == fe_collection.
size() &&
208 n_coefficients_per_direction.size() == q_collection.
size(),
209 ExcMessage(
"All parameters are supposed to have the same size."));
212 const unsigned int max_n_coefficients_per_direction =
213 *std::max_element(n_coefficients_per_direction.cbegin(),
214 n_coefficients_per_direction.cend());
216 Utilities::fixed_power<dim>(max_n_coefficients_per_direction));
221 template <
int dim,
int spacedim>
223 const unsigned int n_coefficients_per_direction,
227 std::vector<unsigned
int>(fe_collection.size(),
228 n_coefficients_per_direction),
235 template <
int dim,
int spacedim>
249 template <
int dim,
int spacedim>
254 for (
unsigned int fe = 0; fe < fe_collection->
size(); ++fe)
256 ensure_existence(n_coefficients_per_direction,
268 template <
int dim,
int spacedim>
271 const unsigned int index)
const 273 return n_coefficients_per_direction[index];
278 template <
int dim,
int spacedim>
279 template <
typename Number>
282 const ::Vector<Number> &local_dof_values,
283 const unsigned int cell_active_fe_index,
286 for (
unsigned int d = 0;
d < dim; ++
d)
288 n_coefficients_per_direction[cell_active_fe_index]);
290 ensure_existence(n_coefficients_per_direction,
293 cell_active_fe_index,
300 n_coefficients_per_direction[cell_active_fe_index]));
307 Assert(local_dof_values.size() == matrix.
n(),
311 for (
unsigned int j = 0; j < local_dof_values.size(); j++)
320 #include "fe_series_legendre.inst"
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
Contents is actually a matrix.
Task< RT > new_task(const std::function< RT()> &function)
const hp::QCollection< dim > q_collection
std::vector< CoefficientType > unrolled_coefficients
#define AssertIndexRange(index, range)
unsigned int get_n_coefficients_per_direction(const unsigned int index) const
const Point< dim > & point(const unsigned int i) const
unsigned int size() const
Legendre(const std::vector< unsigned int > &n_coefficients_per_direction, const hp::FECollection< dim, spacedim > &fe_collection, const hp::QCollection< dim > &q_collection)
#define AssertThrow(cond, exc)
std::vector< FullMatrix< CoefficientType > > legendre_transform_matrices
const std::vector< unsigned int > n_coefficients_per_direction
static ::ExceptionBase & ExcMessage(std::string arg1)
bool operator==(const Legendre< dim, spacedim > &legendre) const
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
unsigned int size() const
#define DEAL_II_NAMESPACE_CLOSE
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)
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
void precalculate_all_transformation_matrices()
size_type size(const unsigned int i) const
virtual double shape_value(const unsigned int i, const Point< dim > &p) const
#define DEAL_II_NAMESPACE_OPEN
void fill(InputIterator entries, const bool C_style_indexing=true)
double weight(const unsigned int i) const
inline ::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &x)
static ::ExceptionBase & ExcInternalError()