32 <<
"x[" << arg1 <<
"] = " << arg2 <<
" is not in [0,1]");
43 for (
unsigned int d = 0;
d < dim; ++
d)
45 const double x = 2.0 * (x_q[
d] - 0.5);
46 Assert((x_q[d] <= 1.0) && (x_q[d] >= 0.), ExcLegendre(d, x_q[d]));
47 const unsigned int ind = indices[
d];
63 for (
unsigned int d = 0;
d < dim; ++
d)
64 res *= (0.5 + indices[d]);
71 template <
int dim,
int spacedim>
76 const unsigned int dof,
77 const unsigned int component)
80 for (
unsigned int q = 0; q < quadrature.
size(); ++q)
83 sum += Lh(x_q, indices) *
87 return sum * multiplier(indices);
96 template <
int spacedim>
99 const std::vector<unsigned int> &n_coefficients_per_direction,
102 const unsigned int fe,
103 const unsigned int component,
108 if (legendre_transform_matrices[fe].m() == 0)
110 legendre_transform_matrices[fe].reinit(
111 n_coefficients_per_direction[fe],
112 fe_collection[fe].n_dofs_per_cell());
114 for (
unsigned int k = 0; k < n_coefficients_per_direction[fe]; ++k)
115 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell(); ++j)
116 legendre_transform_matrices[fe](k, j) =
117 integrate(fe_collection[fe],
125 template <
int spacedim>
128 const std::vector<unsigned int> &n_coefficients_per_direction,
131 const unsigned int fe,
132 const unsigned int component,
137 if (legendre_transform_matrices[fe].m() == 0)
139 legendre_transform_matrices[fe].reinit(
140 Utilities::fixed_power<2>(n_coefficients_per_direction[fe]),
141 fe_collection[fe].n_dofs_per_cell());
144 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
145 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe];
147 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell();
149 legendre_transform_matrices[fe](k, j) =
150 integrate(fe_collection[fe],
158 template <
int spacedim>
161 const std::vector<unsigned int> &n_coefficients_per_direction,
164 const unsigned int fe,
165 const unsigned int component,
170 if (legendre_transform_matrices[fe].m() == 0)
172 legendre_transform_matrices[fe].reinit(
173 Utilities::fixed_power<3>(n_coefficients_per_direction[fe]),
174 fe_collection[fe].n_dofs_per_cell());
177 for (
unsigned int k1 = 0; k1 < n_coefficients_per_direction[fe]; ++k1)
178 for (
unsigned int k2 = 0; k2 < n_coefficients_per_direction[fe]; ++k2)
179 for (
unsigned int k3 = 0; k3 < n_coefficients_per_direction[fe];
181 for (
unsigned int j = 0; j < fe_collection[fe].n_dofs_per_cell();
183 legendre_transform_matrices[fe](k, j) =
184 integrate(fe_collection[fe],
197 template <
int dim,
int spacedim>
199 const std::vector<unsigned int> &n_coefficients_per_direction,
202 const unsigned int component_)
203 : n_coefficients_per_direction(n_coefficients_per_direction)
204 , fe_collection(&fe_collection)
205 , q_collection(q_collection)
206 , legendre_transform_matrices(fe_collection.
size())
207 , component(component_ !=
numbers::invalid_unsigned_int ? component_ : 0)
211 ExcMessage(
"All parameters are supposed to have the same size."));
217 "For vector-valued problems, you need to explicitly specify for "
218 "which vector component you will want to do a Legendre decomposition "
219 "by setting the 'component' argument of this constructor."));
224 const unsigned int max_n_coefficients_per_direction =
228 Utilities::fixed_power<dim>(max_n_coefficients_per_direction));
233 template <
int dim,
int spacedim>
239 (n_coefficients_per_direction == legendre.n_coefficients_per_direction) &&
240 (*fe_collection == *(legendre.fe_collection)) &&
241 (q_collection == legendre.q_collection) &&
242 (legendre_transform_matrices == legendre.legendre_transform_matrices) &&
243 (component == legendre.component));
248 template <
int dim,
int spacedim>
253 for (
unsigned int fe = 0; fe < fe_collection->
size(); ++fe)
255 ensure_existence(n_coefficients_per_direction,
260 legendre_transform_matrices);
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,
295 legendre_transform_matrices);
298 legendre_transform_matrices[cell_active_fe_index];
300 unrolled_coefficients.resize(Utilities::fixed_power<dim>(
301 n_coefficients_per_direction[cell_active_fe_index]));
302 std::fill(unrolled_coefficients.begin(),
303 unrolled_coefficients.end(),
308 Assert(local_dof_values.size() == matrix.n(),
311 for (
unsigned int i = 0; i < unrolled_coefficients.size(); ++i)
312 for (
unsigned int j = 0; j < local_dof_values.size(); ++j)
313 unrolled_coefficients[i] += matrix[i][j] * local_dof_values[j];
315 legendre_coefficients.fill(unrolled_coefficients.begin());
321#include "fe_series_legendre.inst"
const std::vector< unsigned int > n_coefficients_per_direction
ObserverPointer< const hp::FECollection< dim, spacedim > > fe_collection
bool operator==(const Legendre< dim, spacedim > &legendre) const
const unsigned int component
const hp::QCollection< dim > q_collection
Legendre(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()
unsigned int get_n_coefficients_per_direction(const unsigned int index) const
std::vector< CoefficientType > unrolled_coefficients
void calculate(const ::Vector< Number > &local_dof_values, const unsigned int cell_active_fe_index, Table< dim, CoefficientType > &legendre_coefficients)
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
unsigned int size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
#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)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
T sum(const T &t, const MPI_Comm mpi_communicator)
static const unsigned int invalid_unsigned_int
double legendre(unsigned int l, double x)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)