Zhidong,

> In short, my question is how to get the cell_id properly by using CellId 
> class ?
> 
> I want to assign each cell with a different value (its pesudo density in 
> topology optimization). All the values are stored in a cell-based vector x, 
> which is initialized as follows,
> 
> opt->x.reinit(opt->mpi_communicator,
>                    opt->triangulation.n_global_active_cells(),
>                    opt->triangulation.n_locally_owned_active_cells(),
>                    false);
> 
> Now I want to access to x value in each cell. My basic idea is to get the 
> cell_id and then use x(cell_id). In order to get cell_id, I found I should 
> use 
> CellId class, specifically, cell->id().to_string().

I think this is the wrong approach. The cell ids are used to globally identify 
cells, but there is no easy way to translate between cell ids and an index 
into vectors. What you want to do is create another finite element field that 
is piecewise constant, i.e., using FE_DGQ(0). Such fields have exactly one 
value per cell, and they can be accessed like any other field-based quantity.

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/b54551f9-b2ab-8976-d6be-edd516137eff%40colostate.edu.

Reply via email to