*/
unsigned int finest_level;
+ /**
+ * The number of degrees of freedom per vertex. We need to store
+ * this because every object of this kind stores the indices on
+ * all relevant levels in one array, and the starting offset for
+ * a particular level is determined by that level's index times
+ * the number of degrees of freedom per vertex.
+ */
+ unsigned int dofs_per_vertex;
+
/**
* A pointer to an array where we store the indices of the DoFs that live
* on the various levels this vertex exists on.
*
* The starting offset of the DoFs that belong to a @p level are given by
- * <code>indices_offset[level-coarsest_level]</code>.
+ * <code>dofs_per_vertex * (level-coarsest_level)</code>.
*/
types::global_dof_index *indices;
-
- /**
- * This array stores, for each level starting with coarsest_level, the
- * offset in the <code>indices</code> array where the DoF indices for each
- * level are stored.
- *
- * We need to explicitly store this offset because this class does not
- * store how many degrees of freedom the finite element has per vertex,
- * and consequently cannot compute the offset on the fly.
- */
- types::global_dof_index *indices_offset;
};
/**
const unsigned int dof_number) const
{
Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
- return indices[indices_offset[level - coarsest_level] + dof_number];
+ return indices[dofs_per_vertex * (level - coarsest_level) + dof_number];
}
const types::global_dof_index index)
{
Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
- indices[indices_offset[level - coarsest_level] + dof_number] = index;
+ indices[dofs_per_vertex * (level - coarsest_level) + dof_number] = index;
}
:
coarsest_level (numbers::invalid_unsigned_int),
finest_level (0),
- indices (nullptr),
- indices_offset (nullptr)
+ indices (nullptr)
{}
DoFHandler<dim, spacedim>::MGVertexDoFs::~MGVertexDoFs ()
{
delete[] indices;
- delete[] indices_offset;
}
template <int dim, int spacedim>
void DoFHandler<dim, spacedim>::MGVertexDoFs::init (const unsigned int cl,
const unsigned int fl,
- const unsigned int dofs_per_vertex)
+ const unsigned int n_dofs_per_vertex)
{
if (indices != nullptr)
{
indices = nullptr;
}
- if (indices_offset != nullptr)
- {
- delete[] indices_offset;
- indices_offset = nullptr;
- }
-
- coarsest_level = cl;
- finest_level = fl;
+ coarsest_level = cl;
+ finest_level = fl;
+ dofs_per_vertex = n_dofs_per_vertex;
if (coarsest_level <= finest_level)
{
indices = new types::global_dof_index[n_indices];
std::fill (indices, indices+n_indices, numbers::invalid_dof_index);
-
- indices_offset = new types::global_dof_index[n_levels];
- for (unsigned int i = 0; i < n_levels; ++i)
- indices_offset[i] = i * dofs_per_vertex;
}
}