/**
* Constructor. Pass the number of shape functions.
*/
- InternalData(const unsigned int n_shape_functions);
+ InternalData(const unsigned int polynomial_degree,
+ const unsigned int n_shape_functions);
/**
* Initialize the object's member variables related to cell data
std::vector<std::vector<Tensor<1,dim> > > unit_tangentials;
/**
- * Default value of this flag is @p true. If <tt>*this</tt> is an object
- * of a derived class, this flag is set to @p false. (This is, for example,
- * the case for MappingQ, which derives MappingQ::InternalData from the
- * current MappingQ1::InternalData.)
+ * The polynomial degree of the mapping. Since the objects here
+ * are also used (with minor adjustments) by MappingQ, we need to
+ * store this.
*/
- bool is_mapping_q1_data;
+ unsigned int polynomial_degree;
/**
* Number of shape functions. If this is a Q1 mapping, then it is simply
* Compute shape values and/or derivatives.
*
* Calls either the @p compute_shapes_virtual of this class or that of the
- * derived class, depending on whether <tt>data.is_mapping_q1_data</tt>
- * equals @p true or @p false.
+ * derived class, depending on whether <tt>data.polynomial_degree</tt>
+ * is one or is greater than that.
*/
void compute_shapes (const std::vector<Point<dim> > &unit_points,
InternalData &data) const;
template<int dim, int spacedim>
-MappingQ<dim,spacedim>::InternalData::InternalData (const unsigned int n_shape_functions)
+MappingQ<dim,spacedim>::InternalData::InternalData (const unsigned int polynomial_degree,
+ const unsigned int n_shape_functions)
:
- MappingQ1<dim,spacedim>::InternalData(n_shape_functions),
+ MappingQ1<dim,spacedim>::InternalData(polynomial_degree,
+ n_shape_functions),
use_mapping_q1_on_current_cell(false),
- mapping_q1_data(1 << dim)
-{
- this->is_mapping_q1_data=false;
-}
+ mapping_q1_data(1,
+ GeometryInfo<dim>::vertices_per_cell)
+{}
MappingQ<dim,spacedim>::get_data (const UpdateFlags update_flags,
const Quadrature<dim> &quadrature) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(degree, n_shape_functions);
// fill the data of both the Q_p and the Q_1 objects in parallel
Threads::TaskGroup<> tasks;
MappingQ<dim,spacedim>::get_face_data (const UpdateFlags update_flags,
const Quadrature<dim-1>& quadrature) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(degree, n_shape_functions);
const Quadrature<dim> q (QProjector<dim>::project_to_all_faces(quadrature));
// fill the data of both the Q_p and the Q_1 objects in parallel
MappingQ<dim,spacedim>::get_subface_data (const UpdateFlags update_flags,
const Quadrature<dim-1>& quadrature) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(degree, n_shape_functions);
const Quadrature<dim> q (QProjector<dim>::project_to_all_subfaces(quadrature));
// fill the data of both the Q_p and the Q_1 objects in parallel
const QGauss<dim> quadrature(degree+1);
const unsigned int n_q_points=quadrature.size();
- InternalData quadrature_data(n_shape_functions);
+ InternalData quadrature_data(degree, n_shape_functions);
quadrature_data.shape_derivatives.resize(n_shape_functions * n_q_points);
this->compute_shapes(quadrature.get_points(), quadrature_data);
Assert(q1_data!=0, ExcInternalError());
// If it is a genuine MappingQ::InternalData, we have to test further
- if (!q1_data->is_mapping_q1_data)
+ if (const InternalData *data = dynamic_cast<const InternalData *>(&mapping_data))
{
- Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
- ExcInternalError());
- const InternalData &data = static_cast<const InternalData &>(mapping_data);
// If we only use the Q1-portion, we have to extract that data object
- if (data.use_mapping_q1_on_current_cell)
- q1_data = &data.mapping_q1_data;
+ if (data->use_mapping_q1_on_current_cell)
+ q1_data = &data->mapping_q1_data;
}
+
// Now, q1_data should have the right tensors in it and we call the base
// classes transform function
MappingQ1<dim,spacedim>::transform(input, mapping_type, *q1_data, output);
Assert(q1_data!=0, ExcInternalError());
// If it is a genuine MappingQ::InternalData, we have to test further
- if (!q1_data->is_mapping_q1_data)
+ if (const InternalData *data = dynamic_cast<const InternalData *>(&mapping_data))
{
- Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
- ExcInternalError());
- const InternalData &data = static_cast<const InternalData &>(mapping_data);
// If we only use the Q1-portion, we have to extract that data object
- if (data.use_mapping_q1_on_current_cell)
- q1_data = &data.mapping_q1_data;
+ if (data->use_mapping_q1_on_current_cell)
+ q1_data = &data->mapping_q1_data;
}
+
// Now, q1_data should have the right tensors in it and we call the base
// classes transform function
MappingQ1<dim,spacedim>::transform(input, mapping_type, *q1_data, output);
Assert(q1_data!=0, ExcInternalError());
// If it is a genuine MappingQ::InternalData, we have to test further
- if (!q1_data->is_mapping_q1_data)
+ if (const InternalData *data = dynamic_cast<const InternalData *>(&mapping_data))
{
- Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
- ExcInternalError());
- const InternalData &data = static_cast<const InternalData &>(mapping_data);
// If we only use the Q1-portion, we have to extract that data object
- if (data.use_mapping_q1_on_current_cell)
- q1_data = &data.mapping_q1_data;
+ if (data->use_mapping_q1_on_current_cell)
+ q1_data = &data->mapping_q1_data;
}
+
// Now, q1_data should have the right tensors in it and we call the base
// classes transform function
MappingQ1<dim,spacedim>::transform(input, mapping_type, *q1_data, output);
Assert(q1_data!=0, ExcInternalError());
// If it is a genuine MappingQ::InternalData, we have to test further
- if (!q1_data->is_mapping_q1_data)
+ if (const InternalData *data = dynamic_cast<const InternalData *>(&mapping_data))
{
- Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
- ExcInternalError());
- const InternalData &data = static_cast<const InternalData &>(mapping_data);
// If we only use the Q1-portion, we have to extract that data object
- if (data.use_mapping_q1_on_current_cell)
- q1_data = &data.mapping_q1_data;
+ if (data->use_mapping_q1_on_current_cell)
+ q1_data = &data->mapping_q1_data;
}
+
// Now, q1_data should have the right tensors in it and we call the base
// classes transform function
MappingQ1<dim,spacedim>::transform(input, mapping_type, *q1_data, output);
Assert(q1_data!=0, ExcInternalError());
// If it is a genuine MappingQ::InternalData, we have to test further
- if (!q1_data->is_mapping_q1_data)
+ if (const InternalData *data = dynamic_cast<const InternalData *>(&mapping_data))
{
- Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
- ExcInternalError());
- const InternalData &data = static_cast<const InternalData &>(mapping_data);
// If we only use the Q1-portion, we have to extract that data object
- if (data.use_mapping_q1_on_current_cell)
- q1_data = &data.mapping_q1_data;
+ if (data->use_mapping_q1_on_current_cell)
+ q1_data = &data->mapping_q1_data;
}
+
// Now, q1_data should have the right tensors in it and we call the base
// classes transform function
MappingQ1<dim,spacedim>::transform(input, mapping_type, *q1_data, output);
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/mapping_q1.h>
+#include <deal.II/fe/mapping_q.h>
#include <deal.II/fe/mapping_q1_eulerian.h>
#include <cmath>
template<int dim, int spacedim>
-MappingQ1<dim,spacedim>::InternalData::InternalData (const unsigned int n_shape_functions)
+MappingQ1<dim,spacedim>::InternalData::InternalData (const unsigned int polynomial_degree,
+ const unsigned int n_shape_functions)
:
- is_mapping_q1_data(true),
+ polynomial_degree (polynomial_degree),
n_shape_functions (n_shape_functions)
-{}
+{
+ Assert (n_shape_functions ==
+ Utilities::fixed_power<dim>(polynomial_degree+1),
+ ExcInternalError());
+}
MemoryConsumption::memory_consumption (mapping_support_points) +
MemoryConsumption::memory_consumption (cell_of_current_support_points) +
MemoryConsumption::memory_consumption (volume_elements) +
- MemoryConsumption::memory_consumption (is_mapping_q1_data) +
+ MemoryConsumption::memory_consumption (polynomial_degree) +
MemoryConsumption::memory_consumption (n_shape_functions));
}
MappingQ1<dim,spacedim>::compute_shapes (const std::vector<Point<dim> > &unit_points,
InternalData &data) const
{
- // choose either the function implemented
- // in this class, or whatever a virtual
- // function call resolves to
- if (data.is_mapping_q1_data)
+ // choose either the function implemented in this class, or whatever
+ // a virtual function call resolves to
+ if (dynamic_cast<typename MappingQ<dim,spacedim>::InternalData *>(&data) == 0)
MappingQ1<dim,spacedim>::compute_shapes_virtual(unit_points, data);
else
compute_shapes_virtual(unit_points, data);
MappingQ1<dim,spacedim>::get_data (const UpdateFlags update_flags,
const Quadrature<dim> &q) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(1, n_shape_functions);
data->initialize (requires_update_flags(update_flags), q, q.size());
compute_shapes (q.get_points(), *data);
MappingQ1<dim,spacedim>::get_face_data (const UpdateFlags update_flags,
const Quadrature<dim-1> &quadrature) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(1, n_shape_functions);
data->initialize_face (requires_update_flags(update_flags),
QProjector<dim>::project_to_all_faces(quadrature),
quadrature.size());
MappingQ1<dim,spacedim>::get_subface_data (const UpdateFlags update_flags,
const Quadrature<dim-1>& quadrature) const
{
- InternalData *data = new InternalData(n_shape_functions);
+ InternalData *data = new InternalData(1, n_shape_functions);
data->initialize_face (requires_update_flags(update_flags),
QProjector<dim>::project_to_all_subfaces(quadrature),
quadrature.size());