Praveen,

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.

Right. The question is: Does it matter? All of these accesses should be close enough in memory that you shouldn't incur a lot of cache misses.


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.

But you can achieve this using global DoF index renumbering. That's the way I'd go.

Best
 W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/32056c07-837e-172a-bc2e-7c25d5552b4d%40colostate.edu.

Reply via email to