I do want all dofs in a cell to be contiguous in memory. But I want bit more.
In a setup like this, say in dim=2
FESystem( FE_DGQArbitraryNodes(QGauss<1>(degree+1)), nvar)
Vector<double> solution
on each cell I want to extract the solution into a local variable
double cell_solution[degree+1][degree+1][nvar]
So I want all nvar-values at each support point to be contiguous in memory.
I can achieve this by doing a DoF renumbering. Suppose I have done this.
Now when I extract
cell->get_dof_indices( local_dof_indices );
index = 0;
for(j = 0; j < degree+1; ++j)
for(i = 0; i < degree+1; ++i)
for(c = 0; c < nvar; ++c)
{
cell_solution[j][i][c] = solution( local_dof_indices[index] );
++index;
}
The access into solution is not contiguous, it jumps around. This is because of how FESystem orders dofs within a cell.
To access solution contiguously, I can do this
cell->get_dof_indices( local_dof_indices );
for(j = 0; j < degree+1; ++j)
for(i = 0; i < degree+1; ++i)
for(c = 0; c < nvar; ++c)
{
c_index = i + (degree+1)*j;
index = fe.component_to_system_index(c, c_index);
cell_solution[j][i][c] = solution( local_dof_indices[index] );
}
but my access into local_dof_indices is not contiguous.
In a DG case, I should be able to do the following, without needing local_dof_indices, and still access all memory contiguously
cell->get_dof_indices( local_dof_indices );
index = local_dof_indices[0]; // get first index on this cell
for(j = 0; j < degree+1; ++j)
for(i = 0; i < degree+1; ++i)
for(c = 0; c < nvar; ++c)
{
cell_solution[j][i][c] = solution( index );
++index;
}
There is no need for the whole local_dof_indices, if I know the starting index on cell, it is enough.
This would be useful for writing tensor product DG codes, which is needed for things like Euler/compressible NS problems.
Thanks
praveen